Link Search Menu Expand Document

Render Part of PDF Page - C#

PDF Renderer SDK sample in C# demonstrating ‘Render Part of PDF Page’

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

namespace RenderPartOfPdfPage
    class Program
        static void Main(string[] args)
            // Create an instance of Bytescout.PDFRenderer.RasterRenderer object and register it.
            RasterRenderer renderer = new RasterRenderer();
            renderer.RegistrationName = "demo";
            renderer.RegistrationKey = "demo";

            // Set high quality resolution 600 dpi (600 dots per inch)
            float renderingResolution = 600;

            // Load PDF document.

            // Set extraction area
            renderer.SetExtractionArea(205.5f, 108.75f, 331.5f, 121.5f);

            // Render part of document to PNG image file.
            renderer.Save($"result_{renderingResolution}.png", RasterImageFormat.PNG, 0, renderingResolution);

            // Cleanup

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo($"result_{renderingResolution}.png");
            processStartInfo.UseShellExecute = true;

Download Source Code (.zip)

Return to the previous page Explore PDF Renderer SDK