PDF Rendering Engines in Windows Forms PDF Viewer (PdfViewerControl)

9 Jun 20235 minutes to read

Syncfusion WinForms PDF Viewer renders the PDF pages through 2 different rendering engines.

  • PDFium (Google Chrome’s PDF rendering engine)
  • SfPdf (Syncfusion’s Own PDF rendering engine)

PDFium

PDFium is used in Google Chrome for rendering PDF files. It provides accurate and robust PDF rendering. It is the recommended PDF rendering engine.

NOTE

  • From v16.3.0.x onwards, this PDFium rendering engine is the default rendering engine of Syncfusion WinForms PDF Viewer.
  • From v20.4.0.x onwards, ARM64-based Pdfium assembly is generated for Syncfusion WinForms PDF Viewer control in applications that target ARM64 architecture.
  • From v22.1.x onwards, Pdfium is upgraded to the new version which was built with the branch chromium/5692.

How PDFium works with Syncfusion’s PDF Viewer

  • On running your WinForms application, Syncfusion PDF Viewer control generates a folder named PDFium in the application output path folder (for example: bin/release or bin/debug) at runtime.
  • Syncfusion PDF Viewer control detects the architecture of the running machine automatically.
  • Next, it creates another subfolder named “x64”, “x86” or “arm64” based on the machine architecture.
  • Extracts the PDFium binary (PDFium.dll) into the subfolder (x64, x86 or arm64) and consumes it to render PDF files.

Pdfium Folder Structure

NOTE

PDFium rendering is not supported in Windows XP operating system.

How to run PDFium in a restricted access environment

If there is any access restriction applied to the application output folder, then the Syncfusion PDF Viewer control cannot able to extract and consume the PDFium engine as mentioned above.

In that situation, you need to add the following steps to consume the PDFium rendering engine.

  • Create a folder where your application can access, create & read files. For example, “d:\ThirdPartyBinaries".
  • Update the path of this folder to the ReferencePath property of PDF Viewer control, like shown in the following code sample.
  • If ReferencePath is set, then PDF Viewer control extracts the PDFium binary inside that specified folder and consume the PDFium rendering engine.
using Syncfusion.Windows.Forms.PdfViewer;
using System.Windows.Forms;

namespace PdfViewerDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            //Set the reference path.
            pdfViewer.ReferencePath = @"D:\ThirdPartyBinaries\";
            //Load the PDF.
            pdfViewer.Load("Sample.pdf");
        }
    }
}

NOTE

In the run time, the PDF viewer will check the custom folder path provided in the ReferencePath property. If you already placed the Pdfium assemblies in the custom folder path, it will refer to the already available assemblies from the location. It won’t generate the assemblies in the folder again.
You need to place the PDFium assembly in the correct folder structure as mentioned below.

  • ThirdPartyBinaries
    • Pdfium
      • x86
        • Pdfium.dll
      • x64
        • Pdfium.dll
      • arm64
        • Pdfium.dll

SfPdf

SfPdf is the Syncfusion’s own PDF rendering engine. Before v16.3.0.x, PDF Viewer control has used this rendering engine as default to rendering the PDF pages. If you wish to use SfPdf rendering engine or face any compatibility issues with Pdfium rendering engine in your environment, you may set the RenderingEngine property to SfPdf as shown in the following code sample.

NOTE

The recommended PDF rendering engine is PDFium.

using Syncfusion.Windows.Forms.PdfViewer;
using System.Windows.Forms;

namespace PdfViewerDemo
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            //Set the rendering engine as `SfPdf`.
            pdfViewer.RenderingEngine = PdfRenderingEngine.SfPdf;
            //Load the PDF.
            pdfViewer.Load("Sample.pdf");
        }
    }
}