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

求助:如何用PowerShell实现PDF文档的Duplex(双面)打印

实现PDF双面打印的PowerShell解决方案

方案1:使用Adobe Acrobat命令行(需安装Acrobat)

如果系统安装了Adobe Acrobat DC/Pro,可通过其命令行参数直接指定双面打印:

# 长边装订双面打印
& "C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /t "document.pdf" "Canon LBP226dw" "" "" "duplex=longedge"

# 短边装订双面打印(可选)
& "C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Acrobat.exe" /t "document.pdf" "Canon LBP226dw" "" "" "duplex=shortedge"

参数说明:

  • /t:触发打印命令
  • document.pdf:目标PDF文件路径
  • Canon LBP226dw:你的打印机名称
  • 两个空字符串:对应打印机驱动和端口,留空让系统自动识别
  • duplex=longedge/shortedge:指定双面打印的装订方向

方案2:使用Foxit Reader命令行(需安装Foxit)

Foxit Reader支持简洁的命令行打印参数控制:

# 长边装订双面打印
& "C:\Program Files\Foxit Software\Foxit Reader\FoxitReader.exe" /p "document.pdf" /printer "Canon LBP226dw" /duplex 2

# 短边装订双面打印(可选)
& "C:\Program Files\Foxit Software\Foxit Reader\FoxitReader.exe" /p "document.pdf" /printer "Canon LBP226dw" /duplex 1

参数说明:

  • /p:触发打印操作
  • /printer:指定目标打印机
  • /duplex:设置双面模式,2=长边装订,1=短边装订,0=单面打印

方案3:使用System.Printing程序集(纯PowerShell,无需额外软件)

通过.NET的System.Printing类库直接控制打印队列和参数,无需依赖第三方阅读器:

# 加载必要程序集
Add-Type -AssemblyName System.Printing

# 配置参数
$printerName = "Canon LBP226dw"
$pdfFilePath = "C:\path\to\document.pdf"

# 获取目标打印机队列
$printServer = New-Object System.Printing.PrintServer
$printQueue = New-Object System.Printing.PrintQueue($printServer, $printerName)

# 修改打印票证,启用长边双面打印
$printTicket = $printQueue.DefaultPrintTicket
$printTicket.Duplexing = [System.Printing.Duplexing]::TwoSidedLongEdge
# 若需短边双面,替换为:[System.Printing.Duplexing]::TwoSidedShortEdge

# 提交打印作业
$printJob = $printQueue.AddJob("PDF双面打印任务", $pdfFilePath, $false)
$printJob.JobTicket = $printTicket
$printJob.Submit()

# 释放资源
$printQueue.Dispose()
$printServer.Dispose()

注意:此方法依赖Windows系统对PDF的原生打印支持,需确保默认PDF阅读器支持通过打印队列提交作业。


内容的提问来源于stack exchange,提问作者Học Lệ

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.27 08:47:40