Welcome Guest.   Make a donation to an author on the site September 01, 2014, 08:41:34 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Read the full one-year retrospective report on DonationCoder.com.
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: command line tool for pdf  (Read 1142 times)
kalos
Member
**
Posts: 999

View Profile Give some DonationCredits to this forum member
« on: November 26, 2011, 08:02:36 AM »

hello!

I am looking for a command line tool that will:

1) place a specific image (logo) at a specific resolution/size, at a specific place in pdf pages (according to the top left corner, etc)
2) extract all the text of pdf pages (and save it in a variable or a file)
3) search and replace specific text in pdf pages (optimally using regex)
4) crop and save the cropped area or delete the cropped area of pdf pages

do you know any??

thanks!
Logged
rjbull
Charter Member
***
Posts: 2,748

View Profile Give some DonationCredits to this forum member
« Reply #1 on: November 26, 2011, 01:37:36 PM »

2) extract all the text of pdf pages (and save it in a variable or a file)
XPDF.  Freeware.
3) search and replace specific text in pdf pages (optimally using regex)
PDF Text Replace Tool.  It isn't command-line, but it's the only one I know that can do that.  Freeware and more advanced payware editions.
Logged
Shades
Member
**
Posts: 1,638


see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #2 on: November 27, 2011, 07:05:44 AM »

It is highly improbable that you will find such a (commandline) tool. However, there are tools partially do what you request.

Likely you have an original PDF and you want to create a new PDF using your logo and (most of) the content from the original PDF.
In that case it might be smarter to rethink the order in which you want to do things.

01.) It would be better to first extract the content from the original PDF to file(s) in a separate folder: 
     http://pdftohtml.sourceforge.net/
02.) Again using a different (sub-)folder to strip the html content, leaving you with text file(s) only:
     http://kmachine.home.xs4all.nl/html2txt.htm
03.) Use a graphical editor in cli mode to resize/crop and save graphical content from step 1:
     http://gd.tuwien.ac.at/graphics/xv/html-docu/command-line-options.html
04.) Using a text editor in cli mode to store the differences between HTML content and the stripped text (to retain a simple HTML layout):
     http://sed.sourceforge.net/ (this appears to be the most capable text editor for command line operations)
05.) Using a text editor in cli mode to replace desired specific content inside the stripped text:
     http://sed.sourceforge.net/
06.) Using a text editor in cli mode to store the content from step 4 into a previously created HTML template (with your positioned logo):
     http://sed.sourceforge.net/
07.) Using a text editor in cli mode to store the content from step 5 into a previously created HTML template (with your positioned logo):
     http://sed.sourceforge.net/
08.) Using a text editor in cli mode to store the content from step 7 in a different (sub-)folder as HTML file(s):
     http://sed.sourceforge.net/
09.) Convert the HTML file(s) to PDF:
     http://code.google.com/p/anytopdf/ - uses the OpenOffice/LibreOffice (portable version) PDF conversion capabilities (which are awesome in my point of view)
10.) Cleanup the mess created during the conversion process from your hard drive:
     Use a BATCH script or something similar

All the above is great on simple PDF's, if you have to use complicated PDF's (heavy on layout) you will have to do things manually as preserving the layout will be practically impossible when automatizing.

Have fun puzzling with the command line options of each and every tool...
Logged
kalos
Member
**
Posts: 999

View Profile Give some DonationCredits to this forum member
« Reply #3 on: November 30, 2011, 03:39:32 PM »

thanks for your reply, but that would be overkill for my task, eg. to monitor a folder named "logo them all" and when a pdf is pasted or created in that folder, to automatically add a graphics file to each page

any script or program that performs actions to pdf files, like those I mention at the first post?

Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.037s | Server load: 0.11 ]