v3.4.0 · Oracle 19c+

API Reference

Detailed documentation of every public function and procedure of the PL_FPDF package: syntax, parameters with accepted values, return, errors and an example. For a task-oriented guide, see the usage index. Installation, compatibility and common problems are in the guides; the 18 APIs of PL_FPDF_UTIL (QR, barcodes, compression and encryption, used from inside PL_FPDF) are documented in its own spec.

Lifecycle

fpdf Procedure#

Initialises the document in the classic FPDF style. Kept for compatibility with v0.9.4; use Init in new code.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.fpdf(
    orientation varchar2 DEFAULT 'P',
    unit        varchar2 DEFAULT 'mm',
    format      varchar2 DEFAULT 'A4');

Parameters

ParameterTypeDefaultDescription
orientationVARCHAR2'P'Orientation. 'P' (default) or 'L'
unitVARCHAR2'mm'Unit of measurement. 'mm' (default), 'cm', 'pt' or 'in'
formatVARCHAR2'A4'Page format. 'A3', 'A4' (default), 'A5', 'Letter' or 'Legal'

Example

PL_FPDF.fpdf('L', 'mm', 'A4');

See also: Init

Init Procedure#

Initialises a new PDF document. This must be the first call of any generation; it sets the orientation, unit of measurement, page format and encoding used by every other API.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.Init(
    p_orientation varchar2 DEFAULT 'P',
    p_unit        varchar2 DEFAULT 'mm',
    p_format      varchar2 DEFAULT 'A4',
    p_encoding    varchar2 DEFAULT 'UTF-8');

Parameters

ParameterTypeDefaultDescription
p_orientationVARCHAR2'P'Default page orientation. 'P' (portrait, the default) or 'L' (landscape)
p_unitVARCHAR2'mm'Unit of measurement for every coordinate and dimension in the document. 'mm' (default), 'cm', 'pt' or 'in'
p_formatVARCHAR2'A4'Default page format. 'A3', 'A4' (default), 'A5', 'Letter' or 'Legal'
p_encodingVARCHAR2'UTF-8'Character encoding of the text. 'UTF-8' (default) or 'WINDOWS-1252'

Errors

CodeWhen
ORA-20001invalid orientation
ORA-20002invalid unit of measurement
ORA-20003unsupported encoding

Example

PL_FPDF.Init('P', 'mm', 'A4');

See also: Reset, IsInitialized, AddPage

IsInitialized Function#

Tells whether a document is currently being built in this session.

Since version 2.0.0

Syntax

FUNCTION PL_FPDF.IsInitialized RETURN BOOLEAN;

Returns

BOOLEAN — TRUE if Init has been called and the document has not been finalised.

Example

IF NOT PL_FPDF.IsInitialized THEN PL_FPDF.Init; END IF;

See also: Init

Reset Procedure#

Returns the PDF engine to its initial state, freeing temporary CLOBs and clearing every internal array. Use it between documents generated in the same job, or at the end of long routines.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.Reset;

Example

PL_FPDF.Reset;

See also: Init, ClearPDFCache

Pages and positioning

AcceptPageBreak Function#

Reports whether an automatic page break should happen at the current point. The engine calls it internally; you can read it for your own pagination logic.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.AcceptPageBreak RETURN BOOLEAN;

Returns

BOOLEAN — TRUE if the automatic page break is enabled.

Example

IF PL_FPDF.AcceptPageBreak THEN ... END IF;

See also: SetAutoPageBreak

AddPage Procedure#

Adds a new page to the document and makes it the current one. NULL parameters inherit the values set in Init, which lets you mix orientations and formats within the same PDF.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.AddPage(
    p_orientation varchar2 DEFAULT null,
    p_format      varchar2 DEFAULT null,
    p_rotation    pls_integer DEFAULT 0);

Parameters

ParameterTypeDefaultDescription
p_orientationVARCHAR2nullOrientation for this page only. 'P', 'L' or NULL (inherits from Init)
p_formatVARCHAR2nullPage format for this page only. 'A3', 'A4', 'A5', 'Letter', 'Legal' or NULL (inherits from Init)
p_rotationPLS_INTEGER0Display rotation applied by the PDF reader. 0 (default), 90, 180 or 270

Note

The NAME of the first parameter changed between versions -- it was 'orientation' in 2.0.0 and today it is 'p_orientation'. Callers that pass by position (AddPage('L')) are unaffected; callers that pass by name (AddPage(orientation => 'L')) have to use the new name. There is no way to accept both: overloads differing only in parameter name make the call ambiguous, and Oracle refuses them with PLS-00307.

Errors

CodeWhen
ORA-20005Init has not been called yet
ORA-20107invalid orientation
ORA-20103unknown page format
ORA-20101invalid dimensions in the free-form format
ORA-20104invalid rotation

Example

PL_FPDF.AddPage;
PL_FPDF.AddPage('L');
PL_FPDF.AddPage('P', '210,297', 90);

See also: Init, SetPage, GetCurrentPage

GetCurrentPage Function#

Returns the number of the current page — the one receiving content.

Since version 2.0.0

Syntax

FUNCTION PL_FPDF.GetCurrentPage RETURN PLS_INTEGER;

Returns

PLS_INTEGER — number of the active page.

Example

l_pagina := PL_FPDF.GetCurrentPage;

See also: SetPage, PageNo

GetX Function#

Returns the current X position of the cursor.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.GetX RETURN NUMBER;

Returns

NUMBER — X coordinate.

Example

l_x := PL_FPDF.GetX;

See also: SetX, SetXY

GetY Function#

Returns the current Y position of the cursor.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.GetY RETURN NUMBER;

Returns

NUMBER — Y coordinate.

Example

l_y := PL_FPDF.GetY;

See also: SetY

Ln Procedure#

Moves the cursor to the next line, back at the left margin.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Ln(
    h number DEFAULT null);

Parameters

ParameterTypeDefaultDescription
hNUMBERnullHeight of the jump. Number in the unit set by Init (mm, cm, pt or in); NULL (default) uses the height of the last cell written

Example

PL_FPDF.Cell(40, 10, 'First');
PL_FPDF.Ln;

See also: SetXY

PageNo Function#

Returns the current page number during generation; typically used in footers.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.PageNo RETURN NUMBER;

Returns

NUMBER — number of the current page.

Example

PL_FPDF.Cell(0, 10, 'Page ' || PL_FPDF.PageNo);

See also: SetAliasNbPages, SetFooterProc

SetAutoPageBreak Procedure#

Turns the automatic page break on or off and sets how far from the bottom edge it happens.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetAutoPageBreak(
    pauto   boolean,
    pMargin number DEFAULT 0);

Parameters

ParameterTypeDefaultDescription
pautoBOOLEAN—Enables the automatic page break. TRUE or FALSE
pMarginNUMBER0Bottom margin that triggers the break. Number in the unit set by Init (mm, cm, pt or in); 0 is the default

Example

PL_FPDF.SetAutoPageBreak(TRUE, 20);

See also: AcceptPageBreak, SetMargins

SetLeftMargin Procedure#

Sets the left margin only.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetLeftMargin(
    pMargin number);

Parameters

ParameterTypeDefaultDescription
pMarginNUMBER—Left margin. Number in the unit set by Init (mm, cm, pt or in)

Example

PL_FPDF.SetLeftMargin(25);

See also: SetMargins

SetMargins Procedure#

Sets the left, top and right margins of the document. The bottom margin is controlled by SetAutoPageBreak.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetMargins(
    left  number,
    top   number,
    right number DEFAULT -1);

Parameters

ParameterTypeDefaultDescription
leftNUMBER—Left margin. Number in the unit set by Init (mm, cm, pt or in)
topNUMBER—Top margin. Number in the unit set by Init (mm, cm, pt or in)
rightNUMBER-1Right margin. Number in the unit set by Init (mm, cm, pt or in); -1 (default) reuses the left margin value

Example

PL_FPDF.SetMargins(20, 15);

See also: SetLeftMargin, SetTopMargin, SetRightMargin, SetAutoPageBreak

SetPage Procedure#

Chooses which existing page receives the content of the next calls, so you can go back to an earlier page — to fill in a table of contents once the final page numbers are known, for instance.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.SetPage(
    p_page_number pls_integer);

Parameters

ParameterTypeDefaultDescription
p_page_numberPLS_INTEGER—Page that becomes the current one. Integer >= 1, up to GetPageCount

Errors

CodeWhen
ORA-20005Init has not been called yet
ORA-20106the page does not exist

Example

PL_FPDF.SetPage(1);

See also: AddPage, GetCurrentPage

SetRightMargin Procedure#

Sets the right margin only.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetRightMargin(
    pMargin number);

Parameters

ParameterTypeDefaultDescription
pMarginNUMBER—Right margin. Number in the unit set by Init (mm, cm, pt or in)

Example

PL_FPDF.SetRightMargin(20);

See also: SetMargins

SetTopMargin Procedure#

Sets the top margin only.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetTopMargin(
    pMargin number);

Parameters

ParameterTypeDefaultDescription
pMarginNUMBER—Top margin. Number in the unit set by Init (mm, cm, pt or in)

Example

PL_FPDF.SetTopMargin(15);

See also: SetMargins

SetX Procedure#

Sets the X position of the cursor.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetX(
    px number);

Parameters

ParameterTypeDefaultDescription
pxNUMBER—New X coordinate. Number in the unit set by Init (mm, cm, pt or in); negative values count from the right edge

Example

PL_FPDF.SetX(-40);

See also: GetX

SetXY Procedure#

Sets both X and Y of the cursor in a single call.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetXY(
    x number,
    y number);

Parameters

ParameterTypeDefaultDescription
xNUMBER—X coordinate. Number in the unit set by Init (mm, cm, pt or in)
yNUMBER—Y coordinate. Number in the unit set by Init (mm, cm, pt or in)

Example

PL_FPDF.SetXY(20, 50);

See also: SetX, SetY

SetY Procedure#

Sets the Y position of the cursor, and moves X back to the left margin.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetY(
    py number);

Parameters

ParameterTypeDefaultDescription
pyNUMBER—New Y coordinate. Number in the unit set by Init (mm, cm, pt or in); negative values count from the bottom edge — e.g. -15 for a footer

Example

PL_FPDF.SetY(-20);   -- 20 above the foot of the page

See also: GetY, SetXY

Fonts and UTF-8

AddFont Procedure#

Registers an additional font (FPDF compatibility). For TrueType with UTF-8, prefer AddTTFFont.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.AddFont(
    family   varchar2,
    style    varchar2 DEFAULT '',
    filename varchar2 DEFAULT '');

Parameters

ParameterTypeDefaultDescription
familyVARCHAR2—Family name to register. Free text; used later in SetFont
styleVARCHAR2''Style tied to the file. '', 'B', 'I' or 'BI'
filenameVARCHAR2''Font definition file. File name; empty uses the standard FPDF convention

Example

PL_FPDF.AddFont('Arial', 'B');

See also: AddTTFFont, SetFont

AddTTFFont Procedure#

Registers a TrueType font from a BLOB and makes it available to SetFont. The file's tables are really parsed, and the font is embedded in the PDF as /FontFile2.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.AddTTFFont(
    p_font_name varchar2,
    p_font_blob blob,
    p_encoding  varchar2 DEFAULT 'UTF-8',
    p_embed     boolean DEFAULT true);

Parameters

ParameterTypeDefaultDescription
p_font_nameVARCHAR2—Name by which the font will be referenced in SetFont. Free text, e.g. 'Roboto'
p_font_blobBLOB—Binary content of the .ttf file. Non-null BLOB holding a valid TrueType font
p_encodingVARCHAR2'UTF-8'Font encoding. 'UTF-8' (default) or 'WINDOWS-1252'
p_embedBOOLEANtrueEmbeds the font program in the PDF. TRUE or FALSE; TRUE is the default

Errors

CodeWhen
ORA-20210font name is empty
ORA-20211font BLOB is null

Example

SELECT arquivo INTO l_ttf FROM fontes WHERE nome = 'Roboto';
PL_FPDF.AddTTFFont('Roboto', l_ttf);

See also: LoadTTFFromFile, IsTTFFontLoaded, SetFont

