Link Search Menu Expand Document

Render Text-Vector-Image Layers in PDF - C#

PDF Renderer SDK sample in C# demonstrating ‘Render Text-Vector-Image Layers in PDF’

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

namespace PDF2PNG
    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";

            RenderingOptions renderingOptions = new RenderingOptions();

            // Enable text objects rendering
            renderingOptions.RenderTextObjects = true;
            // DISABLE vector objects rendering
            renderingOptions.RenderVectorObjects = false;
            // DISABLE image objects rendering
            renderingOptions.RenderImageObjects = false;
            // Load PDF document.

            for (int i = 0; i < renderer.GetPageCount(); i++)
                // Render document page to PNG image file.
                renderer.Save("image" + i + ".png", RasterImageFormat.PNG, i, 300, renderingOptions);

            // Cleanup

            // Open result document in default associated application (for demo purpose)
            ProcessStartInfo processStartInfo = new ProcessStartInfo("image0.png");
            processStartInfo.UseShellExecute = true;

Download Source Code (.zip)

Return to the previous page Explore PDF Renderer SDK