pdftk

How to launch a pdftk subprocess while in wsgi?

假装没事ソ 提交于 2019-12-01 16:05:52
I need to launch a pdftk process while serving a web request in Django, and wait for it to finish. My current pdftk code looks like this: proc = subprocess.Popen(["/usr/bin/pdftk", "/tmp/infile1.pdf", "/tmp/infile2.pdf", "cat", "output", "/tmp/outfile.pdf"]) proc.communicate() This works fine, as long as I'm executing under the dev server (running as user www-data ). But as soon as I switch to mod_wsgi, changing nothing else, the code hangs at proc.communicate() , and "outfile.pdf" is left as an open file handle of zero length. I've tried a several variants of the subprocess invocation (as

How to launch a pdftk subprocess while in wsgi?

限于喜欢 提交于 2019-12-01 15:03:57
问题 I need to launch a pdftk process while serving a web request in Django, and wait for it to finish. My current pdftk code looks like this: proc = subprocess.Popen(["/usr/bin/pdftk", "/tmp/infile1.pdf", "/tmp/infile2.pdf", "cat", "output", "/tmp/outfile.pdf"]) proc.communicate() This works fine, as long as I'm executing under the dev server (running as user www-data ). But as soon as I switch to mod_wsgi, changing nothing else, the code hangs at proc.communicate() , and "outfile.pdf" is left as

Pdftk form filling font resize

断了今生、忘了曾经 提交于 2019-12-01 06:19:21
问题 I'm using pdftk to fill inputs in a pdf form. I have no problem to generate a XFDF file and merge data & template, but sometimes the value is longer than the field, and the text is just cut. Is there a way to adapt the font dynamically, or something to prevent it to be cut? The PDF generation will be an important part of the appa, and i'm affraid about the risks that wrong values will be sent. What are the best pratices ? Thanks 回答1: It's not cut, it's just not shown. Text field can be

PDFTK and removing the XFA format

我们两清 提交于 2019-11-30 22:23:18
Are there any issues that can come up of removing the XFA format from a PDF form? I'm using PDFTK to fill form, and found that if forms are XFA, then PDFTK doesn't work unless I do a drop_xfa command first to create a new template form. One thing I did notice is that if I didn't do the drop_xfa, I could see the fields pre-filled on Acrobat Reader but not Acrobat Pro. Other views like Ubuntu Document Viewer, would be fine. I don't mind doing the drop_xfa but just checking is there might be issues with me doing that to forms that I am not aware of. Example: If the form is filled, and it's to be

How do you combine PDFs in ruby?

此生再无相见时 提交于 2019-11-30 02:26:58
This was asked in 2008 . Hopefully there's a better answer now. How can you combine PDFs in ruby? I'm using the pdf-stamper gem to fill out a form in a PDF. I'd like to take n PDFs, fill out a form in each of them, and save the result as an n -page document. Can you do this with a native library like prawn? Can you do this with rjb and iText? pdf-stamper is a wrapper on iText. I'd like to avoid using two libraries (i.e. pdftk and iText), if possible. As of 2013 you can use Prawn to merge pdfs. Gist: https://gist.github.com/4512859 class PdfMerger def merge(pdf_paths, destination) first_pdf

Stamp PDF file with control for position of stamp file

心已入冬 提交于 2019-11-30 02:14:11
Does anyone know about stamping PDF file to PDF file and also controls for positioning PDF file stamp? I have a file orginal.pdf and logo.pdf . I want to stamp logo.pdf file to file orginal.pdf at the top left of file original.pdf . How can it be done with Ghostscript or pdftk ? It can be done with Ghostscript plus pdftk, but it requires at least 2 different steps. AFAIK, you cannot directly control pdftk 's stamp placement. By default it puts the stamp on the center of the page, and at the same time does a 'scale-to-fit' operation. So, you have to fix your stamp first so it is placed on an

Split a PDF in two

时间秒杀一切 提交于 2019-11-29 20:50:20
How do you easily split a large PDF into two (or more) separate PDFs? Say we have foo-bar.pdf, section foo is from page 1-12 and section bar is from page 13 till the end. I want foo-bar.pdf split into foo.pdf and bar.pdf. Dennis You can use pdftk , it's a handy tool for manipulating PDF documents. sudo apt-get --yes install pdftk pdftk foo-bar.pdf cat 1-12 output foo.pdf pdftk foo-bar.pdf cat 13-end output bar.pdf You can use this method to split a PDF in N ways, or to remove pages. For example, to remove page 13: pdftk in.pdf cat 1-12 14-end output out.pdf Or use it to rotate pages and many

pdftk split pdf with multiple pages

若如初见. 提交于 2019-11-29 16:35:59
问题 with php i have to split a single pdf file with multiple pages inside it to a lot of PDF file with one page per file. I use pdftk and works fine, but every pdf created for every page is very large size. My original PDF is 7MB (with 70pages inside), the sum of every file created by splitting with pdftk is over 70MB. Someone know if there is a property to set for pdftk to have small file output? thank you 回答1: You could always specify the compress option - for example: pdftk input.pdf burst

Keep a pdf form editable after filling it with pdftk

不羁的心 提交于 2019-11-29 14:49:06
I'm using pdftk to fill a form but the output form isn't editable, when I open it on acrobat reader I'm getting an error message: "This document enabled extended features in Adobe Reader, The document has been changes since it was created and use of extended features is no longer available." is it possible to keep the document editable? No. AFAIK for a PDF to be editable in Adobe Reader it has to be digitally signed by Adobe Acrobat. Obviously manipulating a PDF with pdftk changes the PDF so the signature is no longer valid. To get rid of the Adobe digital signuture, just "cat" the signature

Weird characters when filling PDF with PDFTk

≡放荡痞女 提交于 2019-11-29 11:53:00
I'm using php with PDFTK on Ubuntu. When filling a PDF with data, I get weird characters for this letters with accents: á ó í . I'm using UTF-8 encoding: I checked with echo mb_check_encoding ($var, 'UTF-8') which outputs 1 - TRUE. Any idea what I can do? I also tried converting to ISO with utf8_decode, but still, no luck. Thanks user2829228 You're right, utf8_decode() will work for characters which can be encoded as Windows-1252 (i.e. U+0000–U+00FF). However it won't work for characters which can't be encoded in Windows-1252. You can always encode characters using UTF-16BE, though. You can do