creating pdf documents using pl/sql create pdf in pl/sql generate pdf in pl/sql
pdf by pl/sql pl/sql Oracle Sql PDF pl/sql pdf generate
tool develop oracle pl/sql download
creating html_db applications
spacer
plsql generate pdf
html_db spacer Home Examples TrueType Font support
printemail html_db printed report

TrueType font support

The PDF specification enables the use of TrueType fonts in PDF documents. With the use of TTF fonts, the number of print types can be extended. To do this TTF files are embedded into the PDF document. PL/PDF supports the use of embedded TTF fonts.

To use TTF fonts:

  1. Obtain the desired TTF file: to embed the TTF font, the file with TTF extension is needed. Please take into account that the usage of certain fonts are under copyright. Important: check that the TTF file contains all the characters needed.
  2. Generate the Adobe Font Metrics (AFM) file: the AFM file may be generated by the TTF2PT1 program (http://ttf2pt1.sourceforge.net). The binary version can be downloaded from ttf2pt1. From the command line run the following command: ttf2pt1 -a .ttf . The AFM file is create as .afm.
  3. Load the PLPDF_TTF_FILE table (To load BLOB type data use SQL*Loader or TOAD.):

    • ID (NUMBER): unique identifier

    • FONTFILE_NAME (VARCHAR2(255)): TTF file name with extension (.ttf)

    • FONTFILE_DATA (BLOB): the binary TTF font

    • AFMFILE_DATA (BLOB): the uploaded AFM file

  4. Load the PLPDF_TTF_AFM table: The content of the AFM file is stored in the table line by line. Use afm.ctl to load the table, and then overwrite the value of the FILE_ID field to the unique identifier specified in the PLPDF_TTF_FILE table.

  5. Generate the data necessary for the embedding: run plpdf_ttf.StoreTTF procedure where the parameters are:

    • P_FONT_FILE_ID: the value of the ID in PLPDF_TTF_FILE

    • P_ENC: encoding value, use the encoding values specified in the PL/PDF documentation. The default value is cp1252.

The generated data is stored in the PLPDF_ADD and PLPDF_ADD_CW tables. The ID is taken from the PLPDF_TTF_S sequence. The ID can be used to reference the font during the generation of the PDF document.

The create data can now be used while generating a PDF document. Here is how to use the fonts in the PDF generator:

  • Declare a Plpdf_Type.t_addfont type variable, e.g. l_ttf Plpdf_Type.t_addfont;

  • Retrieve the font using the Plpdf_TTF.GetTTF procedure. The parameter is the ID field of the PLPDF_ADD table, e.g. l_ttf := Plpdf_Ttf.GetTTF(21);

  • Add the TTF font to the PDF document: run the Plpdf.addTTF procedure, where the parameters are:

    • P_FAMILY: the name that can be used to reference the font in the SetPrintFont procedure.

    • P_STYLE: the font style (some TTF fonts only contain the regular style):

      • NULL: regular

      • B: Bold

      • I: Italic

      • BI: Bold, Italic

    • P_DATA: data needed to embed the font. Use the result of the Plpdf_TTF.GetTTF function.

Example: Plpdf.addTTF('ArialMT', NULL, l_ttf);

  • After this the font can be referenced by the SetPrintFont procedure using the P_FAMILY.

Example: test1ttf.prc

Warning: using TrueType fonts in conjunction with PDF file Protection may significantly decrease the speed of PDF generation, because the embedded file is also encrypted using the RC4 encryption.

spacer
pl/sql pdf
mod_plsql pdf