FX - PDF @ File format @ MentDB Weak
PDF
pdf from htmlpdf compress_imagepdf createpdf load (2 params)pdf load (3 params)pdf 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 split (2 params)pdf split (3 params)pdf extract_pagespdf extract_text (1 params)pdf extract_text (3 params)pdf page_count_filepdf to_imagepdf protect (4 params)pdf protect (5 params)pdf unprotect
pdf from html <html> <filePath>
Description
Generate a PDF from a HTML document.
Generate a PDF from a HTML document.
Parameters
html: The html - string - required
filePath: The destination file path - string - required
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
pdf compress_image <pdf_path_source> <pdf_path_destination> <dpi>
Description
Compress images from/into a PDF. Warning, everything is transformed into images, it is made for PDFs of type images originally.
Compress images from/into a PDF. Warning, everything is transformed into images, it is made for PDFs of type images originally.
Parameters
pdf_path_source: The PDF source - string - required
pdf_path_destination: The PDF destination - string - required
dpi: The DPI by image (150 by default) - number - required
pdf_path_source: The PDF source - string - required
pdf_path_destination: The PDF destination - string - required
dpi: The DPI by image (150 by default) - number - required
admin
pdf compress_image "path/source/pdf.pdf" "path/destination/pdf.pdf" 150;
mentdb
1
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).
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
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
pdf load <pdfId> <path>
Description
Load a PDF file into memory (the file can then be overwritten by 'pdf save').
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
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.
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
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
pdf load_base64 <pdfId> <base64>
Description
Load a PDF from a base64 string (data:application/pdf;base64,... accepted).
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
pdfId: The PDF document id - string - required
base64: The PDF in base64 - string - required
admin
pdf load_base64 "pdfId" [b64];
mentdb
1
pdf save <pdfId> <path>
Description
Save a PDF document to a file (the directories are created if needed).
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
pdfId: The PDF document id - string - required
path: The destination path - string - required
admin
pdf save "pdfId" "/Users/jimmitry/Desktop/test.pdf";
mentdb
1
pdf to_base64 <pdfId>
Description
Get a PDF document as a base64 string (for mail, REST ...).
Get a PDF document as a base64 string (for mail, REST ...).
Parameters
pdfId: The PDF document id - string - required
pdfId: The PDF document id - string - required
admin
pdf to_base64 "pdfId"
mentdb
JVBERi0xLjQK...
pdf exist <pdfId>
Description
Check if a PDF document id is loaded.
Check if a PDF document id is loaded.
Parameters
pdfId: The PDF document id - string - required
pdfId: The PDF document id - string - required
admin
pdf exist "pdfId"
mentdb
1
pdf show
Description
Show all loaded PDF documents.
Show all loaded PDF documents.
admin
pdf show
mentdb
["pdfId"]
pdf close <pdfId>
Description
Close a PDF document.
Close a PDF document.
Parameters
pdfId: The PDF document id - string - required
pdfId: The PDF document id - string - required
admin
pdf close "pdfId";
mentdb
1
pdf close_all
Description
Close all PDF documents.
Close all PDF documents.
admin
pdf close_all;
mentdb
1
pdf info get <pdfId>
Description
Get the information of a PDF document.
Get the information of a PDF document.
Parameters
pdfId: The PDF document id - string - required
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" }
pdf info set <pdfId> <info>
Description
Set the information of a PDF document (title, author, subject, keywords, creator, producer).
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
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
pdf page add <pdfId> <format> <orientation>
Description
Add a page at the end of the document, return the new page number.
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
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
pdf page count <pdfId>
Description
Get the number of pages of a loaded document.
Get the number of pages of a loaded document.
Parameters
pdfId: The PDF document id - string - required
pdfId: The PDF document id - string - required
admin
pdf page count "pdfId"
mentdb
3
pdf page delete <pdfId> <page>
Description
Delete a page.
Delete a page.
Parameters
pdfId: The PDF document id - string - required
page: The page number (1-based) - integer>=1 - required
pdfId: The PDF document id - string - required
page: The page number (1-based) - integer>=1 - required
admin
pdf page delete "pdfId" 2;
mentdb
1
pdf page size <pdfId> <page>
Description
Get the size of a page.
Get the size of a page.
Parameters
pdfId: The PDF document id - string - required
page: The page number (1-based) - integer>=1 - required
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 }
pdf page rotate <pdfId> <page> <angle>
Description
Rotate a page (multiple of 90).
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
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
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.
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
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
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).
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
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
pdf font show <pdfId>
Description
Show the available fonts (standard + loaded).
Show the available fonts (standard + loaded).
Parameters
pdfId: The PDF document id - string - required
pdfId: The PDF document id - string - required
admin
pdf font show "pdfId"
mentdb
["HELVETICA", "HELVETICA_BOLD", "...", "dejavu"]
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.
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
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
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}.
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
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
...
pdf text width <pdfId> <text> <style>
Description
Get the width of a text in points (to compute a layout).
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
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
pdf draw line <pdfId> <page> <x1> <y1> <x2> <y2> <style>
Description
Draw a line. Style: color, line_width, dash ('3 2'), opacity.
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
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
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.
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
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
pdf draw circle <pdfId> <page> <cx> <cy> <radius> <style>
Description
Draw a circle.
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
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
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 ...).
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
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
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.
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
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
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}.
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
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}
pdf link add <pdfId> <page> <x> <y> <width> <height> <url>
Description
Add a clickable link (URL) on a zone of a page.
Add a clickable link (URL) on a zone of a page.
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
url: The URL - string - required
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
url: The URL - string - required
admin
pdf link add "pdfId" 1 40 800 120 15 "https://www.mentdb.org";
mentdb
1
pdf bookmark add <pdfId> <title> <page>
Description
Add a bookmark (outline / table of contents of the reader) to a page.
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
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
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).
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
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
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).
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
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
pdf form fields <pdfId>
Description
Get the fields of a PDF form (AcroForm).
Get the fields of a PDF form (AcroForm).
Parameters
pdfId: The PDF document id - string - required
pdfId: The PDF document id - string - required
admin
pdf form fields "pdfId"
mentdb
[ { "name": "lastname", "type": "TextField", "value": "", "read_only": false, "required": false } ]
pdf form fill <pdfId> <fields>
Description
Fill the fields of a PDF form. Checkbox: true/false. Return the number of filled fields.
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
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
pdf form flatten <pdfId>
Description
Flatten the form: the fields become non editable content.
Flatten the form: the fields become non editable content.
Parameters
pdfId: The PDF document id - string - required
pdfId: The PDF document id - string - required
admin
pdf form flatten "pdfId";
mentdb
1
pdf merge <sources> <destination>
Description
Merge PDF files into one.
Merge PDF files into one.
Parameters
sources: JSON array of paths - string - required
destination: The destination file - string - required
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
pdf split <source> <directory>
Description
Split a PDF file: one file per page. Return the created files.
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
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.
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
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" ]
pdf extract_pages <source> <destination> <from> <to>
Description
Extract a range of pages into a new PDF file.
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
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
pdf extract_text <source>
Description
Extract the text of a PDF file.
Extract the text of a PDF file.
Parameters
source: The PDF file - string - required
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.
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
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 ...
pdf page_count_file <source>
Description
Get the number of pages of a PDF file (without loading it).
Get the number of pages of a PDF file (without loading it).
Parameters
source: The PDF file - string - required
source: The PDF file - string - required
admin
pdf page_count_file "/tmp/a.pdf"
mentdb
3
pdf to_image <source> <page> <dpi> <destination>
Description
Render a page as an image (png or jpg, from the extension).
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
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
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.
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
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.
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
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
pdf unprotect <source> <destination> <password>
Description
Remove the protection of a PDF file.
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
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
