![]() |
#1 |
Member
![]() 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!!! |
![]() |
![]() |
![]() |
#2 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Member
![]() 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! |
![]() |
![]() |
![]() |
#4 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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" -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. |
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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?
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Member
![]() 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:
|
|
![]() |
![]() |
![]() |
#7 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 294
Karma: 1196776
Join Date: Nov 2008
Location: Bulgaria
Device: Kindle 4 NT, Onyx Boox M92
|
Is it a problem to post the command for Ubuntu?
|
![]() |
![]() |
![]() |
#8 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
Last edited by frabjous; 02-15-2010 at 04:55 PM. |
|
![]() |
![]() |
![]() |
#9 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
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. |
|
![]() |
![]() |
![]() |
#10 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,213
Karma: 12890
Join Date: Feb 2009
Location: Amherst, Massachusetts, USA
Device: Sony PRS-505
|
Quote:
Here's what you'd need to do. 1. Install both Calibre and Ghostscript. 2. Copy and paste the following in to Notepad. Quote:
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. |
||
![]() |
![]() |
![]() |
#11 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 294
Karma: 1196776
Join Date: Nov 2008
Location: Bulgaria
Device: Kindle 4 NT, Onyx Boox M92
|
Thanks, frabjous! It works just fine!
|
![]() |
![]() |
![]() |
#12 |
Junior Member
![]() 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! |
![]() |
![]() |
![]() |
#13 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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:
|
|
![]() |
![]() |
![]() |
#14 |
Enthusiast
![]() Posts: 36
Karma: 10
Join Date: Oct 2012
Location: Los Angeles
Device: Kindle Paperwhite 2019, Firmware 5.12.4
|
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 |
![]() |
![]() |
![]() |
#15 | |
Fuzzball, the purple cat
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,288
Karma: 11087488
Join Date: Jun 2011
Location: California
Device: iPad
|
Quote:
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
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 |