繁体   English   中英

PDFKIT IOS 11 A4 大小以保存 Swift

[英]PDFKIT IOS 11 A4 Size to Save Swift

我有一个 PDF 套件,我想将文件保存为 A4 大小

这是我的代码

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)

如何使用一个标准类在 A4 中设置尺寸

在我的一个项目中,我使用了这种方式。

  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...
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM