PDF-Viewer-exporter-in-pure-Free-Pascal-Lazarus-Delphi
PDF Viewer (+exporter) in pure Free Pascal/ Lazarus/ Delphi
- Active · last change 7-7-2026
- ★ 13 on GitHub
README
License
GNU/GPL. Commercial licenses available, starting at $100 (single developer, up to 5 programs).
Usage examples
Just showing a PDF:
uses ... PdfParser, PdfBitmapRenderer, XelPDF;
...
type
TForm1 = class(TForm)
...
public
PDF: TXelPDF;
end;
...
procedure TForm1.FormCreate(Sender: TObject);
begin
PDF := TXelPDF.Create(Form1);
Pdf.Parent := Form1;
Pdf.Align := alClient;
Pdf.AutoFit := afWidth; //fit to width of the component
Pdf.LoadFromFile('test.pdf');
end;
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
Pdf.Free;
end;Converting .TXT to .PDF
PDF := TXelPDF.Create(Form1);
Pdf.LoadFromFile('input.txt');
Pdf.Document.SaveToFile('txt.pdf');Exporting an embedded font:
TotalFonts := PDF.Document.CountFonts; //count fonts in the PDF
PDF.Document.ExportFont(5, 'out.otf'); //5 is the number of the fontExporting a JPEG or another bitmap:
//images that are embedded as JPEGs in the PDF- no recompression, except CMYK->RGB
Total := Doc.JpegsCount(PageNumber);
Doc.ExportJpeg(PageNumber, JpegNumber, 'out.jpg');Other images:
//images that are embedded in other formats in the PDF- conversion to PNG
Total := Doc.ImagesCount(PageNumber);
Doc.ExportImage(PageNumber, ImageNumber, 'out.png');Exporting vector images to SVG
Total := Doc.VectorGroupsCount(PageNumber);
Doc.ExportVectorGroup(PageNumber, ImageNumber, 'out.svg');Drawing a rectangle:
Doc.DrawRect(0, 50, 600, 200, 80, clRed); //PageNum, Left, Top, Width, Height, ColorRendering to image
Doc.RenderPageToPng(PageNumber, 'out.png');Insert another PDF between pages of current PDF
F := TFileStream.Create('another.pdf', fmOpenRead);
Doc.ImportPDF(F, 0, 0, 0);Insert a blank page or remove a page:
Doc.RemovePage(PageIndex);
Doc.AddPage(Width, Height);Load or save document to file or stream
Doc.SaveToStream(Str: TStream);
Doc.SaveToFile('output.pdf');Insert a JPEG image into a PDF:
Doc.AddJpegImage(PageIndex, JpegBytes, Left, Top, Width, Height);Insert some text into a PDF:
FontRes := Doc.AddFont(FontName, FontSize);
Doc.AddText(PageIndex, 'Test Here', Left, Top, FontRes);Extract text to a file
Doc.ExtractTextToFile(PageIndex, 'output.txt');Features
Printing, rotating, extracting text, removing pages.
Supports encrypted PDFs
Supports:
- RC4-40 (R2), RC4-128 (R3)
- AES-128 (V4/R4, AESV2)
- AES-256 (V5/R6, AESV3)
PDF Features supported
Stream filters:
- FlateDecode
- LZWDecode
- ASCIIHexDecode
- ASCII85Decode
- RunLengthDecode
Images:
- JPEG / DCTDecode: baseline and progressive, with grayscale, RGB, CMYK and Adobe YCCK source spaces. CMYK→RGB is done Adobe-aware.
- Raw/Flate/LZW raster images in DeviceRGB, DeviceGray, DeviceCMYK, CalRGB, CalGray, and Indexed (palette) color.
- CCITT Group 3/4 fax images (monochrome)
- ICCBased images (RGB, CMYK, Gray).
- Soft-mask transparency
- Lab color-space images
- JPEG 2000 / JPXDecode
- JBIG2 images (monochrome) Embedded font formats:
- TrueType — FontFile2
- CFF / Type1C / CIDFontType0C / OpenType — FontFile3
PDF Features NOT supported
?

