Ruby에서 HTML을 PDF 형식으로 변환

Aspose.PDF - HTML을 PDF 형식으로 변환

Aspose.PDF Java for Ruby를 사용하여 HTML을 PDF 형식으로 변환하려면 HtmlToPdf 모듈을 호출하기만 하면 됩니다.

루비 코드

# 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"

실행 코드 다운로드

아래에 언급된 소셜 코딩 사이트 중 하나에서 **HTML을 PDF 형식으로 변환(Aspose.PDF)**В을 다운로드하세요.