Skip to content

Latest commit

 

History

History
86 lines (46 loc) · 2.11 KB

tcpdf.md

File metadata and controls

86 lines (46 loc) · 2.11 KB

TCPDF

Writing

Text($x, $y, $txt) (stroke, clip)

Place a string precisely on the page

Write($h, $txt) (fill, align, newline)

Write text at the current cursor location.

WriteHtml($html) (nl, fill)

Writes HTML to the current cursor location.

Cell($w, $h, $txt) (border, newline, align, fill, link)

Print a cell with width and height at current location

Has lots of options actually, I think most other functions go through this

MultiCell($w, $h, $txt)

Same as Cell but with line breaks allowed

Misc

AddPage()

Must be called before writing

setPage(x) and lastPage()

To jump around pages

SetY(-15)

Jumps to the footer

$this->getAliasNumPage() . '/' . $this->getAliasNbPages()

x/x pages

$this->Ln(2);

Line break

$this->SetFont($name, $style, $size);

$this->SetTextColor($r, $g, $b);

Images

Remember the units for everything are in mm

When pulling in images, try to get them at 300DPI, otherwise they turn out horrible.

Also, save everything as jpeg yourself. If you use a gif, or anything else, it will be converted to jpeg and it sometimes does a shoddy job.

The documents are 72DPI by default, so the images will appear bigger than they should. You need to give it the width and height (in mm) and it will scale the 300DPI into a good looking image.

$this->Image('location.jpg', x, y, width, height);

Gotchas

TCPDF is fairly buggy. The code is messy too making it hard to fix yourself.

Doing a SetFontSize(xx), writing to HTML, and repeating with a different font size, the line breaks will stuff up on the second time.

Tried lots of things, but the only thing I found that worked was to use the in the HTML instead of SetFontSize

Scrap that - this eventually shows detection issues with how long a string was.

Turns out doing a SetFontSize back to the original size after writing fixes this problem.

Floats do not work!

Here is a list of html elements it supports:

h1, h2, h3, h4, h5, h6, b, u, i, a, img, p, br, strong, em, font, blockquote, li, ul, ol, hr, td, th, tr, table, sup, sub, small