PDF
Create, load and change PDF documents: generate a PDF from HTML, add pages, text, tables, shapes, images, links, bookmarks and watermarks, fill forms, merge, split, extract text, convert pages to images and protect files. Typical uses: produce invoices or reports, fill a PDF form, split a scanned batch.
pdf from htmlpdf compress_imagepdf createpdf loadpdf loadpdf load_base64pdf savepdf to_base64pdf existpdf showpdf closepdf close_allpdf info getpdf info setpdf page addpdf page countpdf page deletepdf page sizepdf page rotatepdf page importpdf font loadpdf font showpdf text addpdf text paragraphpdf text widthpdf draw linepdf draw rectpdf draw circlepdf draw polygonpdf image addpdf table addpdf link addpdf bookmark addpdf page_number addpdf watermark addpdf form fieldspdf form fillpdf form flattenpdf mergepdf splitpdf splitpdf extract_pagespdf extract_textpdf extract_textpdf page_count_filepdf to_imagepdf protectpdf protectpdf unprotectpdf comparepdf comparepdf redactpdf redact

pdf from html <html> <filePath>


Description

    Generate a PDF from an HTML document.

Parameters

    html:   The HTML - string - required
    filePath:   The destination file path - string - required
admin
pdf from html (sql to html "session1" "products" (concat "select * from products")) "/Users/jimmitry/Desktop/test.pdf";
mentdb
1
Used in use cases (6 recipes)

    SQL developer in MQL › CSV, XML and HTML for three partners
    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
    Integrator & ETL developer › Mail a PDF report built from live data
    PDF & document automation specialist › Watermark and password-protect a contract
    PDF & document automation specialist › Stamp a PDF received in base64 from an API
    PDF & document automation specialist › Archive compliance: check and fix the PDF metadata
Often used with

    pdf close  ·  pdf load  ·  pdf extract_text  ·  pdf save  ·  string regexp_extract  ·  cm get  ·  date sysdate  ·  json doc

pdf compress_image <pdf_path_source> <pdf_path_destination> <dpi>


Description

    Compress the images of a PDF. Warning: everything is converted into images, so this is intended for PDFs that are originally made of images.

Parameters

    pdf_path_source:   The PDF source - string - required
    pdf_path_destination:   The PDF destination - string - required
    dpi:   The DPI per image (150 by default) - number - required
admin
pdf compress_image "path/source/pdf.pdf" "path/destination/pdf.pdf" 150;
mentdb
1
Used in use cases (2 recipes)

    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Shrink a scanned dossier before archiving
Often used with

    pdf close  ·  pdf create  ·  pdf image add  ·  pdf page add  ·  pdf save  ·  pdf text add  ·  file exist  ·  file size

pdf create <pdfId>


Description

    Create a new empty PDF document in memory (add pages with 'pdf page add').