ClearTTFFontCache Procedure#

Discards every loaded TrueType font, freeing session memory.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.ClearTTFFontCache;

Example

PL_FPDF.ClearTTFFontCache;

See also: AddTTFFont

GetTTFFontInfo Function#

Returns a TrueType font's record: the stored bytes and the metrics parsed from the file, rescaled to the PDF's 1000 units per em.

Since version 2.0.0

Syntax

FUNCTION PL_FPDF.GetTTFFontInfo(
    p_font_name varchar2) RETURN RECTTFFONT;

Parameters

ParameterTypeDefaultDescription
p_font_nameVARCHAR2—Font name. The same one used when loading

Returns

recTTFFont — record with the font's metrics and information.

Errors

CodeWhen
ORA-20206font not loaded

Example

l_fonte := PL_FPDF.GetTTFFontInfo('Roboto');

See also: AddTTFFont

IsTTFFontLoaded Function#

Checks whether a TrueType font has already been loaded in this session.

Since version 2.0.0

Syntax

FUNCTION PL_FPDF.IsTTFFontLoaded(
    p_font_name varchar2) RETURN BOOLEAN;

Parameters

ParameterTypeDefaultDescription
p_font_nameVARCHAR2—Font name. The same one used when loading

Returns

BOOLEAN — TRUE if the font is in the cache.

Example

IF NOT PL_FPDF.IsTTFFontLoaded('Roboto') THEN ... END IF;

See also: AddTTFFont, ClearTTFFontCache

LoadTTFFromFile Procedure#

Loads a TrueType font from a file inside an Oracle DIRECTORY.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.LoadTTFFromFile(
    p_font_name varchar2,
    p_file_path varchar2,
    p_directory varchar2 DEFAULT 'FONTS_DIR',
    p_encoding  varchar2 DEFAULT 'UTF-8');

Parameters

ParameterTypeDefaultDescription
p_font_nameVARCHAR2—Name to use in SetFont. Free text
p_file_pathVARCHAR2—Name of the .ttf file inside the directory. E.g. 'Roboto-Regular.ttf'
p_directoryVARCHAR2'FONTS_DIR'Oracle DIRECTORY with read permission. Default: 'FONTS_DIR'
p_encodingVARCHAR2'UTF-8'Font encoding. 'UTF-8' (default) or 'WINDOWS-1252'

Errors

CodeWhen
ORA-20202invalid font file
ORA-20401invalid directory
ORA-20402no read permission

Example

PL_FPDF.LoadTTFFromFile('Roboto', 'Roboto-Regular.ttf', 'FONTS_DIR');

See also: AddTTFFont

SetFont Procedure#

Sets the font family, style and size used by the next text writes.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetFont(
    pfamily varchar2,
    pstyle  varchar2 DEFAULT '',
    psize   number DEFAULT 0);

Parameters

ParameterTypeDefaultDescription
pfamilyVARCHAR2—Font family. 'Arial'/'Helvetica', 'Times', 'Courier', 'Symbol', 'ZapfDingbats' or the name of a TrueType font loaded with AddTTFFont/LoadTTFFromFile
pstyleVARCHAR2''Text style. '' (regular), 'B' (bold), 'I' (italic), 'BI' (bold italic) or 'U' (underlined)
psizeNUMBER0Size in points. Number > 0; 0 (default) keeps the current size

Note

The family is stored in lower case and the style in upper case. That is what the getters return, not the text given here.

Errors

CodeWhen
ORA-20005Init has not been called yet
ORA-20201font not found -- neither among the core fonts nor in the TrueType registry
ORA-20100invalid style

Example

PL_FPDF.SetFont('Helvetica', 'B', 12);

See also: SetFontSize, AddTTFFont, GetStringWidth

SetFontSize Procedure#

Changes only the size of the current font.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetFontSize(
    psize number);

Parameters

ParameterTypeDefaultDescription
psizeNUMBER—Size in points. Number > 0

Example

PL_FPDF.SetFontSize(8);

See also: SetFont

UTF8ToPDFString Function#

Converts UTF-8 text to the PDF's internal representation. Called internally; useful when debugging accented characters.

Since version 2.0.0

Syntax

FUNCTION PL_FPDF.UTF8ToPDFString(
    p_text   varchar2,
    p_escape boolean DEFAULT true) RETURN VARCHAR2;

Parameters

ParameterTypeDefaultDescription
p_textVARCHAR2—Text to convert. Any VARCHAR2 in UTF-8
p_escapeBOOLEANtrueEscapes the PDF special characters (parentheses and backslash). TRUE or FALSE

Returns

VARCHAR2 — the converted text.

Example

l_txt := PL_FPDF.UTF8ToPDFString('Total (net)');

Writing text

Cell Procedure#

Writes a rectangular block of text, with optional borders, alignment, fill and link. It is the API most used to build reports and tables.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Cell(
    pw      number,
    ph      number DEFAULT 0,
    ptxt    varchar2 DEFAULT '',
    pborder varchar2 DEFAULT '0',
    pln     number DEFAULT 0,
    palign  varchar2 DEFAULT '',
    pfill   number DEFAULT 0,
    plink   varchar2 DEFAULT '');

Parameters

ParameterTypeDefaultDescription
pwNUMBER—Cell width. Number in the unit set by Init (mm, cm, pt or in); 0 stretches to the right margin
phNUMBER0Cell height. Number in the unit set by Init (mm, cm, pt or in); 0 is the default
ptxtVARCHAR2''Text to write. Any VARCHAR2; empty draws the cell alone
pborderVARCHAR2'0''0' for no border, '1' for the whole frame, or the letters of the sides you want, combined: 'L' (Left), 'T' (Top), 'R' (Right) and 'B' (Bottom). 'LR' draws only the two sides; 'TB', only top and bottom
plnNUMBER0Where the cursor goes afterwards.
0 = to the right of the cell (default)
1 = start of the next line
2 = below the cell
palignVARCHAR2''Text alignment. 'L' (left), 'C' (centre), 'R' (right) or '' (default, left)
pfillNUMBER0Fills the background with the SetFillColor colour.
0 = transparent (default)
1 = filled
plinkVARCHAR2''Optional link URL ('https://...') that makes the cell clickable. Internal links are not supported: see AddLink

Errors

CodeWhen
ORA-20100any failure while writing the cell. Cell wraps the original error in this code, but keeps the stack (keeperrorstack), so the cause -- an ORA-20203 for a character outside WinAnsi, for instance -- stays visible in the trace.

Example

-- the whole frame around the cell
PL_FPDF.Cell(40, 8, 'Total', '1', 0, 'L');
PL_FPDF.Cell(30, 8, '1.234,56', '1', 1, 'R');

-- only the bottom, to underline a column heading
PL_FPDF.Cell(100, 8, 'Product', 'B', 1, 'L');

-- table body: each cell draws only the sides ('LR'), and an empty
-- cell with the top ('T') closes the table underneath. Without that,
-- '1' on every cell would give a double rule between the rows.
PL_FPDF.Cell(60, 8, 'Annual licence', 'LR', 0, 'L');
PL_FPDF.Cell(40, 8, '28.400,00',     'LR', 1, 'R');
PL_FPDF.Cell(60, 8, 'Support 8x5',   'LR', 0, 'L');
PL_FPDF.Cell(40, 8, '15.750,50',     'LR', 1, 'R');
PL_FPDF.Cell(100, 0, '', 'T', 1);

See also: MultiCell, Write, CellRotated, SetFillColor

CellRotated Procedure#

Cell with the text rotated — useful for vertical table headers and labels.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.CellRotated(
    p_width    number,
    p_height   number DEFAULT 0,
    p_text     varchar2 DEFAULT '',
    p_border   varchar2 DEFAULT '0',
    p_ln       number DEFAULT 0,
    p_align    varchar2 DEFAULT '',
    p_fill     number DEFAULT 0,
    p_link     varchar2 DEFAULT '',
    p_rotation pls_integer DEFAULT 0);

Parameters

ParameterTypeDefaultDescription
p_widthNUMBER—Cell width. Number in the unit set by Init (mm, cm, pt or in); 0 stretches to the right margin
p_heightNUMBER0Cell height. Number in the unit set by Init (mm, cm, pt or in)
p_textVARCHAR2''Text to write. Any VARCHAR2
p_borderVARCHAR2'0''0' for no border, '1' for the whole frame, or the letters of the sides you want, combined: 'L' (Left), 'T' (Top), 'R' (Right) and 'B' (Bottom). 'LR' draws only the two sides; 'TB', only top and bottom
p_lnNUMBER0Cursor position afterwards.
0 = to the right
1 = next line
2 = below
p_alignVARCHAR2''Alignment. 'L', 'C' or 'R'
p_fillNUMBER0Fill. 0 or 1
p_linkVARCHAR2''Optional link URL. Internal links are not supported: see AddLink
p_rotationPLS_INTEGER0Rotation angle of the text. 0 (default), 90, 180 or 270 — any other value raises an error

Errors

CodeWhen
ORA-20110invalid rotation

Example

PL_FPDF.CellRotated(10, 40, 'January', '1', 0, 'C', 0, '', 90);

See also: Cell, WriteRotated

GetCurrentFontFamily Function#

Returns the family of the current font.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.GetCurrentFontFamily RETURN VARCHAR2;

Returns

VARCHAR2 — the family name.

Example

l_familia := PL_FPDF.GetCurrentFontFamily;

See also: SetFont

GetCurrentFontSize Function#

Returns the size of the current font.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.GetCurrentFontSize RETURN NUMBER;

Returns

NUMBER — size in points.

Example

l_corpo := PL_FPDF.GetCurrentFontSize;

See also: SetFont

GetCurrentFontStyle Function#

Returns the style of the current font.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.GetCurrentFontStyle RETURN VARCHAR2;

Returns

VARCHAR2 — '', 'B', 'I', 'BI' or 'U', always UPPERCASE. > SetFont normalises it: 'b' goes in and 'B' comes back.

Example

l_estilo := PL_FPDF.GetCurrentFontStyle;

See also: SetFont

GetLineSpacing Function#

Returns the current line spacing.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.GetLineSpacing RETURN NUMBER;

Returns

NUMBER — the configured spacing.

Example

l_entre := PL_FPDF.GetLineSpacing;

See also: SetLineSpacing

GetStringWidth Function#

Measures how wide a piece of text will be in the current font and size — use it to centre by hand, size columns, or decide where to break.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.GetStringWidth(
    pstr varchar2) RETURN NUMBER;

Parameters

ParameterTypeDefaultDescription
pstrVARCHAR2—Text to measure. Any VARCHAR2

Returns

NUMBER — width in the document's unit.

Errors

CodeWhen
ORA-20203character outside WinAnsi

Example

l_larg := PL_FPDF.GetStringWidth('São Paulo');

See also: SetFont, Cell

MultiCell Function#

Writes a paragraph with automatic line breaking inside a given width. It exists as a function, returning the number of lines, and as a procedure.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.MultiCell(
    pw      number,
    ph      number DEFAULT 0,
    ptxt    varchar2,
    pborder varchar2 DEFAULT '0',
    palign  varchar2 DEFAULT 'J',
    pfill   number DEFAULT 0,
    phMax   number DEFAULT 0) RETURN NUMBER;
PROCEDURE PL_FPDF.MultiCell(
    pwidth     number,
    pheight    number DEFAULT 0,
    ptext      varchar2,
    pbrdr      varchar2 DEFAULT '0',
    palignment varchar2 DEFAULT 'J',
    pfillin    number DEFAULT 0,
    phMaximum  number DEFAULT 0);

Parameters

ParameterTypeDefaultDescription
pwNUMBER—Block width. Number in the unit set by Init (mm, cm, pt or in); 0 stretches to the right margin
phNUMBER0Height of each line. Number in the unit set by Init (mm, cm, pt or in)
ptxtVARCHAR2—Paragraph text; line breaks are honoured. Any VARCHAR2
pborderVARCHAR2'0''0' for no border, '1' for the whole frame, or the letters of the sides you want, combined: 'L' (Left), 'T' (Top), 'R' (Right) and 'B' (Bottom). 'LR' draws only the two sides; 'TB', only top and bottom
palignVARCHAR2'J'Alignment. 'J' (justified, default), 'L', 'C' or 'R'
pfillNUMBER0Fills the background. 0 (default) or 1
phMaxNUMBER0Maximum block height; text beyond it is truncated. Number; 0 (default) = no limit

