2012-03-04 27 views

回答

1

由於這個SO Post

PDFKit.configure do |config| 
    config.wkhtmltopdf = `which wkhtmltopdf`.to_s.strip 
    config.default_options = { 
    :encoding=>"UTF-8", 
    :page_size=>"A4", #or "Letter" or whatever needed 
    :margin_top=>"0.25in", 
    :margin_right=>"1in", 
    :margin_bottom=>"0.25in", 
    :margin_left=>"1in", 
    :disable_smart_shrinking=>false 
    } 
end 

您可以更改:page_size變量,無論你需要的。

1

在初始化程序中指定page_widthpage_height

PDFKit.configure do |config| 
    config.default_options = { 
    :page_width => '169.33', 
    :page_height => '95.25' 
    } 
end 

page_widthpage_height在您的代碼中。

kit = PDFKit.new(html, page_width: '169.33', page_height: '95.25') 

值是以毫米爲單位,感謝j.avi分享this solution

0

這工作對我來說:

var doc = new PDFDocument({ 
    size: [240, 320] 
});