Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Formats > PDF

Notices

Reply
 
Thread Tools Search this Thread
Old 02-06-2010, 03:26 PM   #1
SpyKiIIer
Member
SpyKiIIer began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Jan 2010
Location: Ontario, Canada
Device: Sony PRS-600
Cropping Multiple Files

Hi all,

I have a bunch of PDF ebooks, with stuff (text or images) in the borders which I want to remove before putting them onto my ereader. I had been opening them in Adobe Pro, and cropping them, but the text/images are still there when I open it on my ereader. So I am wondering if anyone knows of a good tool which can crop multiple files at once (the text/images are all in the exact same place on all the files), and either save them as a pdf, or as epub.

Thanks!!!
SpyKiIIer is offline   Reply With Quote
Old 02-06-2010, 06:53 PM   #2
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
The pdfmanipulate command line program that comes with calibre, used inside a batch file, can do this. If you need more info, post here but be sure to indicate which operating system you are using.
frabjous is offline   Reply With Quote
Old 02-07-2010, 03:15 PM   #3
SpyKiIIer
Member
SpyKiIIer began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Jan 2010
Location: Ontario, Canada
Device: Sony PRS-600
More information as to how to make the batch file would be great. I am currently running windows 7 Pro.

Thanks!
SpyKiIIer is offline   Reply With Quote
Old 02-07-2010, 05:59 PM   #4
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
Unfortunately, I only have both Windows and calibre installed on my office computer, which I won't have access to until Tuesday. (Just linux at home!) However, I believe the process would be something like the following.

After installing calibre, paste the following into Notepad

Code:
for %%I in (*.pdf) do "C:\Program Files (x86)\Calibre2\pdfmanipulate.exe" crop -o "%%~nI-cropped.pdf" -x 100 -y 100 -w 100 -v 100  "%%I"
You'll probably want to make changes to this. First double check that the path to pdfmanipulate.exe is right, and that the case is right. If you're running 32 bit Win 7 rather than 64 bit, you might need to eliminate the (x86) part. Also, the numbers

-x 100 -y 100 -v 100 -w 100

indicate how many pixels to crop from the left, bottom, right and top, respectively. (I hope that's right... it might not be.) Change from 100 to whatever it needs to be. (Unfortunately I don't know the conversion from pixels to cm or inches offhand.) You might need to run it to test it a few times to get it right.

Save the file as something ending in .bat that you'll remember (batchcrop.bat or similar) in the folder where you have the PDFs you want to crop. Navigate to that folder in Windows Explorer or My Computer and double click the batch file. It'll then create cropped versions of all the PDFs in that folder. The new versions will be named filename-cropped.pdf and so on. (You can change that by editing what I have after -o above.)

That's my best guess at the moment. If I get a chance on Tuesday, I'll double check this, or maybe someone else who has access to both Windows and calibre can help.

Or you could ask in the calibre forum.

Last edited by frabjous; 02-07-2010 at 06:02 PM.
frabjous is offline   Reply With Quote
Old 02-10-2010, 11:20 AM   #5
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
OK, I was able to test the above now, and it works for me at least. Have you tried it?
frabjous is offline   Reply With Quote
Old 02-15-2010, 01:49 PM   #6
SpyKiIIer
Member
SpyKiIIer began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Jan 2010
Location: Ontario, Canada
Device: Sony PRS-600
THANK YOU!!!

I just tried out the batch line you gave, and it worked really well. I used the following numbers to remove the unnecessary text/images, and also cut the unneeded whitespace down as well. It works really fast. Thanks again!

Quote:
for %%I in (*.pdf) do "C:\Program Files\Calibre2\pdfmanipulate.exe" crop -o "%%~nI-cropped.pdf" -x 80 -y 70 -w 70 -v 80 "%%I"
SpyKiIIer is offline   Reply With Quote
Old 02-15-2010, 02:08 PM   #7
slex
Addict
slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.
 
