How to create a PDF report in landscape mode
There is no landscape flag. A landscape page is one whose width exceeds its height, so you
swap the two elements of a PageSize.
c := creator.New()
// A4 rotated: width and height swapped.
c.SetPageSize(creator.PageSize{creator.PageSizeA4[1], creator.PageSizeA4[0]})
c.SetPageMargins(50, 50, 100, 70)PageSize is a [2]float64 of width and height in points. PageSizeA3, PageSizeA4,
PageSizeA5, PageSizeLetter and PageSizeLegal are all declared portrait, so indexing
[1] then [0] gives you the rotated form without hard-coding numbers. For a size with no
constant, build one from creator.PPMM or creator.PPI.
SetPageSize resets all four margins to 10% of the new page width, so it has to come
before SetPageMargins or your margins are silently replaced. It also only affects pages
created after the call; pages already added keep the size they had.
Anything positioned in absolute coordinates has to move with the page. Rotated A4 is about 842 points wide instead of 595, so a footer paragraph pinned near the right edge needs a different x. Tables and images sized to the content width adjust themselves.
Refer to our guide for creating landscape report.