In the overload above the parameters are the same, in the same order, under other names: pwidth, pheight, ptext, pbrdr, palignment, pfillin, phMaximum.

Returns

NUMBER (function version) — how many lines were produced.

Errors

CodeWhen
ORA-20100any failure while writing, with the original stack preserved

Example

-- justified paragraph, with the whole frame
l_linhas := PL_FPDF.MultiCell(120, 5, l_texto_longo, '1', 'J');

-- no border at all, which is the usual case in body text
l_linhas := PL_FPDF.MultiCell(120, 5, l_texto_longo, '0', 'J');

-- only the sides, for a block inside a table
l_linhas := PL_FPDF.MultiCell(120, 5, l_observacao, 'LR', 'L');

See also: Cell, Write

SetLineSpacing Procedure#

Sets the line spacing used by Write and MultiCell.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetLineSpacing(
    pls number);

Parameters

ParameterTypeDefaultDescription
plsNUMBER—Spacing factor or height. Number > 0

Example

PL_FPDF.SetLineSpacing(5);

See also: GetLineSpacing

Text Procedure#

Writes text at absolute coordinates, without moving the cursor or breaking lines.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Text(
    px   number,
    py   number,
    ptxt varchar2);

Parameters

ParameterTypeDefaultDescription
pxNUMBER—X coordinate where the text starts. Number in the unit set by Init (mm, cm, pt or in)
pyNUMBER—Y coordinate of the baseline. Number in the unit set by Init (mm, cm, pt or in)
ptxtVARCHAR2—Text to write. Any VARCHAR2

Errors

CodeWhen
ORA-20203character outside WinAnsi

Example

PL_FPDF.Text(20, 50, 'Billing address');

See also: Cell, Write

Write Procedure#

Writes text as a flow, continuing where the previous one stopped and breaking lines automatically — which lets you switch fonts and styles in the middle of a sentence.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Write(
    pH    varchar2,
    ptxt  varchar2,
    plink varchar2 DEFAULT null);

Parameters

ParameterTypeDefaultDescription
pHVARCHAR2—Line height. Number in the unit set by Init (mm, cm, pt or in)
ptxtVARCHAR2—Text to write. Any VARCHAR2
plinkVARCHAR2nullOptional link URL applied to the text; NULL (default) = no link. Internal links are not supported: see AddLink

Errors

CodeWhen
ORA-20100any failure while writing, with the original stack preserved

Example

PL_FPDF.SetFont('Helvetica', '', 10);
PL_FPDF.Write(5, 'Consulte o ');
PL_FPDF.SetFont('Helvetica', 'U', 10);
PL_FPDF.Write(5, 'manual', 'https://example.com/manual');

See also: Cell, MultiCell, WriteRotated

WriteRotated Procedure#

The same as Write, with a rotation parameter -- but only a rotation of 0 degrees is accepted: any other raises -20111. For rotated text, use CellRotated.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.WriteRotated(
    p_height   number,
    p_text     varchar2,
    p_link     varchar2 DEFAULT null,
    p_rotation pls_integer DEFAULT 0);

Parameters

ParameterTypeDefaultDescription
p_heightNUMBER—Line height. Number in the unit set by Init (mm, cm, pt or in)
p_textVARCHAR2—Text to write. Any VARCHAR2
p_linkVARCHAR2nullOptional link URL
NULL = no link. Internal links are not supported: see AddLink
p_rotationPLS_INTEGER0Rotation angle in degrees; only 0 is accepted

Errors

CodeWhen
ORA-20110invalid rotation
ORA-20111only 0-degree rotation is supported; use CellRotated

Example

PL_FPDF.WriteRotated(5, 'Text on the line', NULL, 0);
-- rotated: PL_FPDF.CellRotated(10, 40, 'CONFIDENTIAL', '0', 0, 'C', 0, '', 90);

See also: Write, CellRotated

Colours and drawing

Line Procedure#

Draws a straight line between two points.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Line(
    x1 number,
    y1 number,
    x2 number,
    y2 number);

Parameters

ParameterTypeDefaultDescription
x1NUMBER—X of the start point. Number in the unit set by Init (mm, cm, pt or in)
y1NUMBER—Y of the start point. Number in the unit set by Init (mm, cm, pt or in)
x2NUMBER—X of the end point. Number in the unit set by Init (mm, cm, pt or in)
y2NUMBER—Y of the end point. Number in the unit set by Init (mm, cm, pt or in)

Example

PL_FPDF.Line(20, 60, 190, 60);

See also: SetDrawColor, SetLineWidth

Poly Procedure#

Draws a polygon from a collection of points.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Poly(
    points tab_points,
    pclose boolean,
    pstyle varchar2 DEFAULT '');

Parameters

ParameterTypeDefaultDescription
pointsTAB_POINTS—Points of the polygon. tab_points collection with X/Y pairs in the document's unit
pcloseBOOLEAN—Closes the polygon, joining the last point to the first. TRUE or FALSE
pstyleVARCHAR2''Rendering style. '' or 'D' (outline), 'F' (filled), 'DF' (both)

Example

l_pontos(0).x := 10; l_pontos(0).y := 10;
l_pontos(1).x := 50; l_pontos(1).y := 10;
l_pontos(2).x := 30; l_pontos(2).y := 40;
PL_FPDF.Poly(l_pontos, TRUE, 'F');

See also: Line, Triangle

Rect Procedure#

Draws a rectangle: outlined, filled, or both.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Rect(
    px     number,
    py     number,
    pw     number,
    ph     number,
    pstyle varchar2 DEFAULT '');

Parameters

ParameterTypeDefaultDescription
pxNUMBER—X of the top-left corner. Number in the unit set by Init (mm, cm, pt or in)
pyNUMBER—Y of the top-left corner. Number in the unit set by Init (mm, cm, pt or in)
pwNUMBER—Width. Number in the unit set by Init (mm, cm, pt or in)
phNUMBER—Height. Number in the unit set by Init (mm, cm, pt or in)
pstyleVARCHAR2''Rendering style. '' or 'D' (outline only, the default), 'F' (fill only), 'DF'/'FD' (outline + fill)

Example

PL_FPDF.Rect(20, 40, 60, 25, 'FD');

See also: SetDrawColor, SetFillColor

SetDash Procedure#

Sets a simple dashed-line pattern.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetDash(
    pblack number DEFAULT 0,
    pwhite number DEFAULT 0);

Parameters

ParameterTypeDefaultDescription
pblackNUMBER0Length of the dash. Number in the unit set by Init (mm, cm, pt or in); 0 (default) goes back to a solid line
pwhiteNUMBER0Length of the gap. Number in the unit set by Init (mm, cm, pt or in); 0 (default) goes back to a solid line

Example

PL_FPDF.SetDash(2, 2);          -- tracejado
PL_FPDF.Line(10, 50, 200, 50);
PL_FPDF.SetDash;                -- back to the solid line

See also: SetLineDashPattern

SetDrawColor Procedure#

Sets the colour of the lines and outlines drawn next.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetDrawColor(
    r number,
    g number DEFAULT -1,
    b number DEFAULT -1);

Parameters

ParameterTypeDefaultDescription
rNUMBER—Red component, or the grey level when g and b are omitted. 0 to 255
gNUMBER-1Green component. 0 to 255; -1 (default) means greyscale, using r
bNUMBER-1Blue component. 0 to 255; -1 (default) means greyscale, using r

Errors

CodeWhen
ORA-20501component outside 0..255

Example

PL_FPDF.SetDrawColor(200);            -- cinza claro
PL_FPDF.SetDrawColor(0, 90, 160);     -- azul

See also: SetFillColor, SetTextColor, SetLineWidth

SetFillColor Procedure#

Sets the fill colour of cells (pfill = 1), rectangles and shapes.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetFillColor(
    r number,
    g number DEFAULT -1,
    b number DEFAULT -1);

Parameters

ParameterTypeDefaultDescription
rNUMBER—Red component, or the grey level. 0 to 255
gNUMBER-1Green component. 0 to 255; -
1 = greyscale
bNUMBER-1Blue component. 0 to 255; -
1 = greyscale

Errors

CodeWhen
ORA-20501component outside 0..255

Example

PL_FPDF.SetFillColor(230, 230, 230);
PL_FPDF.Cell(40, 8, 'Heading', '1', 0, 'C', 1);

See also: Cell, Rect

SetLineDashPattern Procedure#

Sets the dash pattern using the PDF's own syntax, for fine control.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetLineDashPattern(
    pdash varchar2 DEFAULT '[] 0');

Parameters

ParameterTypeDefaultDescription
pdashVARCHAR2'[] 0'Pattern in PDF format. '[] 0' (solid, the default), '[3 2] 0' (3 on, 2 off), '[1 2 3 2] 0' and so on

Example

PL_FPDF.SetLineDashPattern('[3 2] 0');

See also: SetDash

SetLineWidth Procedure#

Sets the thickness of the lines drawn next.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetLineWidth(
    width number);

Parameters

ParameterTypeDefaultDescription
widthNUMBER—Line thickness. Number in the unit set by Init (mm, cm, pt or in); the PDF default is about 0.2 mm

Errors

CodeWhen
ORA-20502zero or negative line width

Example

PL_FPDF.SetLineWidth(0.5);

See also: Line, Rect

SetTextColor Procedure#

Sets the colour of the text written next.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetTextColor(
    r number,
    g number DEFAULT -1,
    b number DEFAULT -1);

Parameters

ParameterTypeDefaultDescription
rNUMBER—Red component, or the grey level. 0 to 255
gNUMBER-1Green component. 0 to 255; -
1 = greyscale
bNUMBER-1Blue component. 0 to 255; -
1 = greyscale

Errors

CodeWhen
ORA-20501component outside 0..255

Example

PL_FPDF.SetTextColor(180, 0, 0);

See also: SetFont, Cell

Triangle Procedure#

Draws an isosceles triangle with a base of 2xpsize and a height of psize, pointing in the direction given.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Triangle(
    px           number,
    py           number,
    psize        number,
    porientation varchar2 DEFAULT 'left',
    pstyle       varchar2 DEFAULT '');

Parameters

ParameterTypeDefaultDescription
pxNUMBER—X of the top-left corner of the triangle's bounding box. Number in the unit set by Init (mm, cm, pt or in)
pyNUMBER—Y of the top-left corner of the triangle's bounding box. Number in the unit set by Init (mm, cm, pt or in)
psizeNUMBER—Height of the triangle; the base is twice that. Number in the unit set by Init (mm, cm, pt or in)
porientationVARCHAR2'left'Direction the tip points to. 'up', 'down', 'left' or 'right' — or the initials 'U', 'D', 'L', 'R'
pstyleVARCHAR2''Rendering style. '' or 'D' (outline), 'F' (filled), 'DF' (both)

Errors

CodeWhen
ORA-20821invalid orientation

Example

PL_FPDF.Triangle(20, 20, 5, 'right', 'F');

See also: Poly, Rect

Images

getImageFromUrl Function#

Downloads an image from a URL through UTL_HTTP for use in the document. The database needs a network ACL for this.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.getImageFromUrl(
    p_Url varchar2) RETURN RECIMAGEBLOB;

Parameters

ParameterTypeDefaultDescription
p_UrlVARCHAR2—Address of the image. http:// or https:// URL reachable from the database

Returns

recImageBlob — record with the image's content and metadata.

Note

Accepted formats: PNG, JPEG/JPG

Errors

CodeWhen
ORA-20301invalid image header
ORA-20302the image could not be fetched
ORA-20303unsupported format

Example

l_img := PL_FPDF.getImageFromUrl('https://example.com/logo.png');

See also: Image

image Procedure#

Places an image fetched by URL. The fetch goes over the network and needs an ACL granted to the schema -- when the image is already in a table or a variable, ImageFromBlob does the same with no network and no permission. Width and height of zero come from the image itself, at 72 dpi; with only one of them zero, it is derived from the other, keeping the aspect ratio.

