我有一个PDF套件我想以A4尺寸保存文件
这是我的代码
let newPagetxt = PDFPage(image:image!)
apdf.insert(newPagetxt!, at:index)
let apdf = PDFDocument()
apdf.documentAttributes!["Title"] = sampleFilenameTitle
apdf.documentAttributes!["Author"] = sampleFilenameAuthre
apdf.write(to: destination)
如何使用一个标准类
在A4中设置te尺寸答案 0 :(得分:1)
在我的一个项目中,我使用了这种方式。
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...
}