Rails 2,PDFkit 0.5.0
我使用PDFkit从Rails 2中的View生成PDF,一切正常.唯一不起作用的是在pdf中显示图片.
当我在浏览器中查看视图时,图片就在那里,但在PDF中丢失了.PDF中只存在占位符.
image_tag看起来像这样:
<%= image_tag('plus.gif') %>
Run Code Online (Sandbox Code Playgroud)
我也尝试用css文件实现它,但它也不起作用.
有任何想法吗?
我可以很好地将HTML页面转换为PDF文档.问题是,我不知道如何将HTML文件转换为横向PDF.有没有办法在控制器中设置它?
从控制器......
def pdf_customer_shipments
@customer = Customer.find(params[:id])
@shipments = Shipment.where("customer_id = ? AND status = 'Open'", @customer.id)
render :layout => 'pdf'
end
Run Code Online (Sandbox Code Playgroud) 当我生成pdf时,我正在使用pdfkit生成pdf,它给了我以下错误.
command failed: "/usr/bin/wkhtmltopdf" "--page-size" "Letter"
"--margin-top" "0.75in" "--margin-right" "0.75in" "--margin-bottom"
"0.75in" "--margin-left" "0.75in" "--encoding" "UTF-8" "--print-media-type"
"--quiet" "-" "-"
Run Code Online (Sandbox Code Playgroud)
有帮助吗?
我已成功将PDFKit实现到我的Rails应用程序中.但我的应用程序主要是客户端.我有很多javascript小部件,所有这些小部件加载大约需要3秒钟.当我生成pdf时,我可以看到一些小部件已经加载,一些小部件正在加载,而其他小部件根本没有加载.
有办法解决这个问题吗?它不一定太花哨.如果我可以将PDF生成延迟5秒,直到页面加载完毕,那很好.
我正在使用PDFKit作为应用程序.我只是在浏览器的HTML文件中使用它,使用Javascript(没有Node.js).
我从GitHub下载了PDFKit:https://github.com/devongovett/pdfkit/releases
以及Blob Stream:https://github.com/devongovett/blob-stream
我试图按照文档包含自定义字体,如下所示:
doc.registerFont('Custom Font', 'fonts/GOODDP__.TTF');
doc.font('Custom Font').fontSize(fontSize).text($("#text1").val(), xPos, yPos, configObj);
Run Code Online (Sandbox Code Playgroud)
但我总是得到这个错误:
fs.readFileSync is not a function
Run Code Online (Sandbox Code Playgroud)
这是有道理的,因为它fs.readFileSync是node.js的一部分,我没有使用它.但是,文档中的示例说这可以在浏览器中使用.
我知道还有一个Browserify选项,但我不确定在这种情况下如何或如果有帮助
我正在使用pdfkit Python库将html页面转换为pdf。
我正在做的就是使用命令:
pdfkit.from_file('mypage.html', 'output.pdf')
Run Code Online (Sandbox Code Playgroud)
问题是我获得了多页pdf,而我希望将所有内容都放在一页上。如何强制pdfkit缩小/缩放网页以适合常规A4页面?该网页是本地保存在我的PC上的,因此,如果需要,我也可以使用html进行操作。有没有一种方法可以立即“重新缩放”网页?
谢谢!
我正在使用pdfkit从html字符串生成pdf,由我的Django视图呈现.
出于某种原因,输出pdf很小.我的pdfkit选项字典是 -
options = {
'quiet': '',
'page-size': 'A4',
'margin-top': '0.75in',
'margin-right': '0.75in',
'margin-bottom': '0.75in',
'margin-left': '0.75in',
'disable-smart-shrinking': ''
}
Run Code Online (Sandbox Code Playgroud)
输出文件在这里
Html代码是 -
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="pdfkit-orientation" content="Portrait"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>Dribble</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
<!-- Google Font -->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,700,800" rel="stylesheet"> …Run Code Online (Sandbox Code Playgroud) 我正在尝试在iOS上使用PDFKit为文档添加高亮注释.
let highlight = PDFAnnotation(bounds: selection.bounds(for: page),
forType: PDFAnnotationSubtype.highlight,
withProperties: nil)
highlight.color = color
page.addAnnotation(highlight)
page.displaysAnnotations = true
Run Code Online (Sandbox Code Playgroud)
使用上面的代码添加它们时,它们显示为两个不同形状的图层.将它们保存到PDF文件并重新打开时,它们会正确显示.
使用此处提供的代码段以相同的方式添加了顶部和底部突出显示.最上面的一个已保存到pdf文档中,并在重新打开时显示为预期,最后一个刚刚添加.
有没有人知道如何正确显示它们(即像顶部一样)而无需保存并重新打开文件?
我正在尝试移动我使用webview的项目向pdfView显示一些pdf以利用最新的PDFKit功能.
在webview中,当缩小文档时,文档总是缩放以填充屏幕.基本上你不能缩小它弹回来填充屏幕的页面.
现在使用pdfView,我可以通过捏合缩小它看起来并不好看,没有必要让pdf页面小于屏幕......
一旦将手指从屏幕上松开,有没有办法激活自动缩放.我知道有手势功能,但我不熟悉它的使用.
显示PDFDocument在一个PDFView允许用户选择文档的一部分,并与选择执行的操作,例如“复制”。如何在PDFView中禁用选择,同时保留用户放大和缩小以及滚动PDF的可能性?
PDFView本身似乎不提供这样的属性,也不提供PDFViewDelegate。
pdfkit ×10
ios ×3
html ×2
javascript ×2
pdf ×2
pdfview ×2
ruby ×2
swift ×2
wkhtmltopdf ×2
converter ×1
django ×1
formatting ×1
node.js ×1
python ×1
zooming ×1