Since version 0.9.4

Limitation: PNG with an alpha channel, interlaced PNG and 16-bit PNG are refused with -20100 on this path -- for those, re-save the image without alpha and without interlacing, or draw it over a finished PDF with OverlayImage, which accepts them.

Syntax

PROCEDURE PL_FPDF.image(
    pFile   varchar2,
    pX      number,
    pY      number,
    pWidth  number DEFAULT 0,
    pHeight number DEFAULT 0,
    pType   varchar2 DEFAULT null,
    pLink   varchar2 DEFAULT null);

Parameters

ParameterTypeDefaultDescription
pFileVARCHAR2—Image URL (http/https), fetched over the network: needs an ACL granted to the schema. Not a local file path
pXNUMBER—X of the top-left corner. Number in the unit set by Init (mm, cm, pt or in)
pYNUMBER—Y of the top-left corner. Number in the unit set by Init (mm, cm, pt or in)
pWidthNUMBER0Desired width. Number in the unit set by Init (mm, cm, pt or in); 0 (default) derives it from the height
pHeightNUMBER0Desired height. Number in the unit set by Init (mm, cm, pt or in); 0 (default) derives it from the width, keeping the aspect ratio
pTypeVARCHAR2nullImage format. 'PNG', 'JPG'/'JPEG', or NULL (default) to detect it automatically
pLinkVARCHAR2nullOptional link URL over the image
NULL = no link. Internal links are not supported: see AddLink

Errors

CodeWhen
ORA-20100failure fetching or parsing the image, with the original stack preserved

Example

PL_FPDF.Image('https://example.com/logo.png', 10, 10, 40);

See also: getImageFromUrl, OverlayImage

ImageFromBlob Procedure#

Places an image you already hold — from a table, a BFILE or a variable — without going through a URL. Image fetches over the network, which needs an ACL granted to the schema; when the bytes are already in the database, this entry point needs neither the network nor the permission. The format is recognised by the first bytes of the file, not by its extension: PNG and JPEG; anything else is refused.

Since version 3.4.0

Limitation: PNG with an alpha channel, interlaced PNG and 16-bit PNG are refused with -20100 on this path -- for those, re-save the image without alpha and without interlacing, or draw it over a finished PDF with OverlayImage, which accepts them.

Syntax

PROCEDURE PL_FPDF.ImageFromBlob(
    p_blob  blob,
    p_name  varchar2,
    pX      number,
    pY      number,
    pWidth  number DEFAULT 0,
    pHeight number DEFAULT 0,
    pLink   varchar2 DEFAULT null);

Parameters

ParameterTypeDefaultDescription
p_blobBLOB—Image bytes. PNG or JPEG
p_nameVARCHAR2—Key in the image cache. A BLOB has no filename, so you pick one: distinct names for distinct images, and the same name reuses the object already emitted instead of writing the same bytes again. Any non-null text
pXNUMBER—X of the top-left corner. Number in the unit set in Init (mm, cm, pt or in)
pYNUMBER—Y of the top-left corner. Number in the unit set in Init (mm, cm, pt or in)
pWidthNUMBER0Requested width. Number in the unit set in Init; 0 (default) derives it from the height
pHeightNUMBER0Requested height. Number in the unit set in Init; 0 (default) derives it from the width, keeping the aspect ratio
pLinkVARCHAR2nullMakes the image clickable. URL
NULL = no link. An AddLink identifier is refused with ORA-20601

Errors

CodeWhen
ORA-20301invalid header, empty BLOB or missing name
ORA-20303unsupported format

Example

SELECT logo INTO l_logo FROM empresa WHERE id = 1;
PL_FPDF.ImageFromBlob(l_logo, 'LOGO', 10, 10, 40);

See also: image, OverlayImage

Header and footer

SetAliasNbPages Procedure#

Sets the placeholder that will be replaced by the total page count when the document is finalised — so you can write 'Page 2 of 10' without knowing the total in advance.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetAliasNbPages(
    palias varchar2 DEFAULT '{nb}');

Parameters

ParameterTypeDefaultDescription
paliasVARCHAR2'{nb}'Placeholder to replace. Any text; '{nb}' is the default

Example

PL_FPDF.SetAliasNbPages;
PL_FPDF.Cell(0, 10, 'Page ' || PL_FPDF.PageNo || ' of {nb}');

See also: PageNo

SetFooterProc Procedure#

Registers a procedure of yours to run automatically in the footer of every page.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetFooterProc(
    footerprocname varchar2,
    paramTable     tv4000a DEFAULT noParam);

Parameters

ParameterTypeDefaultDescription
footerprocnameVARCHAR2—Qualified name of the procedure. 'package.procedure' or 'procedure'
paramTableTV4000AnoParamParameters passed on to the procedure, by name. PL_FPDF.tv4000a — an associative array INDEXED BY THE NAME of your procedure's parameter: l_p('p_title') := 'Report'. There is no tv4000a(...) constructor: declare a variable and fill it by key. noParam (default) = called with no parameters

Example

PL_FPDF.SetFooterProc('MY_PKG.FOOTER');

See also: SetHeaderProc, SetAliasNbPages, Footer

SetHeaderProc Procedure#

Registers a procedure of yours to run automatically at the top of every page.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetHeaderProc(
    headerprocname varchar2,
    paramTable     tv4000a DEFAULT noParam);

Parameters

ParameterTypeDefaultDescription
headerprocnameVARCHAR2—Qualified name of the procedure. 'package.procedure' or 'procedure'; it must be reachable by the database user
paramTableTV4000AnoParamParameters passed on to the procedure, by name. PL_FPDF.tv4000a — an associative array INDEXED BY THE NAME of your procedure's parameter: l_p('p_title') := 'Report'. There is no tv4000a(...) constructor: declare a variable and fill it by key. noParam (default) = called with no parameters

Example

PL_FPDF.SetHeaderProc('MY_PKG.HEADER');

See also: SetFooterProc, Header

QR codes and barcodes

AddBarcode Procedure#

Draws a linear barcode on the current page, with an optional human-readable caption.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.AddBarcode(
    p_x         number,
    p_y         number,
    p_width     number,
    p_height    number,
    p_code      varchar2,
    p_type      varchar2 DEFAULT 'CODE128',
    p_show_text boolean DEFAULT true);

Parameters

ParameterTypeDefaultDescription
p_xNUMBER—X of the top-left corner. Number in the unit set by Init (mm, cm, pt or in)
p_yNUMBER—Y of the top-left corner. Number in the unit set by Init (mm, cm, pt or in)
p_widthNUMBER—Total width of the code. Number in the unit set by Init (mm, cm, pt or in)
p_heightNUMBER—Height of the bars. Number in the unit set by Init (mm, cm, pt or in)
p_codeVARCHAR2—Data to encode. It must match the chosen symbology:
EAN13 = 13 digits
EAN8 = 8 digits
ITF = any even number of digits (a Brazilian bank slip uses 44)
ITF14 = 14 digits
CODE39 = uppercase alphanumeric
CODE128 = ASCII
p_typeVARCHAR2'CODE128'Barcode symbology. 'CODE128' (default), 'CODE39', 'EAN13', 'EAN8', 'ITF' or 'ITF14'
p_show_textBOOLEANtruePrints the readable value below the bars. TRUE or FALSE; TRUE is the default

Errors

CodeWhen
ORA-20880empty code
ORA-20882unsupported symbology
ORA-20881width or height is not positive
ORA-20883CODE39 does not accept the given character
ORA-20884CODE128 accepts only ASCII 32 to 126
ORA-20885EAN with the wrong number of digits
ORA-20886EAN with an invalid check digit
ORA-20887ITF14 requires 13 digits (check digit computed) or 14
ORA-20888ITF with no digit in the content

Example

PL_FPDF.AddBarcode(30, 50, 150, 20, 'ABC123456', 'CODE128', TRUE);

See also: AddQRCode

AddQRCode Procedure#

Draws a QR code on the current page, with a configurable content format and error-correction level.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.AddQRCode(
    p_x                number,
    p_y                number,
    p_size             number,
    p_data             varchar2,
    p_format           varchar2 DEFAULT 'TEXT',
    p_error_correction varchar2 DEFAULT 'M');

Parameters

ParameterTypeDefaultDescription
p_xNUMBER—X of the top-left corner. Number in the unit set by Init (mm, cm, pt or in)
p_yNUMBER—Y of the top-left corner. Number in the unit set by Init (mm, cm, pt or in)
p_sizeNUMBER—Side of the QR code (
width = height). Number in the unit set by Init (mm, cm, pt or in)
p_dataVARCHAR2—Content to encode. Up to 2953 bytes in binary mode; the content must follow the format chosen in p_format
p_formatVARCHAR2'TEXT'Content format, which tells readers how to interpret the code. 'TEXT' (default, free text), 'URL', 'PIX', 'VCARD', 'WIFI' or 'EMAIL'
p_error_correctionVARCHAR2'M'Error-correction level: the higher it is, the better the code survives dirt and creases, and the less data fits. 'L' (7%), 'M' (15%, default), 'Q' (25%) or 'H' (30%)

Errors

CodeWhen
ORA-20870empty content
ORA-20872invalid error-correction level
ORA-20871size is not positive
ORA-20873content beyond the QR Code capacity

Example

PL_FPDF.AddQRCode(50, 50, 40, 'https://example.com', 'URL', 'M');

See also: AddBarcode

Metadata and document setup

GetDocumentMetadata Function#

Returns the metadata currently set on the document.

Since version 2.0.0

Syntax

FUNCTION PL_FPDF.GetDocumentMetadata RETURN JSON_OBJECT_T;

Returns

JSON_OBJECT_T — object with title, subject, author, keywords, creator and the remaining options.

Note

JSON structure: { "pageCount": <number>, "title": "<string>", "author": "<string>", "subject": "<string>", "keywords": "<string>", "format": "<string>", "orientation": "<string>", "unit": "<string>", "initialized": <boolean> }

Example

DECLARE
  l_meta JSON_OBJECT_T;
BEGIN
  l_meta := PL_FPDF.GetDocumentMetadata();
  DBMS_OUTPUT.PUT_LINE('Pages: ' || l_meta.get_Number('pageCount'));
END;

See also: SetDocumentConfig

GetPageInfo Function#

Returns information about a page of the document being built.

Since version 2.0.0

Syntax

FUNCTION PL_FPDF.GetPageInfo(
    p_page_number pls_integer DEFAULT null) RETURN JSON_OBJECT_T;

Parameters

ParameterTypeDefaultDescription
p_page_numberPLS_INTEGERnullPage to query. Integer >= 1, up to GetPageCount; NULL (default) = the current page

Returns

JSON_OBJECT_T — width, height, orientation and rotation of the page.

Note

JSON structure: { "number": <number>, "format": "<string>", "orientation": "<string>", "width": <number>, "height": <number>, "unit": "<string>" }

Errors

CodeWhen
ORA-20106the page does not exist
ORA-20812page number out of range

Example

DECLARE
  l_page_info JSON_OBJECT_T;
BEGIN
  l_page_info := PL_FPDF.GetPageInfo(1);
  DBMS_OUTPUT.PUT_LINE('Width: ' || l_page_info.get_Number('width'));
END;

See also: GetCurrentPage, GetPDFInfo

SetAuthor Procedure#

Sets the document author in the metadata.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetAuthor(
    pauthor varchar2);

Parameters

ParameterTypeDefaultDescription
pauthorVARCHAR2—Author. Any VARCHAR2

Example

PL_FPDF.SetAuthor('Finance Department');

See also: SetDocumentConfig

SetCompression Procedure#

Turns compression of the page content stream on or off. When on, each page comes out with /Filter [/ASCIIHexDecode /FlateDecode] — a deflate written inside the package itself, in hexadecimal because the document is assembled as text. Hexadecimal doubles the compressed size, so compression is only applied when the stream still ends up smaller than the original; a page that does not benefit comes out unfiltered. Text usually drops below a fifth.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetCompression(
    p_compress boolean DEFAULT false);

Parameters

