The PDF Plugin provides methods to create, manipulate, and export PDF documents, including adding text, images, shapes, barcodes, and controlling page layout, fonts, colors, and security.
Methods
Method | Description |
---|---|
create | Creates a new PDF document instance. |
extractText | Extracts text from a PDF file. |
extractTextFields | Extracts text fields from a PDF file. |
Methods Details
create()
• Type
() => Pdf
• Details
Creates a new PDF document instance.
Returns a Pdf object for further PDF manipulation.
• Example
const pdf = E8App.$pdf.create();
// add a new page
pdf.addPage();
// set font, size, and add text
pdf.setFont(E8App.$pdf.FONT_HELVETICA);
pdf.setFontSize(12);
pdf.addText({ text: 'Hello, PDF!', x: 20, y: 50, width: 200 });
// add a rectangle
pdf.addRect({ x: 20, y: 60, width: 100, height: 50, stroke: true, fill: false });
// save PDF
const fileInfo = pdf.save('example');
// fileInfo now contains information about the saved PDF file
extractText()
• Type
(id: string | UploadedFile) => string | null
• Details
Expects a file ID or an UploadedFile to extract text from.
Returns the extracted text as a string or null
if extraction fails.
extractTextFields()
• Type
(id: string | UploadedFile) => PdfTextField[] | null
• Details
Expects a file ID or an UploadedFile to extract form fields from.
Returns an array of PdfTextField or null
if extraction fails.