You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Swift iOS开发:如何将打印纸张格式从Letter改为A4?

修改打印代码为A4纸张格式

你只需要在配置UIPrintInfo的代码中添加一行指定纸张尺寸的代码,就能将默认的Letter格式改为A4。

修改后的完整代码如下:

let printInfo = UIPrintInfo(dictionary: nil)
printInfo.outputType = UIPrintInfo.OutputType.general
printInfo.jobName = "Title"
// 新增此行设置A4纸张格式
printInfo.paperSize = .a4
let printController = UIPrintInteractionController.shared
printController.printInfo = printInfo
printController.printingItem = myItem
printController.present(animated: true, completionHandler: nil)

说明

UIPrintInfo的paperSize属性用于定义打印作业的纸张规格,.a4是系统提供的标准A4纸型枚举值,设置后打印控制器会默认采用A4格式,替代原本默认的Letter纸型。

内容的提问来源于stack exchange,提问作者Stéphane

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 10:01:16