cod*_*ife 5 pdfkit ios swift swift4 ios11
我有一个 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)
Run Code Online (Sandbox Code Playgroud)
如何使用一个标准类在 A4 中设置尺寸
小智 7
在我的一个项目中,我使用了这种方式。
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...
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1414 次 |
| 最近记录: |