Delphi PDF Viewer Component for VCL and FireMonkey
A native Delphi PDF viewer in pure Object Pascal: open a file and your users scroll, zoom, search, annotate and print it, in VCL and FireMonkey apps with no DLL to deploy.
A native Delphi PDF viewer in pure Object Pascal: open a file and your users scroll, zoom, search, annotate and print it, in VCL and FireMonkey apps with no DLL to deploy.
The sgcPDF viewer is a regular control on the sgcPDF palette page. Drop it on a form, or create it at run time, and load a file. The VCL viewer renders pages in the background into a bounded page cache, so large documents open quickly and scroll smoothly.
Place TsgcPDFViewerControl on a VCL form, or TsgcPDFViewerFMX on a FireMonkey form, and align it to the client area.
Set FileName in the Object Inspector, which also loads the file at design time, or call LoadFromFile or LoadFromStream at run time. A TsgcPDFDocument you created in code can be shown through the Document property.
Link TsgcPDFThumbnailView and TsgcPDFOutlineView to the viewer with their Viewer property for page thumbnails and a bookmarks tree. TsgcPDFCommentsView lists the annotations of the document.
The features of the VCL viewer TsgcPDFViewerControl. The FireMonkey viewer shares most of them, see the FireMonkey section.
Continuous, single page or two page layout. Fit width, fit page, fit height, actual size or a custom zoom, plus a zoom tool that fits a dragged rectangle. Keyboard, mouse wheel and hand tool navigation, and a view rotation in 90 degree steps.
The thumbnail view follows the current page and goes to a page on click, with thumbnails rendered on demand and cached. The outline view shows the bookmarks, and the comments view lists every annotation by page with author, date, contents and threaded replies.
FindText highlights every match in the document and scrolls to the first one, with case and whole word options. Users select text with the mouse, Ctrl+A selects all and Ctrl+C copies, and your code reads SelectedText.
With FormFilling, on by default, users fill text fields, check boxes, radio buttons, list boxes and combo boxes, and Tab moves between the fields. OnFieldChange reports each change to your code.
Users add sticky notes, free text, highlight, underline and strike-out, lines, arrows, rectangles, ellipses, freehand ink and stamps such as Approved, Draft or Confidential. They select, move, resize and delete them, and reply in a popup.
Print sends a page range to the current printer, and PrintDialog shows the print dialog with printer, page range, copies and collate. Every page prints with its own rotation, fitted to the paper, with the annotations in print mode.
Links to pages are followed, and OpenLinksInBrowser opens http, https and mailto links. OnPageChange, OnZoomChange, OnLinkClick and OnPaintPage let you build your own toolbar and draw on top of the pages.
High DPI aware on Delphi 10.3 and newer. With sgcUI, UseUITheme takes the viewer colours from the application theme. Page box display, a measure tool and overprint preview help print shops check their files.
The viewer shows what the rest of sgcPDF creates and edits: forms, generated invoices, extracted text, rendered pages and redacted documents.
A fillable PDF form in the viewer: users type in the fields and tick the check boxes.
An invoice generated in native code with TsgcPDFDocument, ready to show or print.
The sgcReports preview draws its pages through the sgcPDF viewer control.
Text extraction, the same text layer the viewer uses for search and selection.
Pages rendered to PNG at 144 DPI by the pure Pascal raster renderer.
Redaction with TsgcPDFRedactor removes the text, not just covers it.
A VCL form with page thumbnails on the left and the viewer filling the rest, plus a search box and a print button.
uses
Classes, Controls, Forms,
sgcPDF_ViewerVCL;
procedure TMainForm.FormCreate(Sender: TObject);
begin
// page thumbnails on the left
FThumbnails := TsgcPDFThumbnailView.Create(Self);
FThumbnails.Parent := Self;
FThumbnails.Align := alLeft;
FThumbnails.Width := 160;
// the viewer fills the rest of the form
FViewer := TsgcPDFViewerControl.Create(Self);
FViewer.Parent := Self;
FViewer.Align := alClient;
// link the thumbnails to the viewer and open the file
FThumbnails.Viewer := FViewer;
FViewer.LoadFromFile('invoice.pdf');
end;
procedure TMainForm.btnSearchClick(Sender: TObject);
begin
// highlights every match and scrolls to the first one
FViewer.FindText(edtSearch.Text);
end;
procedure TMainForm.btnPrintClick(Sender: TObject);
begin
// printer, page range, copies and collate
FViewer.PrintDialog('Invoice');
end;The FireMonkey viewer loads a file the same way:
uses
FMX.Types,
sgcPDF_ViewerFMX;
procedure TMainForm.FormCreate(Sender: TObject);
begin
FViewer := TsgcPDFViewerFMX.Create(Self);
FViewer.Parent := Self;
FViewer.Align := TAlignLayout.Client;
FViewer.LoadFromFile('invoice.pdf');
end;TsgcPDFViewerFMX shows PDF documents on Windows, macOS, iOS and Android, and on Linux with FMXLinux. It needs Delphi XE5 or newer and draws the pages with the pure Pascal raster renderer of sgcPDF.
Pinch to zoom, drag to pan, and a long press then a drag to zoom into an area. Continuous, single page and two page layouts, with fit width, fit page and fit height zoom modes.
FindText, FindNext and FindPrevious highlight and walk through the matches. Users add and edit the same annotation types as in the VCL viewer, and TsgcPDFCommentsViewFMX lists them with their replies.
Print and PrintDialog print on Windows and macOS with the FireMonkey print dialog. A drag on a page pans it. Text selection and copy are in the VCL viewer and the .NET viewers.
One PDF engine in Object Pascal behind every viewer, with the same member names in Delphi, C++ Builder and the .NET Windows Forms control.
TsgcPDFViewerControl for Delphi 7 to Delphi 13 and C++ Builder 2007 to 13, on Windows 32-bit and 64-bit.
TsgcPDFViewerFMX for Delphi XE5 and newer, on Windows, macOS, iOS, Android and Linux with FMXLinux.
TsgcPDFViewerControl in the esegece.sgcPDF.WinForms package, with thumbnail and outline views, for .NET Framework 4.7.2 and .NET 8 on Windows.
TsgcWpfPDFViewer for WPF on Windows, and TsgcAvaloniaPDFViewer for Avalonia on Windows, Linux and macOS, each with thumbnail and outline views, form filling and annotation editing.
Drop a TsgcPDFViewerControl from the sgcPDF palette page on the form, set Align to alClient and set FileName, or call LoadFromFile at run time as in the code sample. Add a TsgcPDFThumbnailView and a TsgcPDFOutlineView for thumbnails and bookmarks.
Yes. TsgcPDFViewerFMX is a FireMonkey control for Windows, macOS, iOS and Android, and for Linux with FMXLinux. It has zoom modes, pinch to zoom, search with highlights, annotations and printing on Windows and macOS. It needs Delphi XE5 or newer.
No. sgcPDF is written entirely in Object Pascal, and the parser, fonts, image decoders and renderers are compiled into your application. There is no DLL and no external PDF engine to deploy, and full source code is included.
Users fill text fields, check boxes, radio buttons, list boxes and combo boxes in the VCL viewer, and in the WinForms, WPF and Avalonia viewers, and your code saves the filled form. For signatures, TsgcPDFSignaturePad records a handwritten signature and ApplyToSignature puts it into the visible field of a digital signature, and the help shows how users drag signature stamps onto a page of the viewer before the document is signed.
Yes. Print prints a page range on the current printer, and PrintDialog shows the print dialog with printer, page range, copies and collate. Pages are fitted to the paper and the annotations print with them. The FireMonkey viewer prints on Windows and macOS.
Yes. Download the fully functional trial for Delphi and C++ Builder, with compiled demos you can run without the IDE. For .NET, every sgcPDF NuGet package also ships as a free Community edition for individuals and organizations under EUR 1M annual gross revenue with no more than 5 developers. See sgcPDF pricing for the licenses.
The VCL viewer supports Delphi 7 to Delphi 13 and C++ Builder 2007 to 13 on Windows 32-bit and 64-bit, and is High DPI aware on Delphi 10.3 and newer. The FireMonkey viewer needs Delphi XE5 or newer.