在 Ruby 中将 HTML 转换为 PDF 格式
Contents
[
Hide
]
Aspose.PDF - 将 HTML 转换为 PDF 格式
要使用 Aspose.PDF Java for Ruby 将 HTML 转换为 PDF 格式,只需调用 HtmlToPdf 模块。
Ruby 代码
# The path to the documents directory.
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
htmloptions = Rjb::import('com.aspose.pdf.HtmlLoadOptions').new(data_dir)
# Load HTML file
pdf = Rjb::import('com.aspose.pdf.Document').new(data_dir + "index.html", htmloptions)
# Save the concatenated output file (the target document)
pdf.save(data_dir + "html.pdf")
puts "Document has been converted successfully"
下载运行代码
下载 Convert HTML to PDF Format (Aspose.PDF) 来自以下列出的社交编码站点: