Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDFKIT IOS 11 A4 Size to Save Swift

I have one PDF Kit I want to save the File in A4 Size

here is my code

let newPagetxt = PDFPage(image:image!)

let apdf = PDFDocument()
apdf.insert(newPagetxt!, at:index)

apdf.documentAttributes!["Title"] =  sampleFilenameTitle
apdf.documentAttributes!["Author"] = sampleFilenameAuthre
apdf.write(to: destination)

how can to set te size in A4 with one Standard Class

like image 499
code is my life Avatar asked Mar 11 '18 20:03

code is my life


1 Answers

In one of my projects, I used this way.

  if let pdfPage = PDFPage(image: image) {

     let page = CGRect(x: 0, y: 0, width: 595.2, height: 841.8) // A4, 72 dpi
     pdfPage.setBounds(page, for: PDFDisplayBox.artBox)

     let pdfDoc = PDFDocument()
     pdfDoc.insert(pdfPage, at: 0)
     // Some code to save the doc...
  }
like image 153
Tim S Avatar answered Nov 08 '22 23:11

Tim S