aw2.pdf
aw2.pdf is used to provide the ability to generate PDF from HTML content. It is based on tcpdf library, with aw2.pdf you can save a pdf file or force it to download it.
Attributes:
- part:
setup| header | footer | content | download | saveVarious parts split the usage of aw2.pdf into manageable chunks.
Part = Setup for aw2.pdf
When you are starting to set up various properties of your PDF file like page orientation etc., you start by using part=setup. It takes following values as a JSON object, as shown in example below
- page_orientation:
P or Portrait | L or LandscapeIf not specified, Portrait is taken as default - pdf_unit:
pt | mm | cm | inA point equals 1/72 of an inch, that is to say about 0.35 mm (an inch being 2.54 cm). This is a very common unit in typography; font sizes are expressed in that unit - page_format:
A0| A4 | LETTERA bigger list of supported page formats can be seen at https://tcpdf.org/docs/srcdoc/tcpdf/class-TCPDF_STATIC/#$page_formats. You can also provide an array of width and height for custom sizes. - unicode:
TRUE | FalseTRUE means that the input text is Unicode (default = true) - encoding:
Charset encoding (used only when converting back HTML entities); default is UTF-8.
- pdfa:
TRUE | FalseIf TRUE set the document to PDF/A mode. - show_header:
yes | noIf it is set to ‘no’ then the header is not set on pdf file, and part=header section is ignored. By default, it is yes. - header_margin:
Size of the header, it is specified in the page unit selected.
- show_footer:
yes | noIf it is set to ‘no’ then the footer is not set on pdf file, and part=footer section is ignored. By default, it is yes. - footer_margin:
Size of the footer is specified using footer_margin
- author:
If provided it will set as author of the PDF file
- title:
If provided it will be set as title of the PDF file
- left_margin:
It allows you to set the left margin of the page
- top_margin:
It allows you to set the top margin of the page
- right_margin:
It allows you to set the right margin of the page
- font_name:
Set over all font to use for the PDF file
[aw2.pdf part=setup] { "page_orientation":"", "pdf_unit":"", "page_format":"", "unicode":"", "encoding":"", "pdfa":"", "show_footer":"yes", "show_header":"yes", "author":"", "title":"" } [/aw2.pdf]
A working example
[aw2.pdf part=setup] { "page_orientation":"p", "pdf_unit":"mm", "page_format":"A4", "header_margin":"5", "footer_margin":"20", "author":"Amit" } [/aw2.pdf]
Part = Header for aw2.pdf
If you want to set a header to the PDF you can use the part=header. It allows you to set the font, size for the full header. It gives you the flexibility to control the position of each item where you want. It supports following JSON parameters
- font_name:
You can specify the name of the font to use.
- font_size:
size of the font
- items:
item_type
An example
[aw2.pdf part=header] { "font_name":"freesans", "font_size":"15", "items":[ { "item_type": "cell", "SetY":"1", "w":"10", "h":"0", "text":"Testing Header WPoets", "border":"B", "ln":"1", "align":"R" }, { "item_type": "text", "SetY":"2", "x":"2", "y":"2", "text":"Testing Text Link header", "link":"https://www.wpoets.com" }, { "item_type": "image", "SetY":"0.1", "file":"D:\\laragon\\www\\awesome\\wp-content\\uploads\\2017\\05\\random-4-100x100.png", "x":"15", "y":"2", "w":"100" }, { "item_type": "cell", "SetY":"4", "w":"10", "h":"0", "text":"header cell", "border":"B", "ln":"1", "align":"R" } ] } [/aw2.pdf]
Part = Footer for aw2.pdf
Similar to part = header, it allows you to configure things for footer of you PDF page. Part = Footer has same JSON attributes as header.
[aw2.pdf part=footer] { "font_name":"freesans", "font_size":"15", "items":[ { "item_type": "cell", "SetX":"6", "w":"0", "h":"0", "text":"Generated By Magazinify.com | An Experiment By AmiWorks", "border":"", "ln":"0", "align":"L" } ] } [/aw2.pdf]
Part = Content for aw2.pdf
This is where actual HTML page content of you pdf file is written. It uses writeHTML function of tcpdf, so make sure the HTML you are writing here is well formed. You can use awesome studio shortcodes within the content. It will be parsed while generating PDF
[aw2.pdf part=content] <p style="color:red">the properly formated HTML content with attributes having double quotes.</p> [/aw2.pdf]
Part = Download for aw2.pdf
If you want to download the generated PDF you use part=download. Once this part is executed, PDF file is forced to download and the pdf objected is destroyed. It requires just one additional attribute
- filename:
Name of the PDf that will be used while downloading the file.
[aw2.pdf part=download filename='abc.pdf'][/aw2.pdf]
Part = Save for aw2.pdf
If instead of downloading you want to save the generated PDF file then you can use part=save. Similar to download part, it will destroy the PDF object when executed. It requires few additional parameters
- dir_path:
The folder where you want to save the pdf files. This path must have write permission.
- filename:
Name of the PDF that will be used while saving the file.
[aw2.pdf part=save dir_path='D:/laragon/www/awesome/wp-content/uploads/2017' filename='abc.pdf'][/aw2.pdf]
It returns the path of PDF file generated.
Other shortcodes
Conditionals (7)
Core (11)
- aw2.run
- aw2.return
- aw2.template
- aw2.module
- aw2.raw
- aw2.get
- aw2.set_array
- aw2.set
- aw2.echo
- aw2.shortcode
- aw2.part
CRM (1)
Database (1)
Design & JavaScript (3)
- aw2.enqueue
- aw2.client
- aw2.spa
E-commerce (1)
Excelsheet (1)
- excel.write_bulk
Form Handling (3)
- aw2.sideload
- aw2.save_form
- aw2.upload
Mailing & SMS (3)
- aw2.subscribe
- aw2.sms
- aw2.wp_mail
PDF (1)
Utility (6)
- aw2.register
- aw2.register_handler
- aw2.reset_password
- aw2.login_handler
- app.restore
- app.backup
Latest Blogs
And there’s one thing I keep noticing: Everyone's obsessed with growth hacks.