Generating a PDF through a template something like editing markdown. We have a simple markup language to describe the style of the content.
Controller
First Parameter: Images directory that referred to generate a PDF.
Second Parameter: Template name that includes PDF content and its attributes.
Third Parameter: PDF filename
Fourth Parameter: PDF Title
Fifth Parameter: Width of the PDF window
function pdf1(Controller $ctl)
{
$ctl->res_pdf('images_dir', 'pdf_text.tpl', 'Example PDF');
}
Template
First --- use to divide header and body. Header parameters tell the generator how PDF look like. Other --- use to describe the style of the content that includes in the lower.
pagesize:A4
orientation:P
page_margin_top:20
page_margin_left:30
page_margin_right:30
page_margin_bottom:30
pagenumber:on
pagenumber_firstpage:on
img_grayscale:off
font:migmix-1p-bold
---
Left-justified text
--- R
Right-ordered text
--- C
Centering text
--- fontsize:20
Font size change
--- lineheight:10
Specifying row spacing lineheight:10
Specifying row spacing lineheight:10
--- lineheight:5
Specifying row spacing lineheight:5
Specifying row spacing lineheight:5
--- margintop:5
Specify upper margin margintop:5
--- marginleft:20
Specifying the left margin marginleft:30
--- marginleft:30 marginright:30
Left margin, left margin specified left margin, right margin left margin, left margin left margin, left margin left margin, left margin left margin, right margin left margin, left margin left margin, left marginMergen, specify the right margin left margin, specify the right margin left margin, specify the right margin
--- underline
Underline specification
--- color:255,0,0
Character color specification(RGB)
---L background:0,0,0 color:255,255,255 lineheight:9
Background color, character color specification
--- border:BLTR linecolor:0,0,255
Specify the color of the frame
--- x:50 y:200
X,YSpecify coordinates
--- x:50 y:230 width:100
X, y coordinates and width specification x, y coordinate and width specified x, y coordinate and width specified x, y coordinate and width specified x, y coordinate and width specified x,Specify y coordinates and width x, y coordinates and width
--- border:T linecolor:200,0,255 margintop:20
Only the upper frame
--- border:LT linecolor:0,200,200
Only left and upper frame
--- rotate:30 margintop:30
rotate rotate:30Specification
--- I file:logo.jpg x:100 y:100 w:100 h:30
Header Parameters
1) pagesize:A4
pagesize parameter sets the paper size. Example: A4, A3, B5, etc...
2) orientation:P
orientation parameter sets the page's orientation.
P refers to portrait - Page is in a vertical display
L refers to Landscape - Page is in a horizontal display
3) page_margin_top:20
page_margin_top parameter sets the value for the top margin.
4) page_margin_left:30
page_margin_left parameter sets the value for the left margin.
5) page_margin_right:30
page_margin_right parameter sets the value for the right margin.
6) page_margin_bottom:30
page_margin_bottom parameter sets the value for the bottom margin.
7) pagenumber:on
pagenumber parameter sets the values on/off
on - Page number is displayed
off - Page number is hidden
8) pagenumber_firstpage:on
pagenumber_firstpage parameter sets the values on/off
on - The page number is displayed only on the first page
off - The page number is hidden only on the first page
9) img_grayscale:off
img_grayscale parameter sets the values on/off
on - image contains only shades of gray and no colour
off - image contains colour
10) font:migmix-1p-bold
Default font size of the contents.
Content Parameters
1) --- R
R - right align, C - Center, L - left align
2) --- fontsize:20
Font size in pixel
3) --- lineheight:10
Line height in pixel
4) --- marginleft:30 marginright:30
Margin size in pixel
5) --- underline
Underlining the content
6) --- color:255,0,0
Content color in RGB format
7) --- background:0,0,0
Background color in RGB format
8) --- x:50 y:200
Custom content position in pixel
9) --- border:BLTR linecolor:0,0,255
Draw a border. B: bottom-line, T: top-line, L: left-line, R: right-line
10) --- rotate:30
Rotate content
11) --- I file:logo.jpg x:100 y:100 w:100 h:30
Image file that included in the image directory that given by first parameter.
x,y: position
w,h: width and height
Generate Tables
Template
---
Basic
--- H separator:|
name|tel|address|age
Tanaka|03-1111-2222|Taito-ku, Tokyo|25
Suzuki|03-1111-2222|Taito-ku, Tokyo|25
Sato|03-1111-2222|Taito-ku, Tokyo|25
---
Set column size as %
--- H separator:| columnsize:20,30,40,10
name|tel|address|age
Tanaka|03-1111-2222|Taito-ku, Tokyo|25
Suzuki|03-1111-2222|Taito-ku, Tokyo|25
Sato|03-1111-2222|Taito-ku, Tokyo|25
---
Set each align Right or Center or Left
--- H separator:| columnsize:20,30,40,10 columnalign:L,C,C,R
name|tel|address|age
Tanaka|03-1111-2222|Taito-ku, Tokyo|25
Suzuki|03-1111-2222|Taito-ku, Tokyo|25
Sato|03-1111-2222|Taito-ku, Tokyo|25
--- H separator:| columnsize:20,30,40,10 columnalign:L,C,C,R marginleft:20 margintop:10
name|tel|address|age
Tanaka|03-1111-2222|Taito-ku, Tokyo|25
Suzuki|03-1111-2222|Taito-ku, Tokyo|25
Sato|03-1111-2222|Taito-ku, Tokyo|25
---
You can also add margin options
---
If It is over page size, The framewok add page automaticaly
--- H separator:| margintop:3
name|tel|address|age
Tanaka|03-1111-2222|Taito-ku, Tokyo|25
Suzuki|03-1111-2222|Taito-ku, Tokyo|25
Sato|03-1111-2222|Taito-ku, Tokyo|25
Tanaka|03-1111-2222|Taito-ku, Tokyo|25
Suzuki|03-1111-2222|Taito-ku, Tokyo|25
Sato|03-1111-2222|Taito-ku, Tokyo|25
Tanaka|03-1111-2222|Taito-ku, Tokyo|25
Suzuki|03-1111-2222|Taito-ku, Tokyo|25
Sato|03-1111-2222|Taito-ku, Tokyo|25
Tanaka|03-1111-2222|Taito-ku, Tokyo|25
Suzuki|03-1111-2222|Taito-ku, Tokyo|25
Sato|03-1111-2222|Taito-ku, Tokyo|25
Parameters
1) --- H separator:|
Separate cells using |
2) --- columnsize:20,30,40,10
Colum size in percentage. Here are four columns.
3) --- columnalign:L,C,C,R
Alignment of each column. The first column align left, the second column align center.
4) --- marginleft:20 margintop:10
Margins of the table in pixel