sgcPDF Feature Matrix
Everything sgcPDF does, grouped by task. Every feature is implemented in Object Pascal in the sgcPDF_*.pas units and ships with full source code. The code samples on this page were compiled against the sgcPDF sources and run.
Everything sgcPDF does, grouped by task. Every feature is implemented in Object Pascal in the sgcPDF_*.pas units and ships with full source code. The code samples on this page were compiled against the sgcPDF sources and run.
13 features
6 features
7 features
5 features
3 features
6 features
6 features
| Feature | Details |
|---|---|
| Pages | Any page size and orientation, A4, Letter or custom, and page rotation. |
| Text | The 14 standard PDF fonts and colored text, with paragraph wrapping through the canvas and HTML renderers. |
| Embedded fonts | TrueType, OpenType (TrueType and CFF outlines) and TrueType collections, embedded and subset automatically, with Unicode ToUnicode maps so the text can be copied and searched. |
| Complex scripts | Kerning and ligatures, Arabic joining forms through GSUB, and the Unicode bidirectional algorithm for right to left text. |
| CJK text | Chinese, Japanese and Korean text through embedded TrueType and TrueType collection fonts. |
| Images | JPEG, PNG with alpha, BMP and TIFF (including CCITT fax images), with soft masks. |
| Vector graphics | Lines, rectangles, circles, ellipses, Bezier curves, polygons, dash patterns, line caps and joins, transparency and gradients. |
| Tables | Tables with headers, borders, cell padding and colors that continue across pages. |
| Barcodes | Code 128, Code 39, EAN-13, EAN-8, UPC-A, ITF, Codabar, GS1-128, QR Code, DataMatrix (ECC200) and PDF417, drawn as vectors. |
| Annotations and links | Text notes, highlights, links to URLs and to pages, stamps and free text annotations. |
| Bookmarks and layers | Nested bookmarks (outline) and optional content groups (layers) that readers can show or hide. |
| HTML to PDF | TsgcPDFHTMLRenderer: headings, paragraphs, inline CSS styles, lists, tables, images, links, page breaks, headers, footers and page numbers. |
| Canvas and EMF to PDF | TsgcPDFCanvas records drawing calls into PDF content, and EMF metafiles are played back into PDF vectors, so existing report and chart code produces PDF output. |
procedure HTMLToPDF(const APDFFile: string);
var
oHTML: TsgcPDFHTMLRenderer;
begin
oHTML := TsgcPDFHTMLRenderer.Create(nil);
try
oHTML.PageWidth := 595;
oHTML.PageHeight := 842;
oHTML.FooterText := 'Page {page} of {pages}';
oHTML.HTMLToPDFFile(
'<html><head><style>h1 { color: #003366 }</style></head><body>' +
'<h1>Invoice 2026-001</h1>' +
'<table><tr><th>Item</th><th>Amount</th></tr>' +
'<tr><td>Consulting</td><td>299.00</td></tr></table>' +
'</body></html>', APDFFile);
finally
oHTML.Free;
end;
end;
| Feature | Details |
|---|---|
| Watermarks and stamps | Text watermarks with font, size, rotation, color and opacity, on one page or on all pages. |
| Headers, footers, page numbers | Header and footer text and page numbers with a format such as Page %d of %d. |
| Page operations | Merge documents, split, extract page ranges, insert, delete, rotate and reorder pages. |
| Incremental save | Changes are appended to the original file as a new revision, which keeps earlier digital signatures valid. |
| Compact output | Object streams and cross reference streams for smaller files, plus TsgcPDFOptimizer to remove duplicates and unused objects and to downsample images. |
| Large files | Offsets are 64 bit end to end and objects are loaded on demand from a stream, so files over 2 GB can be opened and saved. |
| Feature | Details |
|---|---|
| VCL viewer | TsgcPDFViewerControl with scrolling, zoom modes, page navigation, text selection and copy, search with highlight, form field filling, link navigation and printing, plus TsgcPDFThumbnailView and TsgcPDFOutlineView. |
| FireMonkey viewer | TsgcPDFViewerFMX draws through the FMX canvas on Windows, macOS, iOS and Android. |
| Raster renderer for servers | TsgcPDFRendererRaster is a pure Pascal rasterizer that renders pages to pixels or PNG without GDI, on Windows and Linux. |
| GDI renderer and export | Render to a bitmap or a device context on Windows, and export pages and thumbnails to BMP, PNG or JPEG with TsgcPDFExporter. |
| Graphics model | DeviceGray, DeviceRGB, DeviceCMYK, Indexed, ICCBased and Lab color spaces, axial and radial shadings, tiling patterns, soft masks, blend opacity and form XObjects. |
| Fonts | Embedded TrueType, CFF, OpenType and Type 1 font programs are rendered from their outlines, with the standard encodings and Identity-H CID fonts. |
| Image decoders | Flate, LZW, ASCII85, ASCIIHex, RunLength, JPEG (baseline and progressive, CMYK), JPEG 2000, CCITT Group 3 and 4, and JBIG2. |
| Feature | Details |
|---|---|
| Text | Page text or whole document text, with Unicode mapping of embedded and CID fonts. |
| Text positions | TsgcPDFTextExtractor returns each text fragment with X, Y, font name and font size. |
| Search | Find text on a page or in the document. |
| Images | TsgcPDFImageExtractor enumerates the images of a page, including inline images and images inside form XObjects, and decodes them to PNG, JPEG or BMP. |
| Metadata and attachments | Document information, XMP metadata, bookmarks, layers and embedded files. |
| Feature | Details |
|---|---|
| Create forms | Text fields, check boxes, radio buttons, combo boxes, list boxes and push buttons with appearance streams. |
| Fill and flatten | Set field values in code or in the viewer, then flatten the form into static page content. |
| FDF and XFDF | Import and export form data as FDF and XFDF. |
| Feature | Details |
|---|---|
| Password encryption | RC4 40 bit and 128 bit, AES-128 and AES-256 (revisions 5 and 6), with user and owner passwords and permission flags. Encrypted files are decrypted on load. |
| Certificate encryption | Public key encryption for one or more recipient certificates (adbe.pkcs7.s4 and adbe.pkcs7.s5). |
| Digital signatures | Sign with a PFX certificate, visible or invisible signature fields, SHA-256, SHA-384 and SHA-512, RFC 3161 timestamps and document timestamps. |
| PAdES via sgcSign | TsgcPDFPAdESSigner produces ETSI.CAdES.detached signatures at levels B-B, B-T, B-LT and B-LTA, with DSS validation data, using any key provider of sgcSign (PEM, PFX, PKCS#11, Windows certificate store, cloud HSMs). sgcSign is licensed separately. |
| Verification | TsgcPDFSignatureVerifier checks integrity, byte range coverage, the signer certificate and the certificate chain of every signature. |
| Redaction | TsgcPDFRedactor removes text at glyph level, image pixels, vector paths and annotations under a region or matching a text, adds an overlay and can strip metadata. The removed text cannot be extracted from the output. |
procedure CreateEncryptedPDF(const AFileName: string);
var
oPDF: TsgcPDFDocument;
begin
oPDF := TsgcPDFDocument.Create;
try
oPDF.AddPage(595, 842).DrawText('Secret', 50, 780, sfHelveticaBold, 24);
// user password opens the file, owner password grants full rights
oPDF.SetEncryption(emAES_256, 'user123', 'owner456');
oPDF.SaveToFile(AFileName);
finally
oPDF.Free;
end;
end;
procedure SignPDF(const AInput, AOutput: string);
var
oSigner: TsgcPDFSignatureHandler;
begin
oSigner := TsgcPDFSignatureHandler.Create;
try
oSigner.LoadCertificateFromPFX('signer.pfx', 'test123');
oSigner.Reason := 'Document approval';
oSigner.Location := 'Barcelona';
oSigner.HashAlgorithm := shaSHA256;
// visible signature field on page 1: Left, Bottom, Right, Top
oSigner.SetField('Signature1', 0, 50, 50, 250, 100);
oSigner.SignDocument(AInput, AOutput);
finally
oSigner.Free;
end;
end;
procedure SignPAdES(const AInput, AOutput: string);
var
oKey: TsgcPEMKeyProvider;
oSigner: TsgcPDFPAdESSigner;
begin
oKey := TsgcPEMKeyProvider.Create(nil);
oSigner := TsgcPDFPAdESSigner.Create(nil);
try
// any sgcSign key provider: PEM, PFX, PKCS#11, Windows store, cloud HSM
oKey.LoadFromFile('signer.pem', 'signer.key');
oSigner.KeyProvider := oKey;
// paBB, paBT (timestamp), paBLT and paBLTA (long term validation)
oSigner.Level := paBB;
// signature field and appearance through the sgcPDF handler
oSigner.Handler.SetField('Signature1', 0, 350, 50, 550, 110);
oSigner.Handler.SignerName := 'John Smith';
oSigner.Handler.Reason := 'Approved';
oSigner.SignPDFFile(AInput, AOutput);
oSigner.KeyProvider := nil;
finally
oSigner.Free;
oKey.Free;
end;
end;
procedure RedactFile(const AInput, AOutput: string);
var
oRedactor: TsgcPDFRedactor;
vOptions: TsgcPDFRedactionOptions;
begin
oRedactor := TsgcPDFRedactor.Create;
try
// every occurrence of a text, on all pages
oRedactor.AddText('John Smith');
// an area of page 0: left, bottom, right, top in points
oRedactor.AddArea(0, 50, 500, 250, 650);
vOptions := oRedactor.Options;
vOptions.OverlayText := 'REDACTED';
vOptions.RemoveMetadata := True;
oRedactor.Options := vOptions;
oRedactor.Apply(AInput, AOutput);
finally
oRedactor.Free;
end;
end;
| Feature | Details |
|---|---|
| PDF/A | PDF/A-1, PDF/A-2 and PDF/A-3 output at levels a and b, with XMP metadata, output intent and embedded fonts. |
| Validator | TsgcPDFAValidator checks a file against the selected PDF/A level and reports errors and warnings. |
| Tagged PDF | Structure tree with Document, Part, Sect, H1 to H6, P, L, LI, Table, TR, TH, TD and Figure with alternate text, marked content, role map, language and MarkInfo. |
| PDF/UA-1 | Accessible output together with PDF/A-2a or PDF/A-3a, and PDF/UA-1 checks in the validator. |
| Attachments | Embedded files with MIME type, dates and PDF/A-3 associated file relationships. |
| Factur-X and ZUGFeRD | Embeds the invoice XML with the Factur-X XMP extension schema for the Minimum, Basic WL, Basic, EN 16931, Extended and XRechnung profiles, and saves the file as PDF/A-3b. |
procedure CreateFacturX(const AInvoiceXML, AFileName: string);
var
oPDF: TsgcPDFDocument;
oXML: TMemoryStream;
vXML: TBytes;
vFont: Integer;
begin
oPDF := TsgcPDFDocument.Create;
oXML := TMemoryStream.Create;
try
// the invoice XML (CII) is created by your application
oXML.LoadFromFile(AInvoiceXML);
SetLength(vXML, oXML.Size);
Move(oXML.Memory^, vXML[0], oXML.Size);
oPDF.Info.Title := 'Invoice 2026-001';
// PDF/A requires embedded fonts
vFont := oPDF.AddTrueTypeFont('Arial', False, False);
oPDF.AddPage(595, 842).DrawTextTT('Invoice 2026-001', 50, 780, vFont, 18);
// embeds factur-x.xml, adds the Factur-X XMP schema, saves as PDF/A-3b
oPDF.Attachments.AddFacturX(vXML, fxpEN16931);
oPDF.SaveToFile(AFileName);
finally
oXML.Free;
oPDF.Free;
end;
end;
procedure ValidatePDFA(const AFileName: string);
var
oParser: TsgcPDFParser;
oValidator: TsgcPDFAValidator;
i: Integer;
begin
oParser := TsgcPDFParser.Create;
oValidator := TsgcPDFAValidator.Create(paA3b);
try
oParser.LoadFromFile(AFileName);
oParser.Parse;
if oValidator.Validate(oParser) then
WriteLn('PDF/A-3b: no errors')
else
for i := 0 to oValidator.Errors.Count - 1 do
WriteLn('Error: ', oValidator.Errors[i]);
finally
oValidator.Free;
oParser.Free;
end;
end;