Created
March 23, 2017 02:49
-
-
Save beepony/2379c18399e116c1b8ed0013f08e45d8 to your computer and use it in GitHub Desktop.
使用 Ruby 把 HTML 转成 PDF 输出
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/ruby -w | |
# test html to pdf lib | |
require 'pdfkit' | |
# 从 URL 转换成 PDF | |
kit = PDFKit.new('https://techs.b0.upaiyun.com/article/%E9%98%BF%E9%87%8C%E4%BA%91%E5%AE%89%E5%85%A8%E7%BB%84%E5%92%8C%E4%BA%91%E7%9B%BE%E8%AE%BE%E7%BD%AE.html') | |
# 从本地 HTML 文件转换成 PDF | |
kit = PDFKit.new(File.new('./pdf.html')) | |
# 以文件的方式输出 | |
file = kit.to_file('./lala.pdf') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment