TCPDF page rotation

James picture James · Mar 30, 2011 · Viewed 32.8k times · Source

I'm trying to generate a PDF file containing labels which are 202mm wide by 50mm heigh. I have managed to do this and added the required text and a barcode but my problem is that the labels print out narrow edge first so the whole page need rotating 90 degrees.

I can do this in Adobe Reader with ease by simple right clicking on the page and selecting Rotate Clockwise (Shift+Ctrl++) but I really need to do it in the code.

Does anyone know how to do this with TCPDF? I have tried the Rotate function but can't seem to get it working. Any examples of code would be helpful.

Answer

LawrenceGS picture LawrenceGS · May 23, 2011

How about setting it to landscape when building the page?

TCPDF::__construct($orientation = 'L',
$   unit = 'mm',
$   format = 'A4',
$   unicode = true,
$   encoding = 'UTF-8',
$   diskcache = false)

$orientation (string) page orientation. Possible values are (case insensitive):

  • P or Portrait (default)
  • L or Landscape
  • '' (empty string) for automatic orientation

http://www.tcpdf.org/doc/classTCPDF.html#a5420ac8b0726a604260780d8f4185fc1