pdfkit

Node js, piping pdfkit to a memory stream

送分小仙女□ 提交于 2020-06-09 17:11:41
问题 I am using pdfkit (https://github.com/devongovett/pdfkit) on my node server, typically creating pdf files, and then uploading them to s3. The problem is that pdfkit examples pipe the pdf doc into a node write stream, which writes the file to the disk, I followed the example and worked correctly, however my requirement now is to pipe the pdf doc to a memory stream rather than save it on the disk (I am uploading to s3 anyway). I've followed some node memory streams procedures but none of them

3个步骤教你如何用Python实现网页转PDF

自作多情 提交于 2020-04-24 02:00:12
前言 本文的文字及图片来源于网络,仅供学习、交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理。 作者:fdy PS:不管你是零基础还是有基础都可以获取到自己相对应的学习礼包!包括Python软件工具和2020最新入门到实战教程。加群695185429即可免费获取。 在用jupyter notebook写代码文档的时候,有时需要导出pdf版本,但jupyter会报错。我在想,除了网上的debug方法,还没有其他方案可以生成pdf。 度娘搜了下,很多博客推荐Python的第三方库pdfkit,可以将 网页、html文件以及字符串 生成pdf文件。 其实也有很多软件提供pdf生成服务,但这样太不python了,那下面就来试试pdfkit怎么用吧! 三步实现自动生成pdf文档: 使用pip安装pdfkit库 python版本 3.x,在命令行输入: 安装过程基本不会有啥问题,出现上面的Successfully installed pdfkit-0.6.1提示,说明安装成功了。 安装wkhtmltopdf.exe文件 注:pdfkit是基于wkhtmltopdf的python封装,所以需要安装wkhtmltopdf.exe。wkhtmltopdf是轻量级软件,非常很容易安装。 下载地址: https://wkhtmltopdf.org/downloads

Python之将Python字符串生成PDF

不羁岁月 提交于 2020-04-18 00:23:19
  笔者在今天的工作中,遇到了一个需求,那就是如何将Python字符串生成PDF。比如,需要把Python字符串‘这是测试文件’生成为PDF, 该PDF中含有文字‘这是测试文件’。   经过一番检索,笔者决定采用wkhtmltopdf这个软件,它可以将HTML转化为PDF。wkhtmltopdf的访问网址为: https://wkhtmltopdf.org/downloads.html ,读者可根据自己的系统下载对应的文件并安装。安装好wkhtmltopdf,我们再安装这个软件的Python第三方模块——pdfkit,安装方式如下: pip install pdfkit   我们再讨论如下问题: 如何将Python字符串生成PDF; 如何生成PDF中的表格; 解决PDF生成速度慢的问题。 如何将Python字符串生成PDF   该问题的解决思路还是利用将Python字符串嵌入到HTML代码中解决,注意换行需要用 <br> 标签,示例代码如下: import pdfkit # PDF中包含的文字 content = '这是一个测试文件。' + '<br>' + 'Hello from Python!' html = '<html><head><meta charset="UTF-8"></head>' \ '<body><div align="center"><p>%s</p><

FileNotFoundError: [Errno 2] No such file or directory: 'which' when using python pdfkit

有些话、适合烂在心里 提交于 2020-04-14 06:07:09
问题 I have a strange error. I try to use pdfkit to convert an HTML string to PDF, but i get a "No such file or directory: 'which'". I know that pdfkit uses wkhtmltopdf, and it tries to find this utility by using which. I have no idea what's happening. 'which' works ok and wkhtmltopdf is installed on /usr/bin/. I get the error in this line: pdf = pdfkit.from_string(html, False, options=options) and the traceback: Traceback: File "/srv/zboss-git/venv/lib/python3.5/site-packages/django/core/handlers

JavaScript pdf generation library with Unicode support

℡╲_俬逩灬. 提交于 2020-03-18 05:33:46
问题 I want to generate a pdf file using JavaScript at client side . Firstly I tried using jsPdf API . But it does not work with Unicode character like Chinese. Is there any option to enhance jspdf to support Unicode or any other library which supports Unicode . Pdfmake API says it supports Unicode but when I tried it also does not work out, I checked in there demo example placing Unicode character . I tried using pdfkit in Node.js but pdf is not getting created properly var PDFDocument = require(

适用于iPhone / iPad / iOs的快速精益PDF阅读器

你。 提交于 2020-02-26 10:06:27
最近有很多关于绘制PDF的问题。 是的,您可以使用 UIWebView 轻松渲染PDF,但这无法提供您期望从优秀PDF查看器获得的性能和功能。 您可以将PDF页面绘制 到CALayer 或 UIImage 。 Apple甚至有示例代码来展示如何 在Zoomable UIScrollview中 绘制大型PDF 但同样的问题不断出现。 UIImage方法: UIImage PDF不是光学缩放,也不是Layer方法。 CPU和内存在从 PDFcontext 限制生成 UIImages 阻止/阻止使用它来创建新缩放级别的实时渲染。 CATiledLayer方法: 有一个重要的开销(时间)将完整的PDF页面绘制到 CALayer :可以看到单个图块渲染(即使使用tileSize调整) CALayers 无法提前准备(在屏幕外呈现)。 一般来说,PDF查看器的内存也很重要。 甚至监视苹果可缩放PDF示例的内存使用情况。 在我目前的项目中,我正在开发一个PDF查看器,并在一个单独的线程中呈现页面的 UIImage (这里也是问题!)并在比例为x1时呈现它。 一旦比例> 1, CATiledLayer 渲染就会开始。 iBooks采用了类似的双重拍摄方式,就好像你滚动页面一样,你可以看到页面的低分辨率版本只有不到一秒的时间,然后出现一个清晰的版本。 我在页面的每一侧渲染2页焦点

Zoom in to specific coordinates in PDFKit using swift

房东的猫 提交于 2020-02-08 02:28:10
问题 I am using pdfkit to open pdf file in my app. I want to zoom in to specific coordinates. Let say Following is my pdf page and I want to zoom in to specific coordinates when user will click on pencil button. After clicking on pencil button it should be look like following image. I've searched a lot but couldn't find any proper solution for that. I don't want to use third party libraries to do that. 回答1: I solved this problem by using following code. let documents = pdfView.document if let page

Converting MathJax into pdf with wkhtmltopdf yields too small maths

限于喜欢 提交于 2020-01-24 18:08:05
问题 By using pdfkit-python based on wkhtmltopdf , I have managed to convert MathJax into pdf. wkhtmltopdf configuration options are the following: options = { 'quiet': '', 'javascript-delay' : '5000', 'page-size': 'A4', 'margin-top': '0.75in', 'margin-right': '0.75in', 'margin-bottom': '0.75in', 'margin-left': '0.75in', 'disable-smart-shrinking': '', 'dpi': '400', } This allows to obtain the markdown text that is large as expected, however maths do not scale accordingly. Here a snapshot of the

PDFKit iOS 11: How to change the line width of Ink annotation?

断了今生、忘了曾经 提交于 2020-01-06 12:26:52
问题 I'm drawing some ink annotations on a PDF file using PDFKit. But I can't change the width of the lines. I thought that doing: let path = UIBezierPath() path.lineWidth = 20 // important line path.move(to: originPoint) path.addLine(...) annotation.add(path) would be enough since modifying the lineWidth of a Bezier path works when drawing in Core Graphics. But here, it does not change anything, so how to change the line width of an annotation ? 回答1: Use border property of PDFAnnotation to change

WKHTMLTOPDF with pdfkit on Rails ignoring table page breaks

核能气质少年 提交于 2019-12-30 13:10:23
问题 I know there are a lot of issues with wkhtmltopdf and page breaks that date back years, but I haven't worked out a solution yet. I'm using the PDFKit gem to generate my html pages into pdfs, but I don't want the pages to break in the middle of a table row. I'm using wkhtmltopdf-binary (0.9.9.3), which looks to be the most updated version My CSS: @media print { #scores table tr td, #scores table tr th { page-break-inside: avoid !important; } table, tr, td, th, tbody, thead, tfoot { page-break