ParameterTypeDefaultDescription
p_compressBOOLEANfalseEnables compression. TRUE or FALSE; FALSE is the default

Example

PL_FPDF.SetCompression(TRUE);

See also: FlateEncode, FlateDecode

SetCreator Procedure#

Sets the creating application in the document metadata.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetCreator(
    pcreator varchar2);

Parameters

ParameterTypeDefaultDescription
pcreatorVARCHAR2—Name of the generating system. Any VARCHAR2

Example

PL_FPDF.SetCreator('ERP - billing module');

See also: SetDocumentConfig

SetDisplayMode Procedure#

Tells the PDF reader how to display the document when it opens.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetDisplayMode(
    zoom   varchar2,
    layout varchar2 DEFAULT 'continuous');

Parameters

ParameterTypeDefaultDescription
zoomVARCHAR2—Initial zoom level. 'fullpage' (whole page), 'fullwidth' (page width), 'real' (100%), 'default', or a number standing for the percentage
layoutVARCHAR2'continuous'Page layout. 'continuous' (default), 'single', 'two' or 'default'

Errors

CodeWhen
ORA-20100unknown zoom or layout mode

Example

PL_FPDF.SetDisplayMode('fullwidth', 'continuous');

SetDocumentConfig Procedure#

Sets several document metadata fields and options at once, from a JSON object.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.SetDocumentConfig(
    p_config JSON_OBJECT_T);

Parameters

ParameterTypeDefaultDescription
p_configJSON_OBJECT_T—Document configuration. JSON_OBJECT_T with the optional keys: title, subject, author, keywords, creator, compression (boolean)

Note

JSON keys: - title, author, subject, keywords, creator (document metadata) - orientation ('P' or 'L'), unit ('mm','cm','in','pt'), format (page format) - fontFamily, fontSize, fontStyle (default font) - leftMargin, topMargin, rightMargin (margins, in the current unit)

Errors

CodeWhen
ORA-20001invalid orientation; only P or L
ORA-20002invalid unit; only mm, cm, in or pt

Example

DECLARE
  l_config JSON_OBJECT_T := JSON_OBJECT_T();
BEGIN
  l_config.put('title', 'Monthly Report');
  l_config.put('author', 'Maxwell Oliveira');
  l_config.put('orientation', 'P');
  l_config.put('format', 'A4');
  PL_FPDF.SetDocumentConfig(l_config);
END;

See also: GetDocumentMetadata, SetTitle

SetKeywords Procedure#

Sets the document keywords, which help search and indexing.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetKeywords(
    pkeywords varchar2);

Parameters

ParameterTypeDefaultDescription
pkeywordsVARCHAR2—Keywords. Free text, usually comma separated

Example

PL_FPDF.SetKeywords('production report 2026');

See also: SetDocumentConfig

SetSubject Procedure#

Sets the document subject in the metadata.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetSubject(
    psubject varchar2);

Parameters

ParameterTypeDefaultDescription
psubjectVARCHAR2—Subject. Any VARCHAR2

Example

PL_FPDF.SetSubject('Monthly close');

See also: SetDocumentConfig

SetTitle Procedure#

Sets the document title, shown in the PDF reader's title bar.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.SetTitle(
    ptitle varchar2);

Parameters

ParameterTypeDefaultDescription
ptitleVARCHAR2—Title. Any VARCHAR2

Example

PL_FPDF.SetTitle('Production Report');

See also: SetDocumentConfig

Document output

ClosePDF Procedure#

Closes the document structure (advanced use; the output APIs already do it).

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.ClosePDF;

Example

PL_FPDF.ClosePDF;

See also: OutputBlob

OpenPDF Procedure#

Explicitly opens the document structure (advanced use; Init already does it).

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.OpenPDF;

Example

PL_FPDF.OpenPDF;

See also: Init

Output Procedure#

Closes the document and writes it to a file, in the PDF_DIR DIRECTORY. It is the legacy form: the browser delivery modes ('I', 'D', 'S') left together with OWA/HTP and now refuse with -20306, saying what to use instead. To get the bytes, use OutputBlob.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Output(
    pname varchar2 DEFAULT null,
    pdest varchar2 DEFAULT null);

Parameters

ParameterTypeDefaultDescription
pnameVARCHAR2nullFile or document name. Any VARCHAR2
pdestVARCHAR2nullDestination: 'F' (File) is the only one supported

Errors

CodeWhen
ORA-20100unknown destination, or a failure while writing
ORA-20306delivering straight to the browser is no longer supported; the message points to OutputBlob and the Content-Type header

Example

PL_FPDF.Output('report.pdf', 'F');

See also: OutputBlob, OutputFile

OutputBlob Function#

Synonym of OutputBlob: finalises the document and returns the PDF as a BLOB.

Since version 2.0.0

Syntax

FUNCTION PL_FPDF.OutputBlob RETURN BLOB;

Returns

BLOB — the PDF content.

Errors

CodeWhen
ORA-20005Init has not been called yet. Before August 2026 this call carried on and returned an empty PDF, without pointing to the cause.

Example

l_pdf := PL_FPDF.OutputBlob;
INSERT INTO documentos (id, arquivo) VALUES (1, l_pdf);

See also: OutputBlob

OutputFile Procedure#

Finalises the document and writes the PDF straight to a file on the database server.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.OutputFile(
    p_filename  varchar2,
    p_directory varchar2 DEFAULT 'PDF_DIR');

Parameters

ParameterTypeDefaultDescription
p_filenameVARCHAR2—Name of the output file. E.g. 'report.pdf'
p_directoryVARCHAR2'PDF_DIR'Oracle DIRECTORY with write permission. Default: 'PDF_DIR'

Errors

CodeWhen
ORA-20401invalid directory
ORA-20402no write permission
ORA-20403write failure

Example

PL_FPDF.OutputFile('report.pdf', 'PDF_DIR');

See also: OutputBlob

ReturnBlob Function#

Returns the PDF as a BLOB (legacy compatibility). Prefer OutputBlob.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.ReturnBlob(
    pname varchar2 DEFAULT null,
    pdest varchar2 DEFAULT null) RETURN BLOB;

Parameters

ParameterTypeDefaultDescription
pnameVARCHAR2nullLogical name of the document. Any VARCHAR2
NULL = no name
pdestVARCHAR2nullFPDF-style destination. 'S' (string/BLOB), 'D' (download), 'I' (inline), 'F' (file)

Returns

BLOB — the PDF content.

Errors

CodeWhen
ORA-20100failure closing or assembling the document, with the original stack preserved

Example

l_pdf := PL_FPDF.OutputBlob;    -- prefira esta

See also: OutputBlob

Manipulating an existing PDF

AddWatermark Procedure#

Registers a text watermark, drawn by OutputModifiedPDF() into the page content stream: every affected page gets a content object and a /Resources of its own, so a /Resources shared between pages is never contaminated. The mark is centred and rotated about the centre of the page, always in Helvetica.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.AddWatermark(
    p_text     VARCHAR2,
    p_opacity  NUMBER DEFAULT 0.3,
    p_rotation NUMBER DEFAULT 45,
    p_pages    VARCHAR2 DEFAULT 'ALL',
    p_font     VARCHAR2 DEFAULT 'Helvetica',
    p_size     NUMBER DEFAULT 48,
    p_color    VARCHAR2 DEFAULT 'gray');

Parameters

ParameterTypeDefaultDescription
p_textVARCHAR2—Watermark text. Any VARCHAR2, e.g. 'CONFIDENTIAL'
p_opacityNUMBER0.3Opacity of the mark. 0.0 (invisible) to 1.0 (opaque); 0.3 is the default
p_rotationNUMBER45Text angle in degrees. 0 to 360; 45 (diagonal) is the default
p_pagesVARCHAR2'ALL'Pages that receive the mark. 'ALL' (default), or a list/ranges such as '1', '1,3,5', '2-8', '1,3-5,10'
p_fontVARCHAR2'Helvetica'Font used. 'Helvetica' (default), 'Arial', 'Times' or 'Courier'
p_sizeNUMBER48Font size in points. Number > 0; 48 is the default
p_colorVARCHAR2'gray'Colour of the watermark. 'gray' (default), 'red', 'blue', 'green', 'black', or an RGB hex value such as 'FF0000'

Note

Drawn by OutputModifiedPDF() into the content stream: each affected page gets a content object of its own and a /Resources of its own, so a /Resources shared between pages is never contaminated. Centred and rotated around the centre of the page; the font is always Helvetica.

Errors

CodeWhen
ORA-20809no PDF loaded -- call LoadPDF first
ORA-20816watermark text is empty
ORA-20817opacity outside 0..1
ORA-20818rotation outside 0, 45, 90, 135, 180, 225, 270, 315

Example

PL_FPDF.LoadPDF(l_pdf);
-- every page
PL_FPDF.AddWatermark('CONFIDENTIAL', 0.2, 45, 'ALL');
-- specific pages
PL_FPDF.AddWatermark('DRAFT', 0.3, 45, '1-5,10');
-- Estilo personalizado
PL_FPDF.AddWatermark('APPROVED', 0.5, 0, '1', 'Helvetica', 72, 'green');

See also: GetWatermarks, OverlayText, OutputModifiedPDF

ClearPDFCache Procedure#

Discards the loaded PDFs and frees the memory used by manipulation.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.ClearPDFCache;

Note

Always call it after processing a PDF to release memory. It clears: the loaded PDF, page info, rotations, removed pages and watermarks.

Example

PL_FPDF.LoadPDF(l_pdf);
PL_FPDF.RotatePage(1, 90);   -- with no change, OutputModifiedPDF raises -20819
l_modified := PL_FPDF.OutputModifiedPDF();
-- release the memory
PL_FPDF.ClearPDFCache();

See also: LoadPDF, UnloadPDF

FlateDecode Function#

Decompresses a PDF /FlateDecode stream (zlib, RFC 1950). Implemented in pure PL/SQL, because UTL_COMPRESS will not do: it only accepts a gzip trailer with a correct CRC-32, and that CRC is of the DECOMPRESSED content — to know it you would have to decompress first. Useful in its own right, and it is what lets the copier read cross-reference streams and object streams.

Since version 3.3.0

Syntax

FUNCTION PL_FPDF.FlateDecode(
    p_stream    BLOB,
    p_max_bytes PLS_INTEGER DEFAULT 8388608) RETURN BLOB;

Parameters

ParameterTypeDefaultDescription
p_streamBLOB—Compressed stream. BLOB with zlib data — what the PDF marks as /FlateDecode
p_max_bytesPLS_INTEGER8388608Output ceiling, in bytes. Number > 0; 8388608 (8 MB) is the default. A compressed stream is UNTRUSTED input: a few KB can expand into gigabytes (a zip bomb) and bring the session down with ORA-04036. With the ceiling it raises -20893 and says where it stopped

Returns

BLOB — the decompressed content.

Errors

CodeWhen
ORA-20890truncated stream
ORA-20891malformed DEFLATE data
ORA-20892invalid zlib header
ORA-20893output exceeded p_max_bytes

Example

l_claro := PL_FPDF.FlateDecode(l_comprimido);

See also: LoadPDF

FlateEncode Function#

Compresses data into a PDF /FlateDecode stream (zlib, RFC 1950). Written in pure PL/SQL: a single block with FIXED Huffman and greedy LZ77 — it compresses less than zlib's dynamic Huffman, and far more than nothing. When the data is incompressible it falls back to a stored block, so the output never exceeds the input plus the block overhead.

Since version 3.3.0

Syntax

FUNCTION PL_FPDF.FlateEncode(
    p_data BLOB) RETURN BLOB;

Parameters

ParameterTypeDefaultDescription
p_dataBLOB—Content to compress. BLOB of any size; NULL is treated as empty

Returns

BLOB — zlib stream: header, DEFLATE and Adler-32.

Example

l_comprimido := PL_FPDF.FlateEncode(l_claro);

See also: FlateDecode, SetCompression

GetActivePageCount Function#

Returns how many pages will remain once the pending removals are applied.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.GetActivePageCount RETURN PLS_INTEGER;

Returns

PLS_INTEGER — pages not marked for removal.

Note

Differs from GetPageCount(), which returns the original count