Posts: 280
Karma: 1125790
Join Date: Nov 2008
Location: Bulgaria
Device: Kindle 4 NT, Onyx Boox M92
Is it a problem to post the command for Ubuntu?
slex is offline   Reply With Quote
Old 02-15-2010, 04:45 PM   #8
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
Not at all. It's similar, slightly simpler really. Open a terminal and navigate to the folder with your PDFs and type in:

Quote:
for i in *.pdf ; do pdfmanipulate crop -o "${i%.pdf}-cropped.pdf" -x 80 -y 70 -w 70 -v 80 "$i" ; done
Change the values for -x -y -w and -v as desired.

Last edited by frabjous; 02-15-2010 at 04:55 PM.
frabjous is offline   Reply With Quote
Old 02-15-2010, 05:05 PM   #9
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
But actually, on Ubuntu, here's a cool alternative. Rather than setting the x, y, w and v values manually, you can have ghostscript analyze the pages and determine where they should be cropped:

Quote:
for i in *.pdf ; do gs -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox "$i" 2> bounding ; pdfmanipulate crop -o "${i%.pdf}-cropped.pdf" -b bounding "$i"; done
I didn't suggest that for SpyKiller, since (s)he wanted to crop some non-empty parts of the page (decorative border), and this will leave them, but it's cool for other purposes.

Probably you can do that with Windows too, but I don't really have experience with ghostscript for Windows.

Last edited by frabjous; 02-15-2010 at 05:18 PM.
frabjous is offline   Reply With Quote
Old 02-15-2010, 11:41 PM   #10
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
Quote:
Probably you can do that with Windows too, but I don't really have experience with ghostscript for Windows.
OK, it took awhile, since ghostscript works a bit different for Windows, but this seems to work.

Here's what you'd need to do.

1. Install both Calibre and Ghostscript.

2. Copy and paste the following in to Notepad.

Quote:
for %%I in (*.pdf) do (
"C:\Program Files\gs\gs8.64\bin\gswin32c.exe" -dSAFER -dNOPAUSE -sDEVICE#bbox "%%I" 2> bounding
"C:\Program Files (x86)\Calibre2\pdfmanipulate.exe" crop -o "%%~nI-cropped.pdf" -b bounding "%%I"
)
3. Double check that the paths on your computer to pdfmanipulate.exe and gswin32c.exe are right. If you're using a 32 bit version of Windows, rather than a 64 bit version of Windows, you may need to change "C:\Progam Files (x86)\..." to just "C:\Program Files\". If you're using a newer or older version of ghost script, you may need to change "gs8.64" to something else, and so on.

4. Save the file as something ending in .bat, such as "multicrop.bat", and save it in the same directory as the PDFs you want to crop.

5. Open the folder in question in Windows Explorer or "My Computer" and double click on "multicrop[.bat]", and it should crop all the PDFs in that folder automatically.

(Please back-up all files before trying this and don't blame me too much if things go awry.)

Let me know how this works for you, and if the script needs tweaking.
frabjous is offline   Reply With Quote
Old 02-17-2010, 12:30 PM   #11
slex
Addict
slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.slex ought to be getting tired of karma fortunes by now.
 
Posts: 280
Karma: 1125790
Join Date: Nov 2008
Location: Bulgaria
Device: Kindle 4 NT, Onyx Boox M92
Thanks, frabjous! It works just fine!
slex is offline   Reply With Quote
Old 05-20-2010, 04:23 PM   #12
manneokoko
Junior Member
manneokoko began at the beginning.
 
Posts: 5
Karma: 10
Join Date: May 2010
Device: none
Hello.

Ive tried this, it does not work for me. I have followed all the steps installed gost script and made the correct settings in the bat.

When i run the bat it starts working and goes thru all the pages but when it comes to the the end it just says GS> and stops.

The only new file that is created is file named bounding.

What do i do wrong?

Also, a question: does the pdf keep the links after cropped? Ive tried another croping method and by that all the links in the pdf (table of contents) was made inactive.

Thanks for your help!
manneokoko is offline   Reply With Quote
Old 09-30-2010, 11:25 PM   #13
frabjous
Wizard
frabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterfrabjous can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
frabjous's Avatar
 
Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
After four months, I'm answering your question! (Sorry for the delay, I just realized myself.)

I forgot the -dBATCH flag when posting the instructions for Windows. Try:

Quote:
for %%I in (*.pdf) do (
"C:\Program Files\gs\gs9.00\bin\gswin32c.exe" -dSAFER -dNOPAUSE -dBATCH -sDEVICE#bbox "%%I" 2> bounding
"C:\Program Files\Calibre2\pdfmanipulate.exe" crop -o "%%~nI-cropped.pdf" -b bounding "%%I"
)
(Again, double check that the paths to the executables are right, and that it's the right version of ghostscript; I've updated it to 9.00.)
frabjous is offline   Reply With Quote
Old 10-25-2012, 05:43 AM   #14
annoporci
Member
annoporci began at the beginning.
 
Posts: 19
Karma: 10
Join Date: Oct 2012
Location: Hong Kong
Device: Kindle Touch, firmware 5.1.2
pdfmanipulate gone

I have been using frabjous code in a batch file under windows for some time and with great success (combining ghostcript and pdfmanipulate). I recently updated calibre and it came to my attention that pdfmanipulate is no longer maintained and has been removed from recent releases of calibre, e.g. versions 9 and up.

You can still get pdfmanipulate from there:
http://sourceforge.net/projects/calibre/files/0.8.66/

I downloaded the portable version and removed files that are not needed (I do use calibre, but I have a more up-to-date version installed in a separate directory). I haven't been able to figure out what a minimal configuration would be yet, but this you need: pdfmanipulate.exe, pylib.zip and things inside the two directories DLLs and resources. You probably only need a small number of files from these two directories (it would be nice to know which ones, so as to package pdfmanipulate with its dependencies and nothing else).

Unless there is a superior alternative to pdfmanipulate? I find it does a great job, that's why I was keen on staying with it, but I'm not tied to it either...

EDIT: I found that I could still crop pdfs by keeping just freetype.dll, python27.dll, pywintypes27.dll (all three dlls inside the DLLs directory), and just default_tweaks.py (inside the resources directory), together with pdfmanipulate.exe and pylib.zip. It throws up harmless error messages, harmless as far as I can tell. The pylib.zip remains large at about 43MB, and presumably much can be removed from there too, but I haven't tried. So far I have reduced the directory from about 136MB to about 43MB. I would be surprised if it proved impossible to knock off about 40MB from that. But the process of removing files from pylib.zip and testing is tedious and my patience has run out.

Last edited by annoporci; 10-25-2012 at 09:57 AM. Reason: added precision
annoporci is offline   Reply With Quote
Old 10-29-2012, 12:59 AM   #15
willus
Fuzzball, the purple cat
willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.
 
willus's Avatar
 
Posts: 550
Karma: 2526455
Join Date: Jun 2011
Location: California
Device: Kindle 2, iPad
Quote:
Originally Posted by annoporci View Post
Unless there is a superior alternative to pdfmanipulate? I find it does a great job, that's why I was keen on staying with it, but I'm not tied to it either...
You might check the stickies in the PDF forum, particularly Briss.
willus is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
starting with multiple files? Alkiera Sigil 4 02-07-2011 02:03 AM
Multiple CSS Files jjm6383 Sigil 2 06-28-2010 05:44 PM
Txt files - Convert to Epub - Multiple files into one book - noob help Cernan Calibre 6 05-18-2010 10:12 AM
Multiple Calibre Files? Sydney's Mom Calibre 21 05-02-2010 10:42 AM
Multiple HTML Files JJH1947 Calibre 4 04-07-2009 10:24 AM


All times are GMT -4. The time now is 07:29 AM.


MobileRead.com is a privately owned, operated and funded community.