eDocEngine VCL
Create documents and reports in 18 formats
Compatibility
Delphi C++Builder

How To Render HTML-Formatted Text In PDF

Learn how to render HTML-formatted text in PDF using eDocEngine VCL.
By R. Vyshakh

eDocEngine supports simple HTML tags in text strings it renders on PDF. Using this feature, you can specify formatted text using styles such as:

In the code snippet shown below, you will see how to render strings containing HTML tags on PDF.

begin
 // Use a PDF engine object
 with gtPDFEngine1 do
 begin
  // Specify output PDF file name
  FileName := 'FormattedText';

  // Specify measurement units
  MeasurementUnit := muInches;

  // Specify header/footer dimensions
  Page.HeaderHeight := 1;
  Page.FooterHeight := 1;

  BeginDoc;
   BeginHeader;
   // Use <i> HTML tag
   HTMLTextOut(0.5, 0.5, '<b>This header is in bold style</b>');
   EndHeader;

   // Use <b> and <i> HTML tags
   HTMLTextOut(
    1, 1,
    '<b>This is bold</b> and <i>this is italic</i>' +
    'and <i><b>this is bold and italic</b></i>!');

   BeginFooter;
   // Use <u> HTML tags
   HTMLTextOut(
     0.5, 0.5,
    '<u>This footer is underlined</u>.');
   EndFooter;

   BeginWatermark;
   // Use <s> HTML tags
   HTMLTextOut(
     1, 4,
     '<s>This watermark is in strike-through style.</s>');
   EndWatermark;
  EnDDoc;
 end;
end;

Here is how the PDF document created by eDocEngine looks.

---o0O0o---

Our Developer Tools
eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

XtremePDFConverter VCL

A Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers

PDFOne (for Java™)

A Java™ PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java™ applications.

XtremeFontEngine (for Java)

Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts

Our Office Productivity Applications
Free PDF Reader

A free, fast, and portable application for viewing, printing and converting PDF documents.

Privacy | Legal | Feedback | Newsletter | Resellers © 2002-2013 Gnostice Information Technologies Private Limited. All rights reserved.

This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).