Errors

CodeWhen
ORA-20809no PDF loaded -- call LoadPDF first

Example

l_total := PL_FPDF.GetPageCount();        -- Original: 10
PL_FPDF.RemovePage(2);
l_active := PL_FPDF.GetActivePageCount(); -- Ativas: 9

See also: RemovePage, GetPageCount

GetPageCount Function#

Returns the total page count of the loaded PDF, including the pages marked for removal.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.GetPageCount RETURN PLS_INTEGER;

Returns

PLS_INTEGER — number of pages.

Errors

CodeWhen
ORA-20809no PDF loaded -- call LoadPDF first

Example

l_pages := PL_FPDF.GetPageCount();
DBMS_OUTPUT.PUT_LINE('Total pages:' || l_pages);

See also: LoadPDF, GetActivePageCount

GetPDFInfo Function#

Returns information about the loaded PDF: version, metadata and page count.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.GetPDFInfo RETURN JSON_OBJECT_T;

Returns

JSON_OBJECT_T — PDF version, title, author, page count and the remaining metadata.

Errors

CodeWhen
ORA-20809no PDF loaded -- call LoadPDF first

Example

DECLARE
  l_info JSON_OBJECT_T;
BEGIN
  l_info := PL_FPDF.GetPDFInfo();
  DBMS_OUTPUT.PUT_LINE('Version:' || l_info.get_string('version'));
  DBMS_OUTPUT.PUT_LINE('Pages:' || l_info.get_number('pageCount'));
END;

See also: LoadPDF, GetPageInfo

GetWatermarks Function#

Lists every watermark applied to the loaded PDF.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.GetWatermarks RETURN JSON_ARRAY_T;

Returns

JSON_ARRAY_T — objects with id, text, opacity, rotation, pageRange, font, fontSize and color.

Errors

CodeWhen
ORA-20809no PDF loaded -- call LoadPDF first

Example

DECLARE
  l_watermarks JSON_ARRAY_T;
  l_watermark JSON_OBJECT_T;
BEGIN
  PL_FPDF.LoadPDF(l_pdf);
  PL_FPDF.AddWatermark('CONFIDENTIAL', 0.2, 45, 'ALL');
  l_watermarks := PL_FPDF.GetWatermarks();
  FOR i IN 0..l_watermarks.get_size() - 1 LOOP
    l_watermark := TREAT(l_watermarks.get(i) AS JSON_OBJECT_T);
    DBMS_OUTPUT.PUT_LINE('Watermark:' ||
                         l_watermark.get_string('text'));
  END LOOP;
END;

See also: AddWatermark

IsPageRemoved Function#

Tells whether a page is marked for removal.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.IsPageRemoved(
    p_page_number PLS_INTEGER) RETURN BOOLEAN;

Parameters

ParameterTypeDefaultDescription
p_page_numberPLS_INTEGER—Page to query. Integer >= 1, up to GetPageCount

Returns

BOOLEAN — TRUE if the page will be removed from the output.

Example

IF PL_FPDF.IsPageRemoved(2) THEN
  DBMS_OUTPUT.PUT_LINE('Page 2 removed');
END IF;

See also: RemovePage

IsPDFModified Function#

Tells whether there are pending changes — rotation, removal, watermark, overlay — on the loaded PDF.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.IsPDFModified RETURN BOOLEAN;

Returns

BOOLEAN — TRUE if there are changes not yet applied.

Note

Use it to decide whether OutputModifiedPDF() has to be called

Example

IF PL_FPDF.IsPDFModified() THEN
  l_modified_pdf := PL_FPDF.OutputModifiedPDF();
END IF;

See also: OutputModifiedPDF

LoadPDF Procedure#

Loads an existing PDF into session memory for reading and modification. An encrypted PDF is refused (-20867): decrypt it first with DecryptPDF. It is the starting point of the whole manipulation flow, which ends at OutputModifiedPDF.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.LoadPDF(
    p_pdf_blob BLOB);

Parameters

ParameterTypeDefaultDescription
p_pdf_blobBLOB—PDF document to load. Non-null BLOB with a valid %PDF header

Errors

CodeWhen
ORA-20800PDF is null, or too small to hold a header and a trailer
ORA-20801invalid PDF header
ORA-20802startxref not found
ORA-20803invalid xref table
ORA-20804Root object not found
ORA-20867Encrypted PDF: decrypt it with DecryptPDF first. LoadPDF reads the structure but does not decrypt the content, and the pages would come out blank

Example

DECLARE
  l_pdf BLOB;
BEGIN
  SELECT pdf_content INTO l_pdf FROM documents WHERE id = 123;
  PL_FPDF.LoadPDF(l_pdf);
  DBMS_OUTPUT.PUT_LINE('Pages:' || PL_FPDF.GetPageCount());
END;

See also: LoadPDFWithID, GetPageCount, OutputModifiedPDF, ClearPDFCache

OutputModifiedPDF Function#

Produces the PDF with the changes applied, copying the kept pages object by object: content, fonts, images and annotations arrive intact, with no re-rendering. It applies RemovePage and RotatePage, and draws watermarks and text and image overlays into the content stream: every affected page gets a content object and a /Resources of its own.

Since version 3.0.0

Limitation: Watermarks and both text and image overlays are all drawn. Cross-reference streams and object streams (PDF 1.5+) are read, including with the PNG predictor; a malformed one raises -20843/-20847/-20848.

Syntax

FUNCTION PL_FPDF.OutputModifiedPDF RETURN BLOB;

Returns

BLOB — the modified PDF.

Process

1. Checks that a PDF is loaded and modified 2. Indexes the source (xref chain + flattened page tree) 3. Selects the pages not marked by RemovePage, in the original order 4. Copies every object reachable from those pages, renumbering the indirect references; stream payloads are copied byte for byte 5. Emits a new Catalog, a new /Pages node, xref and trailer

Errors

CodeWhen
ORA-20809no PDF loaded -- call LoadPDF first
ORA-20819the PDF has not been modified (no changes to apply)
ORA-20820every page was removed (an empty PDF cannot be generated)
ORA-20841object dictionary too large to renumber
ORA-20843malformed cross-reference stream
ORA-20847malformed object stream
ORA-20848unsupported predictor in the cross-reference stream
ORA-20823invalid or unsupported image. PNG with alpha and interlaced PNG are supported; refused are interlaced below 8 bits per component, indexed AND interlaced, and images above 4 megapixels on the path that reprocesses pixels
ORA-20846the page /Resources cannot be overlaid (shared indirect sub-dictionary)

Example

DECLARE
  l_pdf BLOB;
  l_modified_pdf BLOB;
BEGIN
  -- Carregar PDF
  SELECT pdf_blob INTO l_pdf FROM docs WHERE id = 1;
  PL_FPDF.LoadPDF(l_pdf);
  -- apply the changes
  PL_FPDF.RotatePage(1, 90);
  PL_FPDF.RemovePage(3);
  -- Gerar PDF modificado
  l_modified_pdf := PL_FPDF.OutputModifiedPDF();
  -- Salvar PDF modificado
  UPDATE docs SET pdf_blob = l_modified_pdf WHERE id = 1;
  PL_FPDF.ClearPDFCache();
END;

See also: LoadPDF, ClearPDFCache

RemovePage Procedure#

Marks a page of the loaded PDF for removal. The deletion is logical: it is only applied by OutputModifiedPDF.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.RemovePage(
    p_page_number PLS_INTEGER);

Parameters

ParameterTypeDefaultDescription
p_page_numberPLS_INTEGER—Page to remove. Integer >= 1, up to GetPageCount

Note

The page is marked for removal. Use OutputModifiedPDF() to produce the modified PDF

Errors

CodeWhen
ORA-20809no PDF loaded -- call LoadPDF first
ORA-20812page number out of range
ORA-20814the page was already marked for removal
ORA-20810/Pages not found in the PDF catalog

Example

PL_FPDF.LoadPDF(l_pdf);
PL_FPDF.RemovePage(2);  -- remove page 2
PL_FPDF.RemovePage(5);  -- remove page 5

See also: IsPageRemoved, GetActivePageCount, OutputModifiedPDF

RotatePage Procedure#

Rotates a page of the loaded PDF.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.RotatePage(
    p_page_number PLS_INTEGER,
    p_rotation    NUMBER);

Parameters

ParameterTypeDefaultDescription
p_page_numberPLS_INTEGER—Page to rotate. Integer >= 1, up to GetPageCount
p_rotationNUMBER—Rotation angle applied. 0, 90, 180 or 270

Note

Changes are kept in memory. Use OutputModifiedPDF() to produce the PDF

Errors

CodeWhen
ORA-20809no PDF loaded -- call LoadPDF first
ORA-20813invalid rotation; only 0, 90, 180 or 270
ORA-20810/Pages not found in the PDF catalog

Example

PL_FPDF.LoadPDF(l_pdf);
PL_FPDF.RotatePage(1, 90);    -- rotate page 1
PL_FPDF.RotatePage(2, 180);   -- rotate page 2

See also: LoadPDF, RemovePage, OutputModifiedPDF

Overlays

ClearOverlays Procedure#

Removes every overlay, from one page or from the whole document.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.ClearOverlays(
    p_page_number PLS_INTEGER DEFAULT NULL);

Parameters

ParameterTypeDefaultDescription
p_page_numberPLS_INTEGERNULLPage to clear. Integer >= 1, up to GetPageCount; NULL (default) clears every page

Example

-- clear every overlay
PL_FPDF.ClearOverlays();
-- clear only those on page 1
PL_FPDF.ClearOverlays(1);

See also: RemoveOverlay, GetOverlays

GetOverlays Function#

Lists the overlays applied, optionally filtered by page.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.GetOverlays(
    p_page_number PLS_INTEGER DEFAULT NULL) RETURN JSON_ARRAY_T;

Parameters

ParameterTypeDefaultDescription
p_page_numberPLS_INTEGERNULLPage filter. Integer >= 1, up to GetPageCount; NULL (default) returns the overlays of every page

Returns

JSON_ARRAY_T — objects with overlayId, overlayType ('TEXT' or 'IMAGE'), pageNumber, x, y, content, opacity, rotation and zOrder.

Errors

CodeWhen
ORA-20809no PDF loaded

Example

DECLARE
  l_overlays JSON_ARRAY_T;
  l_overlay JSON_OBJECT_T;
BEGIN
  l_overlays := PL_FPDF.GetOverlays(1);  -- Page 1 overlays
  FOR i IN 0..l_overlays.get_size() - 1 LOOP
    l_overlay := TREAT(l_overlays.get(i) AS JSON_OBJECT_T);
    DBMS_OUTPUT.PUT_LINE('Type: ' || l_overlay.get_string('overlayType'));
  END LOOP;
END;

See also: OverlayText, RemoveOverlay

OverlayImage Procedure#

Places an image at an exact position on a page of the loaded PDF — logos, scanned signatures, seals. Drawn by OutputModifiedPDF() into the content stream. On the common path nothing is decompressed: JPEG goes in whole as /DCTDecode, and a PNG's IDAT blocks are already zlib, which is the PDF's /FlateDecode — they are concatenated and declared with /Predictor 15, which covers 1 to 16 bits per component. PNG with an alpha channel (colour types 4 and 6) and interlaced PNG (Adam7) are drawn too, by a path that reprocesses pixel by pixel — and so comes out uncompressed, since there is no deflate on that stretch. Refused with -20823, rather than drawn wrong: interlaced below 8 bits per component, indexed AND interlaced, and an image above the pixel ceiling of the reprocessing path.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.OverlayImage(
    p_page_number PLS_INTEGER,
    p_image_blob  BLOB,
    p_x           NUMBER,
    p_y           NUMBER,
    p_width       NUMBER DEFAULT NULL,
    p_height      NUMBER DEFAULT NULL,
    p_options     JSON_OBJECT_T DEFAULT NULL);

Parameters

