我期待将html文件转换为pdf格式,而不需要任何第三方实用程序。我对cupsfilter的输出不感兴趣,我也不想编写浏览器脚本。这个AppleScript/Ruby脚本使用PDFKit重新保存pdf(以解决InDesign问题)。有没有办法修改它来接受一个HTML文件作为输入?任何其他解决方案也欢迎!在Mac上将html文件转换为pdf格式
on pdf_resave(infile, outfile)
set rb to "require 'osx/cocoa'
OSX.require_framework 'PDFKit'
include OSX
raise ArgumentError, %Q[Usage: $0 <input pdf> <output pdf>] unless ARGV.length == 2
infile, outfile = ARGV
url = NSURL.fileURLWithPath(infile)
pdf = PDFDocument.alloc.initWithURL(url)
pdf.writeToFile(outfile)"
do shell script "/usr/bin/ruby -e " & rb's quoted form & " " & infile's quoted form & " " & outfile's quoted form
end pdf_resave
为什么你的输入pdf?我以为你想转换HTML? re:'ArgumentError'' – ocodo 2013-03-02 22:10:17