Conventions: units are points (1 pt = 1/72 inch, A4 = 595 x 842), the origin is the TOP-LEFT corner, page numbers start at 1.
Styles are JSON ({"size":12}) or 'key=value;key=value' (size=12;color=#333333).

Parameters

    pdfId:   The PDF document id - string - required
admin
pdf create "pdfId";
mentdb
1
Full example: an invoice with a logo, a SQL table and page numbers
admin
pdf close_all; pdf create "inv"; pdf info set "inv" "title=Invoice F-2026-001;author=MentDB"; pdf page add "inv" "A4" "portrait"; #Header band, logo and title; pdf draw rect "inv" 1 0 0 595 100 "fill=#1E5AA0"; pdf image add "inv" 1 "/Users/jimmitry/Desktop/logo.png" 40 20 0 60; pdf link add "inv" 1 40 20 160 60 "https://www.mentdb.org"; pdf text add "inv" 1 555 30 "INVOICE" "font=HELVETICA_BOLD;size=26;color=#FFFFFF;align=right"; pdf text add "inv" 1 555 65 "N° F-2026-001" "size=11;color=#FFFFFF;align=right"; #Customer block; pdf draw rect "inv" 1 40 120 250 75 "fill=#F2F5FA;stroke=#1E5AA0;radius=8"; pdf text paragraph "inv" 1 52 130 226 (concat "Customer SARL" [_n_] "12 rue de Paris" [_n_] "97400 Saint-Denis") "size=10"; #SQL connection on the MentDB database (no table needed: the values are in the query); sql connect "session1" {cm get "MENTDB";}; #Table from SQL (page breaks + repeated header are automatic); json load "pos" (pdf table add "inv" 1 40 215 (sql to json "session1" "products" (concat "select 'Car' as name, 5 as quantity, '7.50' as price" " union all select 'Bike', 2, '9.80'" " union all select 'Scooter', 1, '1250.00'" " union all select 'Helmet', 3, '45.90'" " union all select 'Gloves (pair)', 4, '19.99'" " union all select 'Lock with a very long description that wraps automatically in the cell', 2, '32.00'" )) "{\"columns\":[{\"title\":\"Product\",\"key\":\"name\"},{\"title\":\"Qty\",\"key\":\"quantity\",\"align\":\"right\",\"width\":60},{\"title\":\"Price\",\"key\":\"price\",\"align\":\"right\",\"width\":80}],\"width\":515,\"header_bg\":\"#1E5AA0\",\"zebra\":\"#F2F5FA\"}"); #Continue just after the table (maybe on another page); pdf text paragraph "inv" (json select "pos" /page) 40 (+ (json select "pos" /y) 20) 515 "Payment within 30 days. Thank you for your trust." "align=justify;size=10"; pdf page_number add "inv" "Page {page} / {total}" 555 815 "align=right"; pdf save "inv" "/Users/jimmitry/Desktop/invoice.pdf"; pdf close "inv"; sql disconnect "session1";
mentdb
1
Used in use cases (7 recipes)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    Security engineer › Sign a PDF and check it: not modified is not the same as trusted
    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
    PDF & document automation specialist › Shrink a scanned dossier before archiving
    PDF & document automation specialist › Monthly statements: one file, then one PDF per customer
    and 1 more in the Use cases
Often used with

    pdf close  ·  pdf page add  ·  pdf save  ·  pdf text add  ·  pdf extract_text  ·  pdf page_count_file  ·  file exist  ·  file mkdir

pdf load <pdfId> <path>


Description

    Load a PDF file into memory (the file can then be overwritten by 'pdf save').

Parameters

    pdfId:   The PDF document id - string - required
    path:   The PDF file path - string - required
admin
pdf load "pdfId" "/Users/jimmitry/Desktop/test.pdf";
mentdb
1

pdf load <pdfId> <path> <password>


Description

    Load a password-protected PDF file into memory.

Parameters

    pdfId:   The PDF document id - string - required
    path:   The PDF file path - string - required
    password:   The password - string - required
admin
pdf load "pdfId" "/Users/jimmitry/Desktop/secure.pdf" "password";
mentdb
1
Used in use cases (6 recipes)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
    PDF & document automation specialist › Watermark and password-protect a contract
    PDF & document automation specialist › Fill and flatten a PDF form
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
    PDF & document automation specialist › Stamp a PDF received in base64 from an API
    PDF & document automation specialist › Archive compliance: check and fix the PDF metadata
Often used with

    pdf close  ·  pdf save  ·  pdf extract_text  ·  pdf from html  ·  pdf info get  ·  string regexp_extract  ·  string replace  ·  json iobject

pdf load_base64 <pdfId> <base64>


Description

    Load a PDF from a base64 string (data:application/pdf;base64,... accepted).

Parameters

    pdfId:   The PDF document id - string - required
    base64:   The PDF in base64 - string - required
admin
pdf load_base64 "pdfId" [b64];
mentdb
1
Used in use cases (2 recipes)

    PDF & document automation specialist › Fill and flatten a PDF form
    PDF & document automation specialist › Stamp a PDF received in base64 from an API
Often used with

    pdf extract_text  ·  pdf load  ·  pdf to_base64  ·  string replace  ·  date sysdate  ·  file b64_write  ·  file create  ·  json iobject

pdf save <pdfId> <path>


Description

    Save a PDF document to a file (the directories are created if needed).

Parameters

    pdfId:   The PDF document id - string - required
    path:   The destination path - string - required
admin
pdf save "pdfId" "/Users/jimmitry/Desktop/test.pdf";
mentdb
1
Used in use cases (11 recipes)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    Security engineer › Sign a PDF and check it: not modified is not the same as trusted
    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
    PDF & document automation specialist › Watermark and password-protect a contract
    PDF & document automation specialist › Fill and flatten a PDF form
    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    and 5 more in the Use cases
Often used with

    pdf close  ·  pdf create  ·  pdf extract_text  ·  pdf page add  ·  pdf text add  ·  pdf load  ·  pdf page_count_file  ·  string trim

pdf to_base64 <pdfId>


Description

    Get a PDF document as a base64 string (for mail, REST ...).

Parameters

    pdfId:   The PDF document id - string - required
admin
pdf to_base64 "pdfId"
mentdb
JVBERi0xLjQK...
Used in use cases (2 recipes)

    PDF & document automation specialist › Fill and flatten a PDF form
    PDF & document automation specialist › Stamp a PDF received in base64 from an API
Often used with

    pdf extract_text  ·  pdf load  ·  pdf load_base64  ·  string replace  ·  date sysdate  ·  file b64_write  ·  file create  ·  json iobject

pdf exist <pdfId>


Description

    Check if a PDF document id is loaded.

Parameters

    pdfId:   The PDF document id - string - required
admin
pdf exist "pdfId"
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Watermark and password-protect a contract
Often used with

    pdf close  ·  pdf extract_text  ·  pdf from html  ·  pdf info get  ·  pdf load  ·  pdf page_count_file  ·  pdf protect  ·  pdf save

pdf show


Description

    Show all loaded PDF documents.

admin
pdf show
mentdb
["pdfId"]
Used in use cases (1 recipe)

    PDF & document automation specialist › Watermark and password-protect a contract
Often used with

    pdf close  ·  pdf exist  ·  pdf extract_text  ·  pdf from html  ·  pdf info get  ·  pdf load  ·  pdf page_count_file  ·  pdf protect

pdf close <pdfId>


Description

    Close a PDF document.

Parameters

    pdfId:   The PDF document id - string - required
admin
pdf close "pdfId";
mentdb
1
Used in use cases (11 recipes)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    Security engineer › Sign a PDF and check it: not modified is not the same as trusted
    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
    PDF & document automation specialist › Watermark and password-protect a contract
    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
    and 5 more in the Use cases
Often used with

    pdf save  ·  pdf text add  ·  pdf create  ·  pdf extract_text  ·  pdf page add  ·  pdf load  ·  pdf page_count_file  ·  pdf draw rect

pdf close_all


Description

    Close all PDF documents.

admin
pdf close_all;
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Fill and flatten a PDF form
Often used with

    file create  ·  pdf extract_text  ·  pdf form fields  ·  pdf form fill  ·  pdf form flatten  ·  pdf load  ·  pdf load_base64  ·  pdf save

pdf info get <pdfId>


Description

    Get the information of a PDF document.

Parameters

    pdfId:   The PDF document id - string - required
admin
pdf info get "pdfId"
mentdb
{ "title": "Invoice", "author": "MentDB", "pages": 3, "encrypted": false, "has_form": false, "version": "1.4" }
Used in use cases (3 recipes)

    PDF & document automation specialist › Watermark and password-protect a contract
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
    PDF & document automation specialist › Archive compliance: check and fix the PDF metadata
Often used with

    pdf close  ·  pdf load  ·  pdf save  ·  pdf from html  ·  pdf info set  ·  string regexp_extract  ·  file dir_list_regex  ·  is null or empty

pdf info set <pdfId> <info>


Description

    Set the information of a PDF document (title, author, subject, keywords, creator, producer).

Parameters

    pdfId:   The PDF document id - string - required
    info:   JSON or 'key=value;...' - string - required
admin
pdf info set "pdfId" "title=Invoice F-001;author=MentDB;subject=Invoice";
mentdb
1
Used in use cases (3 recipes)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
    PDF & document automation specialist › Archive compliance: check and fix the PDF metadata
Often used with

    pdf close  ·  pdf save  ·  pdf create  ·  pdf draw line  ·  pdf draw rect  ·  pdf info get  ·  pdf load  ·  pdf page add

pdf page add <pdfId> <format> <orientation>


Description

    Add a page at the end of the document, return the new page number.

Parameters

    pdfId:   The PDF document id - string - required
    format:   A0-A6, LETTER, LEGAL or 'widthxheight' in points (ex: 595x842) - string - required
    orientation:   portrait|landscape - string - required
admin
pdf page add "pdfId" "A4" "portrait"
mentdb
1
A custom size (10 x 15 cm)
admin
pdf page add "pdfId" "283x425" "portrait"
mentdb
2
Used in use cases (7 recipes)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    Security engineer › Sign a PDF and check it: not modified is not the same as trusted
    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
    PDF & document automation specialist › Shrink a scanned dossier before archiving
    PDF & document automation specialist › Monthly statements: one file, then one PDF per customer
    and 1 more in the Use cases
Often used with

    pdf close  ·  pdf create  ·  pdf save  ·  pdf text add  ·  pdf extract_text  ·  pdf page_count_file  ·  file exist  ·  file mkdir

pdf page count <pdfId>


Description

    Get the number of pages of a loaded document.

Parameters

    pdfId:   The PDF document id - string - required
admin
pdf page count "pdfId"
mentdb
3
Used in use cases (1 recipe)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
Often used with

    pdf bookmark add  ·  pdf close  ·  pdf extract_pages  ·  pdf extract_text  ·  pdf from html  ·  pdf load  ·  pdf merge  ·  pdf page delete

pdf page delete <pdfId> <page>


Description

    Delete a page.

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
admin
pdf page delete "pdfId" 2;
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
Often used with

    pdf bookmark add  ·  pdf close  ·  pdf extract_pages  ·  pdf extract_text  ·  pdf from html  ·  pdf load  ·  pdf merge  ·  pdf page count

pdf page size <pdfId> <page>


Description

    Get the size of a page.

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
admin
pdf page size "pdfId" 1
mentdb
{ "width": 595.27563, "height": 841.8898, "rotation": 0 }
Used in use cases (3 recipes)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
Often used with

    pdf close  ·  pdf save  ·  pdf create  ·  pdf draw circle  ·  pdf draw line  ·  pdf extract_text  ·  pdf font show  ·  pdf load

pdf page rotate <pdfId> <page> <angle>


Description

    Rotate a page (multiple of 90).

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
    angle:   The angle (90, 180, 270, -90 ...) - number - required
admin
pdf page rotate "pdfId" 1 90;
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
Often used with

    pdf bookmark add  ·  pdf close  ·  pdf extract_pages  ·  pdf extract_text  ·  pdf from html  ·  pdf load  ·  pdf merge  ·  pdf page count

pdf page import <pdfId> <source> <sourcePage>


Description

    Append a page of another PDF file (template, cover, terms ...). You can then draw on it. Return the new page number.

Parameters

    pdfId:   The PDF document id - string - required
    source:   The source PDF file - string - required
    sourcePage:   The page number in the source - integer>=1 - required
admin
pdf page import "pdfId" "/Users/jimmitry/Desktop/template.pdf" 1
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
Often used with

    pdf bookmark add  ·  pdf close  ·  pdf extract_pages  ·  pdf extract_text  ·  pdf from html  ·  pdf load  ·  pdf merge  ·  pdf page count

pdf font load <pdfId> <name> <path>


Description

    Load a TrueType font (.ttf) into the document (full Unicode support). The standard fonts only support Latin-1 (WinAnsi).

Parameters

    pdfId:   The PDF document id - string - required
    name:   The font name to use in the styles - string - required
    path:   The .ttf file - string - required
admin
pdf font load "pdfId" "dejavu" "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf";
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
Often used with

    file exist  ·  json parse_array  ·  pdf close  ·  pdf compress_image  ·  pdf create  ·  pdf draw circle  ·  pdf draw line  ·  pdf draw polygon

pdf font show <pdfId>


Description

    Show the available fonts (standard + loaded).

Parameters

    pdfId:   The PDF document id - string - required
admin
pdf font show "pdfId"
mentdb
["HELVETICA", "HELVETICA_BOLD", "...", "dejavu"]
Used in use cases (2 recipes)

    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
Often used with

    pdf close  ·  pdf create  ·  pdf draw circle  ·  pdf draw line  ·  pdf page add  ·  pdf page size  ·  pdf save  ·  pdf text add

pdf text add <pdfId> <page> <x> <y> <text> <style>


Description

    Draw one line of text. x is the anchor (depends on align), y is the top of the text.
Standard fonts: HELVETICA, HELVETICA_BOLD, HELVETICA_OBLIQUE, HELVETICA_BOLD_OBLIQUE, TIMES_ROMAN, TIMES_BOLD, TIMES_ITALIC, TIMES_BOLD_ITALIC, COURIER, COURIER_BOLD, COURIER_OBLIQUE, COURIER_BOLD_OBLIQUE, SYMBOL, ZAPF_DINGBATS.

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
    x:   x (points) - number - required
    y:   y from the top (points) - number - required
    text:   The text - string - required
    style:   Text style: JSON or 'key=value;...' (font, size, color, align left|center|right, opacity, rotate, underline) - string - required
admin
pdf text add "pdfId" 1 40 40 "Hello world" "font=HELVETICA_BOLD;size=18;color=#1E5AA0";
mentdb
1
Right aligned on x
admin
pdf text add "pdfId" 1 555 40 "Total: 125.00 EUR" "size=12;align=right"
mentdb
1
Vertical text
admin
pdf text add "pdfId" 1 20 500 "Confidential" "rotate=90;color=#999999"
mentdb
1
Used in use cases (8 recipes)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    Security engineer › Sign a PDF and check it: not modified is not the same as trusted
    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
    PDF & document automation specialist › Shrink a scanned dossier before archiving
    PDF & document automation specialist › Stamp a PDF received in base64 from an API
    and 2 more in the Use cases
Often used with

    pdf close  ·  pdf create  ·  pdf page add  ·  pdf save  ·  pdf extract_text  ·  pdf draw rect  ·  pdf page_count_file  ·  file exist

pdf text paragraph <pdfId> <page> <x> <y> <width> <text> <style>


Description

    Draw a wrapped paragraph in a box of 'width' (line breaks [_n_] respected). When the bottom margin is reached, the text continues on the next page (created if needed).
Style: font, size, color, align (left|center|right|justify), line_height (1.25), margin_top (40), margin_bottom (40), space_after, opacity.
Return the position just after the paragraph: {"page":p,"y":y}.

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
    x:   x (points) - number - required
    y:   y from the top (points) - number - required
    width:   The width of the box - number - required
    text:   The text - string - required
    style:   Text style: JSON or 'key=value;...' (font, size, color, align left|center|right, opacity, rotate, underline) - string - required
admin
pdf text paragraph "pdfId" 1 40 100 515 "Lorem ipsum dolor sit amet ..." "size=11;align=justify"
mentdb
{ "page": 1, "y": 142.5 }
Chain the paragraphs
admin
json load "pos" (pdf text paragraph "pdfId" 1 40 100 515 [text1] "size=11"); pdf text paragraph "pdfId" (json select "pos" /page) 40 (json select "pos" /y) 515 [text2] "size=11";
mentdb
...
Used in use cases (2 recipes)

    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
Often used with

    pdf close  ·  pdf create  ·  pdf draw circle  ·  pdf draw line  ·  pdf font show  ·  pdf page add  ·  pdf page size  ·  pdf save

pdf text width <pdfId> <text> <style>


Description

    Get the width of a text in points (to compute a layout).

Parameters

    pdfId:   The PDF document id - string - required
    text:   The text - string - required
    style:   font, size - string - required
admin
pdf text width "pdfId" "Hello" "size=12"
mentdb
27.34
Used in use cases (1 recipe)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
Often used with

    math decimal_format  ·  pdf close  ·  pdf create  ·  pdf draw line  ·  pdf draw rect  ·  pdf extract_text  ·  pdf info set  ·  pdf link add

pdf draw line <pdfId> <page> <x1> <y1> <x2> <y2> <style>


Description

    Draw a line. Style: color, line_width, dash ('3 2'), opacity.

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
    x1:   x1 - number - required
    y1:   y1 - number - required
    x2:   x2 - number - required
    y2:   y2 - number - required
    style:   color, line_width, dash, opacity - string - required
admin
pdf draw line "pdfId" 1 40 120 555 120 "color=#CCCCCC;line_width=1";
mentdb
1
Used in use cases (3 recipes)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
Often used with

    pdf close  ·  pdf create  ·  pdf page add  ·  pdf save  ·  pdf text add  ·  pdf draw circle  ·  pdf draw rect  ·  pdf extract_text

pdf draw rect <pdfId> <page> <x> <y> <width> <height> <style>


Description

    Draw a rectangle (x, y = top-left corner). Style: fill, stroke, line_width, radius (rounded corners), dash, opacity.

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
    x:   x - number - required
    y:   y - number - required
    width:   width - number - required
    height:   height - number - required
    style:   Shape style: JSON or 'key=value;...' (fill, stroke, line_width, dash, radius, opacity) - string - required
admin
pdf draw rect "pdfId" 1 40 120 250 80 "fill=#F2F5FA;stroke=#1E5AA0;radius=8";
mentdb
1
Used in use cases (4 recipes)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
    PDF & document automation specialist › Stamp a PDF received in base64 from an API
    PDF & document automation specialist › Monthly statements: one file, then one PDF per customer
Often used with

    pdf close  ·  pdf text add  ·  pdf create  ·  pdf extract_text  ·  pdf page add  ·  pdf save  ·  math decimal_format  ·  pdf draw line

pdf draw circle <pdfId> <page> <cx> <cy> <radius> <style>


Description

    Draw a circle.

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
    cx:   center x - number - required
    cy:   center y - number - required
    radius:   radius - number - required
    style:   Shape style: JSON or 'key=value;...' (fill, stroke, line_width, dash, radius, opacity) - string - required
admin
pdf draw circle "pdfId" 1 300 400 50 "fill=#FFC800;opacity=0.5";
mentdb
1
Used in use cases (2 recipes)

    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Training certificate in A4 landscape with a seal
Often used with

    pdf close  ·  pdf create  ·  pdf draw line  ·  pdf font show  ·  pdf page add  ·  pdf page size  ·  pdf save  ·  pdf text add

pdf draw polygon <pdfId> <page> <points> <style>


Description

    Draw a polygon. Points: 'x1,y1 x2,y2 ...' or [[x1,y1],[x2,y2],...]. Style 'close=false' for a polyline (charts ...).

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
    points:   The points - string - required
    style:   Shape style: JSON or 'key=value;...' (fill, stroke, line_width, dash, radius, opacity) - string - required
admin
pdf draw polygon "pdfId" 1 "100,200 200,200 150,120" "fill=#1E5AA0";
mentdb
1
A polyline
admin
pdf draw polygon "pdfId" 1 "40,300 100,250 160,280 220,200" "stroke=#E04040;line_width=2;close=false"
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
Often used with

    file exist  ·  json parse_array  ·  pdf close  ·  pdf compress_image  ·  pdf create  ·  pdf draw circle  ·  pdf draw line  ·  pdf extract_text

pdf image add <pdfId> <page> <source> <x> <y> <width> <height>


Description

    Draw an image (png, jpg, gif, bmp file or 'data:image/png;base64,...'). x, y = top-left corner. width/height = 0: keep the ratio (both 0 = natural size). The same image is embedded only once.

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
    source:   The image file or data URI - string - required
    x:   x - number - required
    y:   y - number - required
    width:   width (0 = auto) - number - required
    height:   height (0 = auto) - number - required
admin
pdf image add "pdfId" 1 "/Users/jimmitry/Desktop/logo.png" 40 20 0 60;
mentdb
1
Used in use cases (3 recipes)

    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
    PDF & document automation specialist › Shrink a scanned dossier before archiving
    PDF & document automation specialist › Build a one-page PDF of weekly KPIs with a line chart
Often used with

    pdf close  ·  pdf create  ·  pdf page add  ·  pdf save  ·  pdf text add  ·  file exist  ·  pdf compress_image  ·  pdf extract_text

pdf table add <pdfId> <page> <x> <y> <data> <style>


Description

    Draw a table with word wrap, automatic page breaks and repeated header.
Data: {"columns":[...],"rows":[[...],...]} or the output of 'sql to json' ({"data":[{...}]}) or directly [[...],...].
A column: "title" or {"title":"Price","key":"price","width":80,"align":"right"} (key = the field for object rows). The columns can also be in the style.
Style: width, font, size, color, header_font, header_size, header_color, header_bg, zebra, border_color (none), border_width, padding, line_height, row_min_height, show_header, repeat_header, margin_top, margin_bottom, space_after.
Return the position just after the table: {"page":p,"y":y}.

Parameters

    pdfId:   The PDF document id - string - required
    page:   The page number (1-based) - integer>=1 - required
    x:   x - number - required
    y:   y - number - required
    data:   The table JSON - string - required
    style:   The table style (JSON or 'key=value;...') - string - required
admin
pdf table add "pdfId" 1 40 200 "{\"columns\":[\"Product\",{\"title\":\"Price\",\"align\":\"right\",\"width\":80}],\"rows\":[[\"car\",\"7.50\"],[\"bike\",\"9.80\"]]}" "zebra=#F2F5FA;width=300"
mentdb
{ "page": 1, "y": 250.4 }
From a SQL query
admin
pdf table add "pdfId" 1 40 200 (sql to json "session1" "products" (concat "select 'Car' as name, '7.50' as price union all select 'Bike', '9.80'")) "{\"columns\":[{\"title\":\"Product\",\"key\":\"name\"},{\"title\":\"Price\",\"key\":\"price\",\"align\":\"right\"}],\"header_bg\":\"#1E5AA0\"}"
mentdb
{"page": 1, "y": 245.0}
Used in use cases (1 recipe)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
Often used with

    math decimal_format  ·  pdf close  ·  pdf create  ·  pdf draw line  ·  pdf draw rect  ·  pdf extract_text  ·  pdf info set  ·  pdf link add

pdf bookmark add <pdfId> <title> <page>


Description

    Add a bookmark (outline / table of contents of the reader) to a page.

Parameters

    pdfId:   The PDF document id - string - required
    title:   The title - string - required
    page:   The page number (1-based) - integer>=1 - required
admin
pdf bookmark add "pdfId" "Chapter 1" 2;
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
Often used with

    pdf close  ·  pdf extract_pages  ·  pdf extract_text  ·  pdf from html  ·  pdf load  ·  pdf merge  ·  pdf page count  ·  pdf page delete

pdf page_number add <pdfId> <pattern> <x> <y> <style>


Description

    Write the page numbers on all pages (call it at the end). Pattern: {page} and {total}. Style: text style + from (first page, ex: 2 to skip the cover).

Parameters

    pdfId:   The PDF document id - string - required
    pattern:   The pattern - string - required
    x:   x - number - required
    y:   y - number - required
    style:   Text style: JSON or 'key=value;...' (font, size, color, align left|center|right, opacity, rotate, underline) - string - required
admin
pdf page_number add "pdfId" "Page {page} / {total}" 555 815 "align=right;size=9";
mentdb
1
Used in use cases (2 recipes)

    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    PDF & document automation specialist › Monthly statements: one file, then one PDF per customer
Often used with

    math decimal_format  ·  pdf close  ·  pdf create  ·  pdf draw rect  ·  pdf extract_text  ·  pdf page add  ·  pdf page_count_file  ·  pdf save

pdf watermark add <pdfId> <text> <style>


Description

    Add a diagonal watermark at the center of all pages. Style: font, size (60), color, opacity (0.15), angle (45).

Parameters

    pdfId:   The PDF document id - string - required
    text:   The text - string - required
    style:   The style - string - required
admin
pdf watermark add "pdfId" "DRAFT" "color=#FF0000;opacity=0.1;size=90";
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Watermark and password-protect a contract
Often used with

    pdf close  ·  pdf exist  ·  pdf extract_text  ·  pdf from html  ·  pdf info get  ·  pdf load  ·  pdf page_count_file  ·  pdf protect

pdf form fields <pdfId>


Description

    Get the fields of a PDF form (AcroForm).

Parameters

    pdfId:   The PDF document id - string - required
admin
pdf form fields "pdfId"
mentdb
[ { "name": "lastname", "type": "TextField", "value": "", "read_only": false, "required": false } ]
Used in use cases (1 recipe)

    PDF & document automation specialist › Fill and flatten a PDF form
Often used with

    file create  ·  pdf close_all  ·  pdf extract_text  ·  pdf form fill  ·  pdf form flatten  ·  pdf load  ·  pdf load_base64  ·  pdf save

pdf form fill <pdfId> <fields>


Description

    Fill the fields of a PDF form. Checkbox: true/false. Return the number of filled fields.

Parameters

    pdfId:   The PDF document id - string - required
    fields:   JSON {"name":"value", ...} - string - required
admin
pdf form fill "pdfId" "{\"lastname\":\"Payet\",\"firstname\":\"Jimmitry\",\"accept\":true}"
mentdb
3
Used in use cases (1 recipe)

    PDF & document automation specialist › Fill and flatten a PDF form
Often used with

    file create  ·  pdf close_all  ·  pdf extract_text  ·  pdf form fields  ·  pdf form flatten  ·  pdf load  ·  pdf load_base64  ·  pdf save

pdf form flatten <pdfId>


Description

    Flatten the form: the fields become non editable content.

Parameters

    pdfId:   The PDF document id - string - required
admin
pdf form flatten "pdfId";
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Fill and flatten a PDF form
Often used with

    file create  ·  pdf close_all  ·  pdf extract_text  ·  pdf form fields  ·  pdf form fill  ·  pdf load  ·  pdf load_base64  ·  pdf save

pdf merge <sources> <destination>


Description

    Merge PDF files into one.

Parameters

    sources:   JSON array of paths - string - required
    destination:   The destination file - string - required
admin
pdf merge "[\"/tmp/a.pdf\",\"/tmp/b.pdf\"]" "/tmp/merged.pdf";
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
Often used with

    pdf bookmark add  ·  pdf close  ·  pdf extract_pages  ·  pdf extract_text  ·  pdf from html  ·  pdf load  ·  pdf page count  ·  pdf page delete

pdf split <source> <directory>


Description

    Split a PDF file: one file per page. Return the created files.

Parameters

    source:   The PDF file - string - required
    directory:   The destination directory - string - required
admin
pdf split "/tmp/merged.pdf" "/tmp/split"
mentdb
[ "/tmp/split/merged_1.pdf", "/tmp/split/merged_2.pdf" ]

pdf split <source> <directory> <pagesPerFile>


Description

    Split a PDF file every N pages. Return the created files.

Parameters

    source:   The PDF file - string - required
    directory:   The destination directory - string - required
    pagesPerFile:   Pages per file - integer>=1 - required
admin
pdf split "/tmp/merged.pdf" "/tmp/split" 2
mentdb
[ "/tmp/split/merged_1.pdf" ]
Used in use cases (1 recipe)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
Often used with

    pdf bookmark add  ·  pdf close  ·  pdf extract_pages  ·  pdf extract_text  ·  pdf from html  ·  pdf load  ·  pdf merge  ·  pdf page count

pdf extract_pages <source> <destination> <from> <to>


Description

    Extract a range of pages into a new PDF file.

Parameters

    source:   The PDF file - string - required
    destination:   The destination file - string - required
    from:   First page - integer>=1 - required
    to:   Last page - integer>=1 - required
admin
pdf extract_pages "/tmp/a.pdf" "/tmp/p2-4.pdf" 2 4;
mentdb
1
Used in use cases (2 recipes)

    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
    PDF & document automation specialist › Monthly statements: one file, then one PDF per customer
Often used with

    pdf close  ·  pdf extract_text  ·  pdf save  ·  string replace  ·  string trim  ·  file dir_list_regex  ·  file mkdir  ·  json parse_array

pdf extract_text <source>


Description

    Extract the text of a PDF file.

Parameters

    source:   The PDF file - string - required
admin
pdf extract_text "/tmp/a.pdf"
mentdb
INVOICE ...

pdf extract_text <source> <from> <to>


Description

    Extract the text of some pages of a PDF file.

Parameters

    source:   The PDF file - string - required
    from:   First page - integer>=1 - required
    to:   Last page - integer>=1 - required
admin
pdf extract_text "/tmp/a.pdf" 1 2
mentdb
INVOICE ...
Used in use cases (10 recipes)

    SQL developer in MQL › Export a query to CSV, Excel and PDF files
    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    API & database integrator › Read supplier invoices from an Office 365 mailbox
    PDF & document automation specialist › Assemble an audit dossier, then split it for the reviewers
    PDF & document automation specialist › Watermark and password-protect a contract
    PDF & document automation specialist › Fill and flatten a PDF form
    and 4 more in the Use cases
Often used with

    pdf close  ·  pdf save  ·  pdf page_count_file  ·  pdf text add  ·  pdf create  ·  pdf load  ·  pdf page add  ·  string replace

pdf page_count_file <source>


Description

    Get the number of pages of a PDF file (without loading it).

Parameters

    source:   The PDF file - string - required
admin
pdf page_count_file "/tmp/a.pdf"
mentdb
3
Used in use cases (8 recipes)

    SQL developer in MQL › Export a query to CSV, Excel and PDF files
    PDF & document automation specialist › A4 invoice with a table, totals and page numbers
    Integrator & ETL developer › Nightly export pack: CSV, Excel and PDF in an outbox connection
    SQL developer in MQL › CSV, XML and HTML for three partners
    PDF & document automation specialist › Watermark and password-protect a contract
    PDF & document automation specialist › Shrink a scanned dossier before archiving
    and 2 more in the Use cases
Often used with

    file mkdir  ·  pdf close  ·  pdf extract_text  ·  pdf save  ·  file delete  ·  pdf create  ·  pdf page add  ·  pdf text add

pdf to_image <source> <page> <dpi> <destination>


Description

    Render a page as an image (png or jpg, from the extension).

Parameters

    source:   The PDF file - string - required
    page:   The page number (1-based) - integer>=1 - required
    dpi:   The resolution (72, 150, 300 ...) - number - required
    destination:   The image file (.png or .jpg) - string - required
admin
pdf to_image "/tmp/a.pdf" 1 150 "/tmp/page1.png";
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › KPI one-pager with a hand-drawn chart and a thumbnail
Often used with

    file exist  ·  json parse_array  ·  pdf close  ·  pdf compress_image  ·  pdf create  ·  pdf draw circle  ·  pdf draw line  ·  pdf draw polygon

pdf protect <source> <destination> <ownerPassword> <userPassword>


Description

    Protect a PDF file with AES-256 (user password to open, owner password for full rights). Default rights: print, copy, annotate, fill in.

Parameters

    source:   The PDF file - string - required
    destination:   The destination file - string - required
    ownerPassword:   The owner password - string - required
    userPassword:   The user password ('' = open without password) - string - required
admin
pdf protect "/tmp/a.pdf" "/tmp/secure.pdf" "ownerPwd" "userPwd";
mentdb
1

pdf protect <source> <destination> <ownerPassword> <userPassword> <permissions>


Description

    Protect a PDF file with AES-256 and specific rights: print, copy, modify, annotate, fill_in, assemble.

Parameters

    source:   The PDF file - string - required
    destination:   The destination file - string - required
    ownerPassword:   The owner password - string - required
    userPassword:   The user password - string - required
    permissions:   JSON or 'key=value;...' - string - required
admin
pdf protect "/tmp/a.pdf" "/tmp/secure.pdf" "ownerPwd" "" "print=true;copy=false;modify=false";
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Watermark and password-protect a contract
Often used with

    pdf close  ·  pdf exist  ·  pdf extract_text  ·  pdf from html  ·  pdf info get  ·  pdf load  ·  pdf page_count_file  ·  pdf save

pdf unprotect <source> <destination> <password>


Description

    Remove the protection of a PDF file.

Parameters

    source:   The PDF file - string - required
    destination:   The destination file - string - required
    password:   The password - string - required
admin
pdf unprotect "/tmp/secure.pdf" "/tmp/a.pdf" "ownerPwd";
mentdb
1
Used in use cases (1 recipe)

    PDF & document automation specialist › Watermark and password-protect a contract
Often used with

    pdf close  ·  pdf exist  ·  pdf extract_text  ·  pdf from html  ·  pdf info get  ·  pdf load  ·  pdf page_count_file  ·  pdf protect

pdf compare <pdf_path_a> <pdf_path_b>


Description

    Compare the text of two PDF files page by page (lines in reading order, compared with java-diff-utils). Returns {pages_a, pages_b, identical, pages_with_text_changes, pages: [{page, in_a, in_b, text_equal, changes: [{type (insert, delete, change), line_a, lines_a, line_b, lines_b}]}]}

Parameters

    pdf_path_a:   The first PDF - String - required
    pdf_path_b:   The second PDF - String - required
admin
if (equal (file exist "tmp/tuto_ops") "0") {file mkdir "tmp/tuto_ops";}; invoice to_pdf "{\"number\": \"F2026-0101\", \"type_code\": \"380\", \"issue_date\": \"2026-11-10\", \"currency\": \"EUR\", \"seller\": {\"name\": \"Atelier Payet SARL\", \"siren\": \"732829320\", \"vat_id\": \"FR44732829320\", \"address\": {\"line1\": \"12 rue de Paris\", \"postcode\": \"97400\", \"city\": \"Saint-Denis\", \"country\": \"FR\"}}, \"buyer\": {\"name\": \"Client SAS\", \"address\": {\"postcode\": \"75008\", \"city\": \"Paris\", \"country\": \"FR\"}}, \"lines\": [{\"name\": \"Consulting\", \"quantity\": 3, \"unit_price\": 95, \"vat_category\": \"S\", \"vat_rate\": 8.5}], \"payment\": {\"iban\": \"FR7630006000011234567890189\", \"terms\": \"30 days\"}}" "tmp/tuto_ops/a.pdf"; invoice to_pdf "{\"number\": \"F2026-0101\", \"type_code\": \"380\", \"issue_date\": \"2026-11-10\", \"currency\": \"EUR\", \"seller\": {\"name\": \"Atelier Payet SARL\", \"siren\": \"732829320\", \"vat_id\": \"FR44732829320\", \"address\": {\"line1\": \"12 rue de Paris\", \"postcode\": \"97400\", \"city\": \"Saint-Denis\", \"country\": \"FR\"}}, \"buyer\": {\"name\": \"Client SAS\", \"address\": {\"postcode\": \"75008\", \"city\": \"Paris\", \"country\": \"FR\"}}, \"lines\": [{\"name\": \"Consulting\", \"quantity\": 4, \"unit_price\": 95, \"vat_category\": \"S\", \"vat_rate\": 8.5}], \"payment\": {\"iban\": \"FR7630006000011234567890189\", \"terms\": \"30 days\"}}" "tmp/tuto_ops/b.pdf"; -> "[res]" (pdf compare "tmp/tuto_ops/a.pdf" "tmp/tuto_ops/b.pdf"); file delete "tmp/tuto_ops"; [res]
mentdb
{"pages_a": 1, "pages_b": 1, "identical": false, "pages_with_text_changes": 1, "pages": [{"page": 1, "in_a": true, "in_b": true, "text_equal": false, "changes": [{"type": "change", "line_a": 10, "lines_a": ["Consulting 3 pc 95.00 8.5 % 285.00", "VAT breakdown Total net 285.00 EUR", "Category Rate Basis VAT amount Total VAT 24.23 EUR", "S 8.5 % 285.00 24.23 Total 309.23 EUR", "Amount due 309.23 EUR"], "line_b": 10, "lines_b": ["Consulting 4 pc 95.00 8.5 % 380.00", "VAT breakdown Total net 380.00 EUR", "Category Rate Basis VAT amount Total VAT 32.30 EUR", "S 8.5 % 380.00 32.30 Total 412.30 EUR", "Amount due 412.30 EUR"]}]}]}

pdf compare <pdf_path_a> <pdf_path_b> <json_params>


Description

    Compare with parameters: visual (true: render both pages with PDFBox and give visual_diff_percent, the percentage of pixels that differ by more than threshold on a color channel, 4 decimals; null when a page is missing), dpi (50, 10 to 150), threshold (32), max_pages (500), max_changes (200 per page)

Parameters

    pdf_path_a:   The first PDF - String - required
    pdf_path_b:   The second PDF - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_ops") "0") {file mkdir "tmp/tuto_ops";}; invoice to_pdf "{\"number\": \"F2026-0101\", \"type_code\": \"380\", \"issue_date\": \"2026-11-10\", \"currency\": \"EUR\", \"seller\": {\"name\": \"Atelier Payet SARL\", \"siren\": \"732829320\", \"vat_id\": \"FR44732829320\", \"address\": {\"line1\": \"12 rue de Paris\", \"postcode\": \"97400\", \"city\": \"Saint-Denis\", \"country\": \"FR\"}}, \"buyer\": {\"name\": \"Client SAS\", \"address\": {\"postcode\": \"75008\", \"city\": \"Paris\", \"country\": \"FR\"}}, \"lines\": [{\"name\": \"Consulting\", \"quantity\": 3, \"unit_price\": 95, \"vat_category\": \"S\", \"vat_rate\": 8.5}], \"payment\": {\"iban\": \"FR7630006000011234567890189\", \"terms\": \"30 days\"}}" "tmp/tuto_ops/a.pdf"; invoice to_pdf "{\"number\": \"F2026-0101\", \"type_code\": \"380\", \"issue_date\": \"2026-11-10\", \"currency\": \"EUR\", \"seller\": {\"name\": \"Atelier Payet SARL\", \"siren\": \"732829320\", \"vat_id\": \"FR44732829320\", \"address\": {\"line1\": \"12 rue de Paris\", \"postcode\": \"97400\", \"city\": \"Saint-Denis\", \"country\": \"FR\"}}, \"buyer\": {\"name\": \"Client SAS\", \"address\": {\"postcode\": \"75008\", \"city\": \"Paris\", \"country\": \"FR\"}}, \"lines\": [{\"name\": \"Consulting\", \"quantity\": 4, \"unit_price\": 95, \"vat_category\": \"S\", \"vat_rate\": 8.5}], \"payment\": {\"iban\": \"FR7630006000011234567890189\", \"terms\": \"30 days\"}}" "tmp/tuto_ops/b.pdf"; -> "[res]" (pdf compare "tmp/tuto_ops/a.pdf" "tmp/tuto_ops/b.pdf" "{\"visual\": true, \"dpi\": 36}"); file delete "tmp/tuto_ops"; [res]
mentdb
{"pages_a": 1, "pages_b": 1, "identical": false, "pages_with_text_changes": 1, "pages": [{"page": 1, "in_a": true, "in_b": true, "text_equal": false, "changes": [{"type": "change", "line_a": 10, "lines_a": ["Consulting 3 pc 95.00 8.5 % 285.00", "VAT breakdown Total net 285.00 EUR", "Category Rate Basis VAT amount Total VAT 24.23 EUR", "S 8.5 % 285.00 24.23 Total 309.23 EUR", "Amount due 309.23 EUR"], "line_b": 10, "lines_b": ["Consulting 4 pc 95.00 8.5 % 380.00", "VAT breakdown Total net 380.00 EUR", "Category Rate Basis VAT amount Total VAT 32.30 EUR", "S 8.5 % 380.00 32.30 Total 412.30 EUR", "Amount due 412.30 EUR"]}], "visual_diff_percent": 0.0757}]}
Used in use cases (1 recipe)

    Security engineer › Remove the bank details and an address from a PDF invoice before it is shared
Often used with

    file delete  ·  file exist  ·  file mkdir  ·  invoice to_pdf  ·  pdf redact

pdf redact <pdf_path> <out_path> <json_rules>


Description

    Remove text from a PDF and write a new file. json_rules: {"areas": [{"page": 1 (0 or none: every page), "x", "y", "width", "height"}], "patterns": ["regular expression", ...]}. Returns {out_path, pages, matches, glyphs_removed, images_redacted, images_removed, annotations_removed, verified}

Parameters

    pdf_path:   The PDF - String - required
    out_path:   The PDF to write - String - required
    json_rules:   The areas and patterns - String - required
admin
if (equal (file exist "tmp/tuto_ops") "0") {file mkdir "tmp/tuto_ops";}; invoice to_pdf "{\"number\": \"F2026-0101\", \"type_code\": \"380\", \"issue_date\": \"2026-11-10\", \"currency\": \"EUR\", \"seller\": {\"name\": \"Atelier Payet SARL\", \"siren\": \"732829320\", \"vat_id\": \"FR44732829320\", \"address\": {\"line1\": \"12 rue de Paris\", \"postcode\": \"97400\", \"city\": \"Saint-Denis\", \"country\": \"FR\"}}, \"buyer\": {\"name\": \"Client SAS\", \"address\": {\"postcode\": \"75008\", \"city\": \"Paris\", \"country\": \"FR\"}}, \"lines\": [{\"name\": \"Consulting\", \"quantity\": 3, \"unit_price\": 95, \"vat_category\": \"S\", \"vat_rate\": 8.5}], \"payment\": {\"iban\": \"FR7630006000011234567890189\", \"terms\": \"30 days\"}}" "tmp/tuto_ops/a.pdf"; pdf redact "tmp/tuto_ops/a.pdf" "tmp/tuto_ops/r.pdf" "{\"patterns\": [\"FR76[0-9 ]+\"]}"; -> "[res]" (pdf compare "tmp/tuto_ops/a.pdf" "tmp/tuto_ops/r.pdf"); file delete "tmp/tuto_ops"; [res]
mentdb
{"pages_a": 1, "pages_b": 1, "identical": false, "pages_with_text_changes": 1, "pages": [{"page": 1, "in_a": true, "in_b": true, "text_equal": false, "changes": [{"type": "change", "line_a": 17, "lines_a": ["IBAN: FR76 3000 6000 0112 3456 7890 189"], "line_b": 17, "lines_b": ["IBAN:"]}]}]}

pdf redact <pdf_path> <out_path> <json_rules> <json_params>


Description

    Redact with parameters: ignore_case (false), origin (top-left or bottom-left), fill (true: black boxes), color (#000000), annotations (true: remove the annotations and form fields over the areas or matching the patterns, see above), overwrite (false), max_pages (2000)

Parameters

    pdf_path:   The PDF - String - required
    out_path:   The PDF to write - String - required
    json_rules:   The areas and patterns - String - required
    json_params:   The parameters - String - required
admin
if (equal (file exist "tmp/tuto_ops") "0") {file mkdir "tmp/tuto_ops";}; invoice to_pdf "{\"number\": \"F2026-0101\", \"type_code\": \"380\", \"issue_date\": \"2026-11-10\", \"currency\": \"EUR\", \"seller\": {\"name\": \"Atelier Payet SARL\", \"siren\": \"732829320\", \"vat_id\": \"FR44732829320\", \"address\": {\"line1\": \"12 rue de Paris\", \"postcode\": \"97400\", \"city\": \"Saint-Denis\", \"country\": \"FR\"}}, \"buyer\": {\"name\": \"Client SAS\", \"address\": {\"postcode\": \"75008\", \"city\": \"Paris\", \"country\": \"FR\"}}, \"lines\": [{\"name\": \"Consulting\", \"quantity\": 3, \"unit_price\": 95, \"vat_category\": \"S\", \"vat_rate\": 8.5}], \"payment\": {\"iban\": \"FR7630006000011234567890189\", \"terms\": \"30 days\"}}" "tmp/tuto_ops/a.pdf"; -> "[res]" (pdf redact "tmp/tuto_ops/a.pdf" "tmp/tuto_ops/r.pdf" "{\"areas\": [{\"page\": 1, \"x\": 40, \"y\": 40, \"width\": 250, \"height\": 60}], \"patterns\": [\"client sas\"]}" "{\"ignore_case\": true, \"color\": \"#808080\"}"); file delete "tmp/tuto_ops"; [res]
mentdb
{"out_path": "tmp/tuto_ops/r.pdf", "pages": 1, "matches": 1, "glyphs_removed": 99, "images_redacted": 0, "images_removed": 0, "annotations_removed": 0, "verified": true}
Used in use cases (1 recipe)

    Security engineer › Remove the bank details and an address from a PDF invoice before it is shared
Often used with

    file delete  ·  file exist  ·  file mkdir  ·  invoice to_pdf  ·  pdf compare