Creating pdfs programmatically

Posted by:

You can create a pdf programmatically using this method

WPDFIB()->GetPDF($orderId,$templateId,$mode);

This method requires 3 parameters

OrderId: The id of the order

TemplateId: The id of the template, you can find the template id in the template table or in the id in the orders designer

Mode: You can use 3 modes

display: The pdf is displayed in the browser. (This behavior might vary depending on the browser security settings)

download: The pdf is not displayed and instead is immediately downloaded by the user’s browser (This behavior might vary depending on the browser security settings).

output: The pdf file data is returned, you can then use this data to send it to another place or save it somewhere, for example, the code below will generate the pdf template with id 2 using the order (with id 1) and save it in ‘my/invoice.pdf’

file_put_contents('/my/invoice.pdf', WPDFIB()->GetPDF(1,2,'display'));

link: (Full version required). Returns a link to the pdf

0