This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Is there a way to specify pdf page width & height (landscape vs. portrait) in the html?

nutrislice wrote on 2012-08-07:
I realize I can do this with the server using the setPageWidth and setPageHeight functions. However, the server will dynamically select either a portrait or a landscape HTML template at the pre-pdf html url based on various data. Is there any way to force the PDF page size to be either portrait or landscape (8.5 x 11") inside the HTML? That way it will just happen automatically based on the template that is selected.

The alternative is to process the data twice, once in my view that triggers the PDFCrowd API call to determine landscape vs. portrait so I can set the size, and again when PDFCrowd API hits my url to get the html for the PDF to select the template. This seems unnecessarily inefficient if it can be done with HTML.


support wrote on 2012-08-07:

it is not possible to define the page size with HTML. However, if I understand correctly it should be possible to process the data only once. I would go about it like this:

In the view that triggers the API:
1/ determine landscape/portrait
2/ call setPageWidth() and setPageHeight() accordingly
3/ add the orientation field to the /pre-pdf/ url, e.g. convertURI("your.domain/pre-pdf/?orientaton=landscape")

In the /pre-pdf/ view just use the template based on the value of the orientation field.

Hope this helps.
nutrislice wrote on 2012-08-07:
Thanks. that helps!