ByteScout PDF Renderer SDK - C# - Make Thumbnail - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout PDF Renderer SDK – C# – Make Thumbnail

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Renderer SDK – C# – Make Thumbnail

ByteScout PDF Renderer SDK – C# – Make Thumbnail

Program.cs

using System.Drawing;
using System.Diagnostics;
using Bytescout.PDFRenderer;

namespace MakeThumbnail
{
static class Program
{
static void Main()
{
// Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it
RasterRenderer renderer = new RasterRenderer();
renderer.RegistrationName = “demo”;
renderer.RegistrationKey = “demo”;

// Load PDF document
renderer.LoadDocumentFromFile(“multipage.pdf”);

// Get size of the page in Points (standard PDF document units; 1 Point = 1/72″)
RectangleF rectangle = renderer.GetPageRectangle(0);

int width, height;

if (rectangle.Width < rectangle.Height) // portrait page orientation { width = -1; // width will be calculated from height keeping the aspect ratio height = 100; } else // landscape page orientation { width = 100; height = -1; // height will be calculated from width keeping the aspect ratio } // Render first page of the document to JPEG image file renderer.Save("thumbnail.jpg", RasterImageFormat.JPEG, 0, width, height); // Cleanup renderer.Dispose(); // Open result document in default associated application (for demo purpose) ProcessStartInfo processStartInfo = new ProcessStartInfo("thumbnail.jpg"); processStartInfo.UseShellExecute = true; Process.Start(processStartInfo); } } } [/csharp]


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next