3

I tried to implement a custom PDF-Renderer, inherited from UIPrintPageRenderer. My problem ist that the output-size of the PDF is 215,9 x 279,4 mm. But the correct DIN A4 dimensions i need are 210 x 297 mm. Obviously im getting the size of a US-Letter instead of the DIN A4. How can i change it to DIN A4?

...
class PDFRenderer: UIPrintPageRenderer
{
    private let A4PageWidth : Double = 595.2
private let A4PageHeight : Double = 841.8
private let leftPadding: CGFloat = 18.0;

override init()
{
    super.init()

    let pageFrame : CGRect = CGRect(x: 0, y: 0, width: A4PageWidth, height: A4PageHeight)
...

Thank you

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Joel
  • 396
  • 1
  • 15
  • so far i understand apples Documentation, the app should switch automatically based on locale between the formats. Unfortunately this doesn't happen. – Joel Mar 13 '18 at 09:35

1 Answers1

3

I think you use the wrong rect when you calling the drawPage method for your pdfRenderer.

many examples shows something like this:

pdfRenderer.drawPage(at: i, in: UIGraphicsGetPDFContextBounds()) 

use rect for a A4 format instead of UIGraphicsGetPDFContextBounds()

e.g. CGRect.init(x: 0, y: 0, width: 595.2, height: 841.8)

Maurice Raguse
  • 4,437
  • 2
  • 29
  • 46