PDFViewer Component — sgcHTML | eSeGeCe

PDFViewer

TsgcHTMLComponent_PDFViewer — render an in-page PDF viewer backed by pdf.js, with page navigation, zoom, search, download and print, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_PDFViewer

Point PDFURL at a document (or embed it with Base64Data), tune the toolbar, then read the HTML property; pdf.js does the rendering client-side.

Component class

TsgcHTMLComponent_PDFViewer

Renders

Toolbar + canvas + scoped CSS (pdf.js from CDN)

Languages

Delphi, C++ Builder, .NET

Point it at a PDF, render it

Set PDFURL (or Base64Data to embed the bytes directly), pick InitialPage, Zoom and Theme, then read HTML.

uses
  sgcHTML_Component_PDFViewer;

var
  oViewer: TsgcHTMLComponent_PDFViewer;
begin
  oViewer := TsgcHTMLComponent_PDFViewer.Create(nil);
  try
    oViewer.ViewerID := 'invoice';
    oViewer.PDFURL := '/invoices/INV-2026-0042.pdf';
    oViewer.Height := '700px';
    oViewer.InitialPage := 1;
    oViewer.Zoom := 'page-width';
    oViewer.Theme := pvLight;
    oViewer.DownloadFileName := 'invoice-0042.pdf';

    WebModule.Response := oViewer.HTML;   // toolbar + canvas + pdf.js init script
  finally
    oViewer.Free;
  end;
end;
// includes: sgcHTML_Component_PDFViewer.hpp

TsgcHTMLComponent_PDFViewer *oViewer = new TsgcHTMLComponent_PDFViewer(NULL);
try
{
  oViewer->ViewerID = "invoice";
  oViewer->PDFURL = "/invoices/INV-2026-0042.pdf";
  oViewer->Height = "700px";
  oViewer->InitialPage = 1;
  oViewer->Zoom = "page-width";
  oViewer->Theme = pvLight;
  oViewer->DownloadFileName = "invoice-0042.pdf";

  String html = oViewer->HTML;   // toolbar + canvas + pdf.js init script
}
__finally
{
  delete oViewer;
}
using esegece.sgcWebSockets;

var viewer = new TsgcHTMLComponent_PDFViewer();
viewer.ViewerID = "invoice";
viewer.PDFURL = "/invoices/INV-2026-0042.pdf";
viewer.Height = "700px";
viewer.InitialPage = 1;
viewer.Zoom = "page-width";
viewer.Theme = TsgcHTMLPDFViewerTheme.pvLight;
viewer.DownloadFileName = "invoice-0042.pdf";

string html = viewer.HTML;   // toolbar + canvas + pdf.js init script

Key properties & methods

The members you reach for most often.

Source

PDFURL loads a URL-hosted document; Base64Data embeds the bytes directly (an optional data:application/pdf;base64, prefix is stripped automatically).

Toolbar toggles

ShowToolbar, ShowPageNav, ShowZoomControls, ShowDownload, ShowPrint and ShowSearch each show or hide one control group.

Zoom & page

InitialPage sets the starting page; Zoom accepts auto, page-width, fit, a percentage or a numeric factor.

Theme

Theme (TsgcHTMLPDFViewerTheme: pvLight, pvDark) switches the toolbar and canvas color scheme.

Self-hosting pdf.js

PDFJSLibURL/PDFJSWorkerURL default to the jsDelivr CDN build; override both to self-host the library.

Layout & download

Width/Height size the viewer; DownloadFileName names the file saved by the Download button.

Keep exploring

Online HelpFull API reference and usage guide for this component.
All sgcHTML ComponentsBrowse the full feature matrix of 80+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.

Ready to Get Started?

Download the free trial and start building web UIs in Delphi, C++ Builder and .NET.