Search code examples
iosuiprintpagerenderer

How to set the Legal Page size for PDF created using UIPrintPageRenderer?


I am setting this:

static CGFloat LegalPageWidth = 612.0;
static CGFloat LegalPageHeight = 1008.0;

as legal page size (i.e 8.5 x 14 inch) for PDF creation in UIPrintPageRenderer as "paperRect" but when I print the PDF its size is always A4 (i.e 612 x 792 = 8.5 x 11 inch).

What is the correct way to get Legal Page size PDF ?


Solution

  • The UIGraphicsBeginPDFPage creates the new page using the default size while the UIGraphicsBeginPDFPageWithInfo function lets you customize the page size or customize other aspects of the PDF page.

    Refer this https://developer.apple.com/library/archive/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/GeneratingPDF/GeneratingPDF.html#//apple_ref/doc/uid/TP40010156-CH10-SW3