ParameterTypeDefaultDescription
p_page_numberPLS_INTEGER—Page that receives the image. Integer >= 1, up to GetPageCount
p_image_blobBLOB—Image content. BLOB in JPEG or PNG format
p_xNUMBER—X position in PDF points. 0 to 612 on A4 portrait
p_yNUMBER—Y position in PDF points, from the bottom. 0 to 792 on A4 portrait
p_widthNUMBERNULLWidth in points. Number > 0; NULL (default) uses the original width
p_heightNUMBERNULLHeight in points. Number > 0; NULL (default) uses the original height, or keeps the aspect ratio
p_optionsJSON_OBJECT_TNULLImage settings. JSON_OBJECT_T with the optional keys: opacity (0.0-1.0), rotation (0-360), maintainAspect (true/false), scaleToFit (true/false), zOrder (integer)

Note

Options (JSON_OBJECT_T): { "opacity": 1.0, // Opacity 0.0 to 1.0 "rotation": 0, // Rotation angle "maintainAspect": true, // Keep the aspect ratio "scaleToFit": false, // Scale to fit "zOrder": 100 // Layer order }

Errors

CodeWhen
ORA-20809no PDF loaded
ORA-20810invalid page number
ORA-20821invalid position coordinates
ORA-20823invalid image format -- only JPEG or PNG
ORA-20824invalid image dimensions

Example

DECLARE
  l_logo BLOB;
  l_options JSON_OBJECT_T := JSON_OBJECT_T();
BEGIN
  SELECT logo_blob INTO l_logo FROM company_assets WHERE id = 1;
  PL_FPDF.LoadPDF(l_pdf);
  -- add a logo in the top right corner
  PL_FPDF.OverlayImage(1, l_logo, 450, 750, 100, 50, NULL);
  -- a watermark with transparency
  l_options.put('opacity', 0.3);
  l_options.put('rotation', 45);
  PL_FPDF.OverlayImage(1, l_logo, 200, 400, 300, NULL, l_options);
  l_modified := PL_FPDF.OutputModifiedPDF();
END;

See also: OverlayText, Image, GetOverlays

OverlayText Procedure#

Places text at an exact position on a page of the loaded PDF — stamps, protocol numbers, signatures. Coordinates are in PDF points, with Y growing upwards from the bottom. Drawn by OutputModifiedPDF() into the content stream. When width is given it defines the text BOX: lines wrap inside it and align is relative to [x, x+width]. Without width there is nothing to wrap, and align becomes relative to the point itself — 'center' centres the text on x, 'right' ends it at x.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.OverlayText(
    p_page_number PLS_INTEGER,
    p_text        VARCHAR2,
    p_x           NUMBER,
    p_y           NUMBER,
    p_options     JSON_OBJECT_T DEFAULT NULL);

Parameters

ParameterTypeDefaultDescription
p_page_numberPLS_INTEGER—Page that receives the text. Integer >= 1, up to GetPageCount
p_textVARCHAR2—Text to overlay. Any VARCHAR2
p_xNUMBER—X position in PDF points (1
pt = 1/72 in), from the left. 0 to 612 on A4 portrait
p_yNUMBER—Y position in PDF points, from the bottom of the page. 0 to 792 on A4 portrait
p_optionsJSON_OBJECT_TNULLVisual settings of the text. JSON_OBJECT_T with the optional keys: font ('Helvetica'/'Arial', 'Times' or 'Courier'; any other name falls back to Helvetica), fontSize (number, 12), color (RGB hex, '000000'), opacity (0.0-1.0), rotation (0-360), align ('left', 'center', 'right'), width (box width in points: sets the line breaking and the reference for align), bold (true/false), zOrder (integer; higher goes on top, being drawn last)

Note

Options (JSON_OBJECT_T): { "font": "Helvetica", // Font name "fontSize": 12, // Font size "color": "000000", // RGB colour in hex "opacity": 1.0, // Opacity 0.0 to 1.0 "rotation": 0, // Rotation angle (0-360) "align": "left", // left, center, right "width": null, // maximum width (wraps on its own) "bold": false, // Bold text "zOrder": 100 // layer order (higher goes on top) }

Errors

CodeWhen
ORA-20809no PDF loaded
ORA-20810invalid page number
ORA-20821invalid position coordinates, or opacity outside 0.0..1.0

Example

DECLARE
  l_options JSON_OBJECT_T := JSON_OBJECT_T();
BEGIN
  PL_FPDF.LoadPDF(l_pdf);
  -- a plain overlay
  PL_FPDF.OverlayText(1, 'APPROVED', 100, 700, NULL);
  -- formatted text
  l_options.put('font', 'Helvetica-Bold');
  l_options.put('fontSize', 24);
  l_options.put('color', 'FF0000');  -- Vermelho
  l_options.put('opacity', 0.8);
  l_options.put('rotation', 45);
  PL_FPDF.OverlayText(1, 'CONFIDENTIAL', 200, 400, l_options);
  l_modified := PL_FPDF.OutputModifiedPDF();
END;

See also: OverlayImage, GetOverlays, AddWatermark

RemoveOverlay Procedure#

Removes one specific overlay by its identifier.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.RemoveOverlay(
    p_overlay_id VARCHAR2);

Parameters

ParameterTypeDefaultDescription
p_overlay_idVARCHAR2—The ID that GetOverlays returns in overlayId ('OVL_TEXT_00001', 'OVL_IMG_00002'): it is generated, not chosen

Errors

CodeWhen
ORA-20825overlay not found

Example

l_id := TREAT(PL_FPDF.GetOverlays(1).get(0) AS JSON_OBJECT_T).get_string('overlayId');
PL_FPDF.RemoveOverlay(l_id);

See also: GetOverlays, ClearOverlays

Multi-PDF (merge, split, extract)

ExtractPages Function#

Creates a new PDF holding only the selected pages of a loaded document. The requested order is honoured and a page may repeat; only the objects reachable from the chosen pages are copied, so the result is smaller than the source.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.ExtractPages(
    p_pdf_id  VARCHAR2,
    p_pages   VARCHAR2,
    p_options JSON_OBJECT_T DEFAULT NULL) RETURN BLOB;

Parameters

ParameterTypeDefaultDescription
p_pdf_idVARCHAR2—Identifier of the source document. The same one used in LoadPDFWithID
p_pagesVARCHAR2—Pages to extract. Comma-separated list and ranges, e.g. '1', '1,5,9', '1,5-10,15', '5,1' (reversed order) or 'ALL'
p_optionsJSON_OBJECT_TNULLExtraction options. Optional JSON_OBJECT_T; keys reserved for future use

Returns

BLOB — PDF with the extracted pages.

Errors

CodeWhen
ORA-20831PDF id not found
ORA-20838invalid page specification
ORA-20839page number out of range
ORA-20841object dictionary too large to renumber
ORA-20843malformed cross-reference stream
ORA-20847malformed object stream
ORA-20848unsupported predictor in the cross-reference stream

Example

DECLARE
  l_extracted BLOB;
BEGIN
  PL_FPDF.LoadPDFWithID('manual', l_manual_pdf);
  -- extract pages 1, 5-10 and 15
  l_extracted := PL_FPDF.ExtractPages('manual', '1,5-10,15', NULL);
  INSERT INTO documents (id, pdf_content) VALUES (124, l_extracted);
END;

See also: SplitPDF, MergePDFs

GetLoadedPDFs Function#

Lists the documents currently loaded under an identifier.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.GetLoadedPDFs RETURN JSON_ARRAY_T;

Returns

JSON_ARRAY_T — objects with the id and the information of each loaded PDF.

Example

DECLARE
  l_pdfs JSON_ARRAY_T;
  l_pdf JSON_OBJECT_T;
BEGIN
  l_pdfs := PL_FPDF.GetLoadedPDFs();
  FOR i IN 0..l_pdfs.get_size() - 1 LOOP
    l_pdf := TREAT(l_pdfs.get(i) AS JSON_OBJECT_T);
    DBMS_OUTPUT.PUT_LINE('PDF: ' || l_pdf.get_string('pdfId'));
  END LOOP;
END;

See also: LoadPDFWithID, UnloadPDF

LoadPDFWithID Procedure#

Loads a PDF into memory under an identifier, so several documents can be held open at once to merge, split or extract pages.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.LoadPDFWithID(
    p_pdf_id   VARCHAR2,
    p_pdf_blob BLOB);

Parameters

ParameterTypeDefaultDescription
p_pdf_idVARCHAR2—Identifier of the document within the session. Unique text, e.g. 'cover', 'annex1'
p_pdf_blobBLOB—Document to load. BLOB with a valid PDF

Note

At most 10 PDFs can be loaded at the same time

Errors

CodeWhen
ORA-20828PDF id already loaded
ORA-20829maximum number of loaded PDFs exceeded (10)
ORA-20830identifier empty or too long
ORA-20800PDF is null or too small to be valid
ORA-20801%PDF-x.x header missing or malformed
ORA-20867Encrypted PDF: decrypt it with DecryptPDF first; the ID is not registered

Example

BEGIN
  PL_FPDF.LoadPDFWithID('report_jan', l_jan_pdf);
  PL_FPDF.LoadPDFWithID('report_feb', l_feb_pdf);
  PL_FPDF.LoadPDFWithID('report_mar', l_mar_pdf);
END;

See also: MergePDFs, SplitPDF, ExtractPages, UnloadPDF, GetLoadedPDFs

MergePDFs Function#

Merges several loaded PDFs into a single document, in the order given. The objects of each source — pages, fonts, images, annotations — are copied with their indirect references renumbered: nothing is re-rendered and the original content arrives intact. The same identifier may appear more than once.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.MergePDFs(
    p_pdf_ids JSON_ARRAY_T,
    p_options JSON_OBJECT_T DEFAULT NULL) RETURN BLOB;

Parameters

ParameterTypeDefaultDescription
p_pdf_idsJSON_ARRAY_T—Identifiers of the documents, in the desired order. JSON_ARRAY_T of strings, e.g. JSON_ARRAY_T('["cover","body","annex"]')
p_optionsJSON_OBJECT_TNULLMerge options. Optional JSON_OBJECT_T; keys reserved for future use

Returns

BLOB — the merged PDF.

Errors

CodeWhen
ORA-20832no PDF id was given
ORA-20833a PDF id in the list is not loaded
ORA-20834merge failed
ORA-20841object dictionary too large to renumber
ORA-20843malformed cross-reference stream
ORA-20847malformed object stream
ORA-20848unsupported predictor in the cross-reference stream

Example

DECLARE
  l_merged BLOB;
BEGIN
  PL_FPDF.LoadPDFWithID('jan', l_jan_pdf);
  PL_FPDF.LoadPDFWithID('feb', l_feb_pdf);
  PL_FPDF.LoadPDFWithID('mar', l_mar_pdf);
  l_merged := PL_FPDF.MergePDFs(
    JSON_ARRAY_T('["jan","feb","mar"]'),
    NULL
  );
  INSERT INTO reports VALUES ('Q1_2026', l_merged);
END;

See also: LoadPDFWithID, SplitPDF, ExtractPages

SplitPDF Function#

Splits a loaded PDF into several documents, following the ranges given. Each part carries only the objects reachable from its own pages, which is why it ends up far smaller than the source. The ranges may not overlap.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.SplitPDF(
    p_pdf_id      VARCHAR2,
    p_page_ranges JSON_ARRAY_T) RETURN JSON_ARRAY_T;

Parameters

ParameterTypeDefaultDescription
p_pdf_idVARCHAR2—Identifier of the document to split. The same one used in LoadPDFWithID
p_page_rangesJSON_ARRAY_T—Ranges defining each part produced. JSON_ARRAY_T of strings: '1-10', '11-20', '5' (a single page), '1,3,5' (a list) or 'ALL'

Returns

JSON_ARRAY_T — one entry per range, with the part's PDF in base64, without line breaks.

Errors

CodeWhen
ORA-20831PDF id not found
ORA-20835no range was given
ORA-20836overlapping ranges
ORA-20838invalid page specification
ORA-20839page number out of range
ORA-20843malformed cross-reference stream
ORA-20847malformed object stream
ORA-20848unsupported predictor in the cross-reference stream

Example

DECLARE
  l_split_pdfs JSON_ARRAY_T;
  l_part CLOB;
BEGIN
  PL_FPDF.LoadPDFWithID('contract', l_contract_pdf);
  l_split_pdfs := PL_FPDF.SplitPDF('contract',
    JSON_ARRAY_T('["1-5", "6-10", "11-15"]')
  );
  FOR i IN 0..l_split_pdfs.get_size() - 1 LOOP
    l_part := l_split_pdfs.get_string(i);
    -- process each part
  END LOOP;
END;

See also: ExtractPages, MergePDFs

UnloadPDF Procedure#

Drops from memory a document loaded by LoadPDFWithID.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.UnloadPDF(
    p_pdf_id VARCHAR2);

Parameters

ParameterTypeDefaultDescription
p_pdf_idVARCHAR2—Document identifier. The same one used in LoadPDFWithID

Errors

CodeWhen
ORA-20831PDF id not found

Example

PL_FPDF.UnloadPDF('report_jan');

See also: LoadPDFWithID, ClearPDFCache

Security and encryption

DecryptPDF Function#

Removes the protection from an encrypted PDF, given the right password. It supports RC4-40, RC4-128, AES-128 (AESV2) and AES-256 (AESV3), with either the user or the owner password. The filter is read from the document's /CFM, not assumed. A PDF 1.5+ source is flattened, and object streams are decrypted before being decompressed.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.DecryptPDF(
    p_pdf      BLOB,
    p_password VARCHAR2) RETURN BLOB;

Parameters

ParameterTypeDefaultDescription
p_pdfBLOB—Encrypted document. BLOB with a protected PDF
p_passwordVARCHAR2—User or owner password. Text matching one of the document's passwords

Returns

BLOB — the PDF without encryption.

Note

A PDF 1.5+ source is flattened, and the object streams are decrypted before being decompressed.

Errors

CodeWhen
ORA-20853the PDF is not encrypted
ORA-20854invalid password
ORA-20855decryption failed
ORA-20861/Encrypt dictionary not found in the PDF
ORA-20857invalid PDF version

Example

l_decrypted := PL_FPDF.DecryptPDF(l_encrypted_pdf, 'password123');

See also: EncryptPDF, IsEncrypted

EncryptPDF Function#

Encrypts an existing PDF, applying passwords and permissions. This is the recommended way to protect documents you generate or receive. A PDF 1.5+ source (cross-reference streams, object streams) is flattened: the objects inside object streams become top-level objects, and the output carries a classic cross-reference table.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.EncryptPDF(
    p_pdf            BLOB,
    p_user_password  VARCHAR2,
    p_owner_password VARCHAR2 DEFAULT NULL,
    p_permissions    JSON_OBJECT_T DEFAULT NULL,
    p_encryption     VARCHAR2 DEFAULT 'RC4-128') RETURN BLOB;

Parameters

ParameterTypeDefaultDescription
p_pdfBLOB—Document to protect. BLOB with a valid, unencrypted PDF
p_user_passwordVARCHAR2—Password asked for when opening the document. Text; empty allows opening without a password while keeping the restrictions
p_owner_passwordVARCHAR2NULLOwner password, which allows changing permissions. Text; NULL (default) reuses the user password
p_permissionsJSON_OBJECT_TNULLPermissions granted to the reader. JSON_OBJECT_T with the boolean keys: print, modify, copy, annotate, fill_forms, extract, assemble, print_high. Missing keys take the restrictive default
p_encryptionVARCHAR2'RC4-128'Encryption algorithm. 'AES-256' and 'AES-128' (recommended), 'RC4-128' (the default, legacy: pass 'AES-256') or 'RC4-40' (legacy). RC4 has been broken for years and PDF 2.0 dropped it from the specification; recent readers warn about it or refuse it

Returns

BLOB — the encrypted PDF.

Note

A PDF 1.5+ source (cross-reference streams, object streams) is flattened: the objects inside the object streams become top-level objects and the output carries a classic xref.

Errors

CodeWhen
ORA-20850invalid encryption method
ORA-20851a password is required
ORA-20852encryption failed
ORA-20859the PDF is already encrypted; decrypt it first
ORA-20860invalid PDF: /Root not found in the trailer
ORA-20863empty RC4 key
ORA-20864content above the limit this RC4 implementation handles

Example

l_encrypted := PL_FPDF.EncryptPDF(
  p_pdf => l_pdf,
  p_user_password => 'user123',
  p_owner_password => 'owner456',
  p_permissions => JSON_OBJECT_T('{"print":true,"copy":false}'),
  p_encryption => 'AES-128'
);

See also: DecryptPDF, IsEncrypted, SetEncryption, SetPermissions

GetPDFVersion Function#

Returns the PDF version configured for the output.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.GetPDFVersion RETURN VARCHAR2;

Returns

VARCHAR2 — the version, e.g. '1.7'.

Example

DBMS_OUTPUT.PUT_LINE(PL_FPDF.GetPDFVersion);

See also: SetPDFVersion

GetSecurityInfo Function#

Returns the security details of an encrypted PDF.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.GetSecurityInfo(
    p_pdf BLOB) RETURN JSON_OBJECT_T;

Parameters

ParameterTypeDefaultDescription
p_pdfBLOB—Document to inspect. BLOB with a valid PDF

Returns

JSON_OBJECT_T — algorithm, key length and the permissions granted.

Example

l_info := PL_FPDF.GetSecurityInfo(l_pdf);
IF l_info.get_boolean('encrypted') THEN
  DBMS_OUTPUT.PUT_LINE(l_info.to_string);
END IF;

See also: IsEncrypted, EncryptPDF

IsEncrypted Function#

Checks whether a PDF is encrypted.

Since version 3.0.0

Syntax

FUNCTION PL_FPDF.IsEncrypted(
    p_pdf BLOB) RETURN BOOLEAN;

Parameters

ParameterTypeDefaultDescription
p_pdfBLOB—Document to check. BLOB with a valid PDF

Returns

BOOLEAN — TRUE if the document carries encryption.

Example

IF PL_FPDF.IsEncrypted(l_pdf) THEN
  l_pdf := PL_FPDF.DecryptPDF(l_pdf, 'senha');
END IF;

See also: GetSecurityInfo, DecryptPDF

SetEncryption Procedure#

Sets the encryption of a document being built; it is applied when the PDF is finalised by OutputBlob. Prefer 'AES-256': RC4 stays only for compatibility with old readers.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.SetEncryption(
    p_encryption     VARCHAR2,
    p_user_password  VARCHAR2,
    p_owner_password VARCHAR2 DEFAULT NULL);

Parameters

ParameterTypeDefaultDescription
p_encryptionVARCHAR2—Encryption algorithm: 'RC4-40', 'RC4-128', 'AES-128' or 'AES-256' (recommended)
p_user_passwordVARCHAR2—Opening password. Text
p_owner_passwordVARCHAR2NULLOwner password. Text; NULL (default) = same as the user password

Note

Version mapping: RC4-40/RC4-128 -> PDF 1.4 AES-128 -> PDF 1.5 AES-256 -> PDF 1.7

Errors

CodeWhen
ORA-20850unsupported encryption method
ORA-20851invalid password

Example

PL_FPDF.Init;
PL_FPDF.SetEncryption('AES-128', 'user123', 'owner456');
PL_FPDF.AddPage;
l_pdf := PL_FPDF.OutputBlob;

See also: SetPermissions, EncryptPDF

SetPDFVersion Procedure#

Sets the version declared in the header of the generated PDF.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.SetPDFVersion(
    p_version VARCHAR2);

Parameters

ParameterTypeDefaultDescription
p_versionVARCHAR2—PDF file version. '1.4', '1.5', '1.6' or '1.7'

Note

Features by version: 1.4: 128-bit RC4 encryption, transparency 1.5: 128-bit AES, object streams, cross-reference streams 1.6: 128-bit AES, OpenType fonts 1.7: 256-bit AES, XFA forms 2.0: 256-bit AES only, no RC4

Errors

CodeWhen
ORA-20857invalid PDF version; only 1.4, 1.5, 1.6, 1.7 or 2.0
ORA-20858AES-128 requires PDF 1.5 or higher, and AES-256 requires 1.7

Example

PL_FPDF.SetPDFVersion('1.5');

See also: GetPDFVersion

SetPermissions Procedure#

Sets the permissions of the document being built, applied together with the encryption defined in SetEncryption.

Since version 3.0.0

Syntax

PROCEDURE PL_FPDF.SetPermissions(
    p_print      BOOLEAN DEFAULT TRUE,
    p_modify     BOOLEAN DEFAULT FALSE,
    p_copy       BOOLEAN DEFAULT FALSE,
    p_annotate   BOOLEAN DEFAULT TRUE,
    p_fill_forms BOOLEAN DEFAULT TRUE,
    p_extract    BOOLEAN DEFAULT FALSE,
    p_assemble   BOOLEAN DEFAULT FALSE,
    p_print_high BOOLEAN DEFAULT TRUE);

Parameters

ParameterTypeDefaultDescription
p_printBOOLEANTRUEAllows printing. TRUE or FALSE; TRUE is the default
p_modifyBOOLEANFALSEAllows changing the content. TRUE or FALSE; FALSE is the default
p_copyBOOLEANFALSEAllows copying text and images. TRUE or FALSE; FALSE is the default
p_annotateBOOLEANTRUEAllows adding comments and annotations. TRUE or FALSE; TRUE is the default
p_fill_formsBOOLEANTRUEAllows filling in form fields. TRUE or FALSE; TRUE is the default
p_extractBOOLEANFALSEAllows extracting content for accessibility. TRUE or FALSE; FALSE is the default
p_assembleBOOLEANFALSEAllows inserting, removing and rotating pages. TRUE or FALSE; FALSE is the default
p_print_highBOOLEANTRUEAllows high-resolution printing. TRUE or FALSE; TRUE is the default

Errors

CodeWhen
ORA-20856SetEncryption must be called first

Example

PL_FPDF.SetEncryption('AES-128', 'user', 'owner');
PL_FPDF.SetPermissions(p_print => TRUE, p_copy => FALSE, p_modify => FALSE);

See also: SetEncryption, EncryptPDF

Diagnostics and utilities

DebugDisabled Procedure#

Turns the debug messages off.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.DebugDisabled;

Example

PL_FPDF.DebugDisabled;

See also: SetLogLevel

DebugEnabled Procedure#

Turns the package's debug messages on.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.DebugEnabled;

Example

PL_FPDF.DebugEnabled;

See also: SetLogLevel

Error Procedure#

Raises ORA-20100 with the given message, adding the trace of its origin and keeping the original stack (keeperrorstack) -- that is what keeps the real error behind the -20100 traceable. It is the library's internal error path; it is public by inheritance.

Since version 0.9.4

Syntax

PROCEDURE PL_FPDF.Error(
    pmsg varchar2);

Parameters

ParameterTypeDefaultDescription
pmsgVARCHAR2—Error message. Any VARCHAR2

Errors

CodeWhen
ORA-20100always; that is what this routine does

Example

PL_FPDF.Error('could not assemble the document');

GetLogLevel Function#

Returns the configured log level.

Since version 2.0.0

Syntax

FUNCTION PL_FPDF.GetLogLevel RETURN PLS_INTEGER;

Returns

PLS_INTEGER — the current level (0 to 4).

Example

l_nivel := PL_FPDF.GetLogLevel;

See also: SetLogLevel

GetScaleFactor Function#

Returns the conversion factor between the document's unit and PDF points.

Since version 0.9.4

Syntax

FUNCTION PL_FPDF.GetScaleFactor RETURN NUMBER;

Returns

NUMBER — the scale factor, e.g. 2.8346 for millimetres.

Example

l_pontos := 10 * PL_FPDF.GetScaleFactor;

See also: Init

SetLogLevel Procedure#

Sets how detailed the package's log messages are.

Since version 2.0.0

Syntax

PROCEDURE PL_FPDF.SetLogLevel(
    p_level pls_integer);

Parameters

ParameterTypeDefaultDescription
p_levelPLS_INTEGER—Log level. 0 (off), 1 (error), 2 (warning), 3 (info) or 4 (debug)

Errors

CodeWhen
ORA-20100level outside the 0..4 range

Example

PL_FPDF.SetLogLevel(3);

See also: GetLogLevel, DebugEnabled