Does anyone have any idea how to perform command-line PDF editing?
The sort of thing I am talking about is adding text to the document maybe even editing existing text if that's possible. (The PDF will be a poster for printing, I need to change some details and return it. The quality of the PDF is therefore important and converting (say) to JPEG, adding the content, then converting back, will probably not give adequate results (unless someone knows better?)
For test purposes I have tried things like: convert test.pdf test.png convert test.png test2.pdf .. and the quality difference between test.pdf and test2.pdf is noticable (colour definition has reduced, and the image has become grainy). In fact, even: convert test.pdf test2.pdf .. gives almost identical results to the via-jpeg test, which makes me think something like that is happening anyway.
It may be that I can improve the above tests with convert if anyone has any suggestions?
On 10-Jul-08 10:22:49, Mark Rogers wrote:
Does anyone have any idea how to perform command-line PDF editing?
The sort of thing I am talking about is adding text to the document maybe even editing existing text if that's possible. (The PDF will be a poster for printing, I need to change some details and return it. The quality of the PDF is therefore important and converting (say) to JPEG, adding the content, then converting back, will probably not give adequate results (unless someone knows better?)
For test purposes I have tried things like: convert test.pdf test.png convert test.png test2.pdf .. and the quality difference between test.pdf and test2.pdf is noticable (colour definition has reduced, and the image has become grainy). In fact, even: convert test.pdf test2.pdf .. gives almost identical results to the via-jpeg test, which makes me think something like that is happening anyway.
It may be that I can improve the above tests with convert if anyone has any suggestions?
You've been converting from a vector-graphics (in principle) format to a bit-mapped format, and the loss of quality you describe is inevitable in such conversions.
I'm deducing from the above that you don't have access to PDF-editing software (such as Adobe supplies -- at cost!)
One obstacle you may face (since this is a poster) is that the PDF be itself be bit-mapped graphics (partly or even wholly). If that's the case then I think you're stuck unless you can get access to the "source code" of the PDF.
On the other hand, if the PDF was simply uses text fonts and vector graphics, then you can (in theory) export it (e.g. from Acrobat Reader) to a PostScript file -- just "print to file".
Then -- PostScript being written in ASCII -- you have a chance to edit it using a text editor. How feasible this is will depend on the complexity of the PostScript code.
If you succeed in adequately editing the POstScript, you can then convert it back to PDF using, for instance, ps2pdf (which it might be worth slightly modifying for better results). The graphics quality of the final PDF should then be as good as the original.
I've done this sort of thing a number of times, but (as I state above) the chance of success is very strongly contingent on what's in the PDF file (and therefore in the resulting PS file).
If you want some off-list discussion for this particular case, drop me a line.
Ted.
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 10-Jul-08 Time: 11:47:41 ------------------------------ XFMail ------------------------------
(Ted Harding) wrote:
You've been converting from a vector-graphics (in principle) format to a bit-mapped format, and the loss of quality you describe is inevitable in such conversions.
I'm deducing from the above that you don't have access to PDF-editing software (such as Adobe supplies -- at cost!)
It's not that I don't have the tools (I don't, though) but that I need to be able to alter them through scripts, taking a standard poster and changing/adding some text.
For example, imaging those posters outside newsagents that have a basic format but the text is changed daily to match the days headlines. I need to do that kind of thing.
One obstacle you may face (since this is a poster) is that the PDF be itself be bit-mapped graphics (partly or even wholly). If that's the case then I think you're stuck unless you can get access to the "source code" of the PDF.
Looking at the samples I have so far, which appear to have been created in Corel Draw, they're a mixture of vector and bitmap.
I've done this sort of thing a number of times, but (as I state above) the chance of success is very strongly contingent on what's in the PDF file (and therefore in the resulting PS file).
I have some control over the PDFs I start with, in as much as I can tell the designer what to do (albeit it'll have to be in words he understands and can deliver using something like Corel draw, so that might not be as helpful as it sounds).
If you want some off-list discussion for this particular case, drop me a line.
Thanks, I may do that. I'll play a bit more first, though. The offer is appreciated anyway!
(Ted Harding) Ted.Harding@manchester.ac.uk wrote:
On the other hand, if the PDF was simply uses text fonts and vector graphics, then you can (in theory) export it (e.g. from Acrobat Reader) to a PostScript file -- just "print to file".
More usefully from the command line, there's pdf2ps (from Ghostscript) and pdftops (from XPDF and maybe Poppler).
A disappointingly high number of Windows-produced PDF files are simply bitmaps in PDF wrappers. Mac-produced ones seem better, but still much larger than most GNU-produced ones. I don't understand enough PDF to know why.
Another approach is using Perl or PHP libraries to open the PDF and stick text on it, as mentioned by others, which I've done sometimes, with good results.
Good luck!
Phil Ashby wrote:
PDFedit seems to do what you want, GPL2 and in Debian (unstable, testing and etch backports).
I installed PDFEdit but had no idea it could be scripted. Thanks for that!
At Thu, 10 Jul 2008 11:22:49 +0100, Mark Rogers wrote:
Does anyone have any idea how to perform command-line PDF editing?
If you can bare to use Perl, there is PDF::Resue http://search.cpan.org/~larslund/PDF-Reuse-Tutorial-0.11/, http://www.perl.com/pub/a/2007/09/20/pdf-processing-with-perl.html. I've never used it, mind you.
I also wondered if it might be possible with ReportLab, but a quick search only returned this: http://two.pairlist.net/pipermail/reportlab-users/2006-January/thread.html#4....
Cheers, Richard
Richard Lewis wrote:
If you can bare to use Perl, there is PDF::Resue http://search.cpan.org/~larslund/PDF-Reuse-Tutorial-0.11/, http://www.perl.com/pub/a/2007/09/20/pdf-processing-with-perl.html. I've never used it, mind you.
It does look interesting, thanks for that. It's about time I learnt Perl anyway!
I'll look into this one a bit further, thanks for making me aware of it.
On Thu, 2008-07-10 at 11:22 +0100, Mark Rogers wrote:
Does anyone have any idea how to perform command-line PDF editing?
The sort of thing I am talking about is adding text to the document maybe even editing existing text if that's possible.
Is there a particular reason for doing this on the command line? Do you need to automate it? Are you doing it over screen? Does your PDP-11 not run X?
If you really want to fiddle with PDFs on the command line you should probably check out http://www.pdfhacks.com/pdftk/ . I've managed to make small edits to PDFs using pdftk and a text editor, but it's at best fiddly.
Other than that I'm pretty sure one or both of scribus and inkscape will edit PDFs.
Having said all of which, what you're asking may well just be impractical as PDFs tend to do things like break text into hundreds of individual objects or convert it to vectors, which makes significant editing nigh on impossible.
Joe
On 10-Jul-08 11:16:26, Joe Button wrote:
On Thu, 2008-07-10 at 11:22 +0100, Mark Rogers wrote:
Does anyone have any idea how to perform command-line PDF editing?
The sort of thing I am talking about is adding text to the document maybe even editing existing text if that's possible.
Is there a particular reason for doing this on the command line? Do you need to automate it? Are you doing it over screen? Does your PDP-11 not run X?
If you really want to fiddle with PDFs on the command line you should probably check out http://www.pdfhacks.com/pdftk/ . I've managed to make small edits to PDFs using pdftk and a text editor, but it's at best fiddly.
Other than that I'm pretty sure one or both of scribus and inkscape will edit PDFs.
I just tried Scribus (1.2.6, June 2006 on Debian Etch). It refused to open a PDF file, on the grounds that it was "not in Scribus format".
As to inkscape, I just had a look at http://www.inkscape.org and the documentation seems to be still in a primitive stae, so I can't tell whether it can import a PDF file, let alone edit it if it can be imported!
Ted.
Having said all of which, what you're asking may well just be impractical as PDFs tend to do things like break text into hundreds of individual objects or convert it to vectors, which makes significant editing nigh on impossible.
Joe
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 10-Jul-08 Time: 13:10:03 ------------------------------ XFMail ------------------------------
FOLLOW-UP -- See below.
On 10-Jul-08 12:10:05, Ted Harding wrote:
On 10-Jul-08 11:16:26, Joe Button wrote:
On Thu, 2008-07-10 at 11:22 +0100, Mark Rogers wrote:
Does anyone have any idea how to perform command-line PDF editing?
The sort of thing I am talking about is adding text to the document maybe even editing existing text if that's possible.
Is there a particular reason for doing this on the command line? Do you need to automate it? Are you doing it over screen? Does your PDP-11 not run X?
If you really want to fiddle with PDFs on the command line you should probably check out http://www.pdfhacks.com/pdftk/ . I've managed to make small edits to PDFs using pdftk and a text editor, but it's at best fiddly.
Other than that I'm pretty sure one or both of scribus and inkscape will edit PDFs.
I just tried Scribus (1.2.6, June 2006 on Debian Etch). It refused to open a PDF file, on the grounds that it was "not in Scribus format".
Subsequently, I noticed that there is am "Import" option in the File menu. PDF is not included, but EPS/PS is included. I imported a PS file, and it seemed to allow me do edit it.
So an option for Scribus could be to first convert the PDF to PS, and carry on from there.
PS I just saw your message, Mark, about PDFEdit. Good luck! I hope it works. If so, it may be something well worth knowing about.
Best wishes, Ted.
As to inkscape, I just had a look at http://www.inkscape.org and the documentation seems to be still in a primitive stae, so I can't tell whether it can import a PDF file, let alone edit it if it can be imported!
Ted.
Having said all of which, what you're asking may well just be impractical as PDFs tend to do things like break text into hundreds of individual objects or convert it to vectors, which makes significant editing nigh on impossible.
Joe
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
E-Mail: (Ted Harding) Ted.Harding@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 10-Jul-08 Time: 13:10:03 ------------------------------ XFMail ------------------------------
main@lists.alug.org.uk http://www.alug.org.uk/ http://lists.alug.org.uk/mailman/listinfo/main Unsubscribe? See message headers or the web site above!
-------------------------------------------------------------------- E-Mail: (Ted Harding) Ted.Harding@manchester.ac.uk Fax-to-email: +44 (0)870 094 0861 Date: 10-Jul-08 Time: 13:19:12 ------------------------------ XFMail ------------------------------
(Ted Harding) wrote:
PS I just saw your message, Mark, about PDFEdit. Good luck! I hope it works. If so, it may be something well worth knowing about.
PDFEdit looks pretty reasonable as a GUI PDF editor, I haven't investigated the scripting options yet.
At the moment I'm reading the PDF::Reuse documentation, which looks very promising (not least due to the praise it seems to get from others). And as I aluded to already I wouldn;t mind getting my head around Perl a bit, its something I have to learn one day and today might be that day.