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 .NET Developer Tools
Gnostice Document Studio .NET

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

PDFOne .NET

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

Our Delphi/C++Builder developer tools
Gnostice Document Studio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

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.

Our Java developer tools
Gnostice Document Studio Java

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

PDFOne (for Java)

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

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

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