Tuesday, August 5, 2008

Quickie PDF generator

 

Share this post :

I browse the Internet for beautiful and inspiring images and I am sure many people do the same. I usually have folders categorized with appropriate names where I can go and browse those images at a later stage. But, if you keep downloading images every day, you will reach a point where the numbers become unmanageable. Yes there are various tools to keep your Image folders well organized. But, then, there is a job of backing up your favorite images too. As the numbers grow, not only it becomes to difficult to organize, it takes it's toll on the speed of your PC. Too much defragmentation etc...

I usually, convert individual folders in to PDF files, so it reduces the number of files on the disk and I can add tags and key words to the PDF file and it helps me organize the images in nice booklets.

You can convert images to PDF collection without a commercial PDF tools or PDF printers installed on your system. You can accomplish this using Cygwin on windows PC.

You need:

ImageMagick provides a set of tools for image manipulation from the command line. One important and basic functionality of ImageMagick is its format conversion function. And Cygwin provides the Linux/Unix type environment under Windows.

Convert (convert.exe) is one of the few tools which comes with ImageMagick, and we can convert all the Images under a folder by calling:

convert *.jpg PDF_FileName.pdf

I have been able to open The generated PDF file using Adobe Reader without any problem. But, Sumatra PDF reader had problem, it crashed when I launched from the Windows Explorer. But when I opened the generated PDF by dropping in to Sumatra PDF Reader's window, it could render few of the pages, and then it crashed.

So, here is the warning/rider. I have not investigated the PDF file generated completely. It may not have the correct PDF document structure, Adobe Reader is able to handle without any problem. But, be careful if you are using any other PDF readers, before you delete your original images.

OK Here is a Quick Update on the converted PDF having problems with Sumatra PDF Reader:

I used the Cygwin tool pdf2dsc, an application which analyses the PDF file and produces a text file with description of the pages contained the PDF. I found that some of the pages had unrealistically large bounding box dimensions, which I believe has come from the EXIF data of the original images used with ImageMagick. Hence, the PDF viewer like Sumatra was unable to render such huge pages. Where as, Adobe Reader 9 was rendering such a page, as white page (without any Image). 

At the end of this POST, I have pasted the pdf2dsc output, you can check it out. Few pages have those huge bounding box dimensions.

I could generate documents without hitting problems with Sumatra PDF reader too. Of course all of those JPG files were from my Nokia e90, and I am sure, the EXIF information was not screwed up as was the case when I tried generating the PDF file first time. It happened

That's all it is there to convert images files into PDF files. In case you want to convert the images to Individual PDF files or EPS or PS file format, then the following few lines of BASH script does that for you.

 

for I in *.jpg
do
convert $I $I.pdf
echo "Converted $I to $I.pdf"
done



 




Quote of the Day:


I not only use all the brains I have but all that I can borrow.


--Thomas Woodrow Wilson




the output of pdf2dsc for the offending PDF file (offending to Sumatra PDF reader, that is)



%!PS-Adobe-3.0

%%Title: (test.pdf)


%%CreationDate: (D:20080805110425)


%%DocumentMedia: y880x600 600 880 70 white ()


%%+ y856x600 600 856 70 white ()


%%+ y767x777 777 767 70 white ()


%%+ y1379x357 357 1379 70 white ()


%%+ y1209x600 600 1209 70 white ()


%%+ y1811x600 600 1811 70 white ()


%%+ y979x600 600 979 70 white ()


%%+ y1891x600 600 1891 70 white ()


%%+ y980x600 600 980 70 white ()


%%+ y800x600 600 800 70 white ()


%%+ y1024x760 760 1024 70 white ()


%%+ y1732x600 600 1732 70 white ()


%%+ y450x600 600 450 70 white ()


%%+ y825x600 600 825 70 white ()


%%+ y975x600 600 975 70 white ()


%%+ y600x800 800 600 70 white ()


%%+ y1433x1156 1156 1433 70 white ()


%%+ y1594x600 600 1594 70 white ()


%%+ y500x375 375 500 70 white ()


%%+ y887x600 600 887 70 white ()


%%+ y1535x600 600 1535 70 white ()


%%+ y785x600 600 785 70 white ()


%%+ y797x600 600 797 70 white ()


%%+ y1742x600 600 1742 70 white ()


%%+ y1562x600 600 1562 70 white ()


%%+ y1859x600 600 1859 70 white ()


%%+ y1615x582 582 1615 70 white ()


%%+ y992x600 600 992 70 white ()


%%+ y625x281 281 625 70 white ()


%%+ y2664x828 828 2664 70 white ()


%%+ y375x484 484 375 70 white ()


%%+ y3168x870 870 3168 70 white ()


%%+ y3324x654 654 3324 70 white ()


%%+ y538x600 600 538 70 white ()


%%+ y710x784 784 710 70 white ()


%%+ y1628x766 766 1628 70 white ()


%%+ y910x600 600 910 70 white ()


%%+ y873x600 600 873 70 white ()


%%+ y762x778 778 762 70 white ()


%%+ y3210x804 804 3210 70 white ()


%%+ y665x600 600 665 70 white ()


%%+ y538x420 420 538 70 white ()


%%+ y3132x678 678 3132 70 white ()


%%+ y717x492 492 717 70 white ()


%%+ y536x600 600 536 70 white ()


%%+ y1024x585 585 1024 70 white ()


%%+ y1483x600 600 1483 70 white ()


%%+ y1566x600 600 1566 70 white ()


%%+ y1429x600 600 1429 70 white ()


%%+ y1026x600 600 1026 70 white ()


%%+ y1200x1792 1792 1200 70 white ()


%%+ y1158x600 600 1158 70 white ()


%%+ y742x600 600 742 70 white ()


%%+ y1110x600 600 1110 70 white ()


%%+ y3222x666 666 3222 70 white ()


%%+ y953x600 600 953 70 white ()


%%+ y778x600 600 778 70 white ()


%%+ y865x600 600 865 70 white ()


%%+ y228x600 600 228 70 white ()


%%+ y852x600 600 852 70 white ()


%%+ y1351x600 600 1351 70 white ()


%%+ y1084x600 600 1084 70 white ()


%%+ y1385x817 817 1385 70 white ()


%%+ y1683x495 495 1683 70 white ()


%%+ y1694x680 680 1694 70 white ()


%%+ y871x600 600 871 70 white ()


%%+ y1347x835 835 1347 70 white ()


%%+ y1540x537 537 1540 70 white ()


%%+ y675x1080 1080 675 70 white ()


%%+ y1024x519 519 1024 70 white ()


%%+ y1663x600 600 1663 70 white ()


%%+ y1623x576 576 1623 70 white ()


%%+ y1024x723 723 1024 70 white ()


%%+ y1000x808 808 1000 70 white ()


%%+ y799x600 600 799 70 white ()


%%+ y500x370 370 500 70 white ()


%%+ y1200x2036 2036 1200 70 white ()


%%+ y1458x552 552 1458 70 white ()


%%+ y1595x579 579 1595 70 white ()


%%+ y696x600 600 696 70 white ()


%%+ y891x600 600 891 70 white ()


%%+ y2008x600 600 2008 70 white ()


%%+ y774x600 600 774 70 white ()


%%+ y500x321 321 500 70 white ()


%%+ y860x600 600 860 70 white ()


%%+ y2146x600 600 2146 70 white ()


%%+ y3144x708 708 3144 70 white ()


%%Pages: 92


%%EndComments


%%BeginProlog


/Page null def


/Page# 0 def


/PDFSave null def


/DSCPageCount 0 def


/DoPDFPage {dup /Page# exch store pdfgetpage pdfshowpage } def


GS_PDF_ProcSet begin


pdfdict begin


%%EndProlog


%%BeginSetup


(fashion_05082008_001.pdf) (r) file { DELAYSAFER { .setsafe } if } stopped pop


pdfopen begin


copy_trailer_attrs


%%EndSetup


%%Page: 1 1


%%PageMedia: y1859x600


%%PageBoundingBox: 0 0 144 446


1 DoPDFPage


%%Page: 2 2


%%PageMedia: y1594x600


%%PageBoundingBox: 0 0 144 383


2 DoPDFPage


%%Page: 3 3


%%PageMedia: y1110x600


%%PageBoundingBox: 0 0 144 266


3 DoPDFPage


%%Page: 4 4


%%PageMedia: y873x600


%%PageBoundingBox: 0 0 450 655


4 DoPDFPage


%%Page: 5 5


%%PageMedia: y1615x582


%%PageBoundingBox: 0 0 4022784 11162880


5 DoPDFPage


%%Page: 6 6


%%PageMedia: y3222x666


%%PageBoundingBox: 0 0 500 2417


6 DoPDFPage


%%Page: 7 7


%%PageMedia: y3324x654


%%PageBoundingBox: 0 0 157 798


7 DoPDFPage


%%Page: 8 8


%%PageMedia: y891x600


%%PageBoundingBox: 0 0 288 428


8 DoPDFPage


%%Page: 9 9


%%PageMedia: y3168x870


%%PageBoundingBox: 0 0 209 760


9 DoPDFPage


%%Page: 10 10


%%PageMedia: y2008x600


%%PageBoundingBox: 0 0 144 482


10 DoPDFPage


%%Page: 11 11


%%PageMedia: y3144x708


%%PageBoundingBox: 0 0 170 755


11 DoPDFPage


%%Page: 12 12


%%PageMedia: y797x600


%%PageBoundingBox: 0 0 288 383


12 DoPDFPage


%%Page: 13 13


%%PageMedia: y3210x804


%%PageBoundingBox: 0 0 193 770


13 DoPDFPage


%%Page: 14 14


%%PageMedia: y1623x576


%%PageBoundingBox: 0 0 3981312 11218176


14 DoPDFPage


%%Page: 15 15


%%PageMedia: y1891x600


%%PageBoundingBox: 0 0 144 454


15 DoPDFPage


%%Page: 16 16


%%PageMedia: y1483x600


%%PageBoundingBox: 0 0 450 1112


16 DoPDFPage


%%Page: 17 17


%%PageMedia: y1683x495


%%PageBoundingBox: 0 0 238 808


17 DoPDFPage


%%Page: 18 18


%%PageMedia: y910x600


%%PageBoundingBox: 0 0 450 683


18 DoPDFPage


%%Page: 19 19


%%PageMedia: y1385x817


%%PageBoundingBox: 0 0 5647104 9573120


19 DoPDFPage


%%Page: 20 20


%%PageMedia: y1347x835


%%PageBoundingBox: 0 0 626 1010


20 DoPDFPage


%%Page: 21 21


%%PageMedia: y1742x600


%%PageBoundingBox: 0 0 450 1307


21 DoPDFPage


%%Page: 22 22


%%PageMedia: y1595x579


%%PageBoundingBox: 0 0 434 1196


22 DoPDFPage


%%Page: 23 23


%%PageMedia: y799x600


%%PageBoundingBox: 0 0 450 599


23 DoPDFPage


%%Page: 24 24


%%PageMedia: y1084x600


%%PageBoundingBox: 0 0 288 520


24 DoPDFPage


%%Page: 25 25


%%PageMedia: y980x600


%%PageBoundingBox: 0 0 450 735


25 DoPDFPage


%%Page: 26 26


%%PageMedia: y865x600


%%PageBoundingBox: 0 0 288 415


26 DoPDFPage


%%Page: 27 27


%%PageMedia: y1628x766


%%PageBoundingBox: 0 0 575 1221


27 DoPDFPage


%%Page: 28 28


%%PageMedia: y1732x600


%%PageBoundingBox: 0 0 144 416


28 DoPDFPage


%%Page: 29 29


%%PageMedia: y992x600


%%PageBoundingBox: 0 0 144 238


29 DoPDFPage


%%Page: 30 30


%%PageMedia: y1811x600


%%PageBoundingBox: 0 0 144 435


30 DoPDFPage


%%Page: 31 31


%%PageMedia: y1663x600


%%PageBoundingBox: 0 0 144 399


31 DoPDFPage


%%Page: 32 32


%%PageMedia: y1566x600


%%PageBoundingBox: 0 0 144 376


32 DoPDFPage


%%Page: 33 33


%%PageMedia: y1535x600


%%PageBoundingBox: 0 0 450 1151


33 DoPDFPage


%%Page: 34 34


%%PageMedia: y2146x600


%%PageBoundingBox: 0 0 450 1610


34 DoPDFPage


%%Page: 35 35


%%PageMedia: y1351x600


%%PageBoundingBox: 0 0 450 1013


35 DoPDFPage


%%Page: 36 36


%%PageMedia: y665x600


%%PageBoundingBox: 0 0 450 499


36 DoPDFPage


%%Page: 37 37


%%PageMedia: y975x600


%%PageBoundingBox: 0 0 144 234


37 DoPDFPage


%%Page: 38 38


%%PageMedia: y1458x552


%%PageBoundingBox: 0 0 265 700


38 DoPDFPage


%%Page: 39 39


%%PageMedia: y742x600


%%PageBoundingBox: 0 0 144 178


39 DoPDFPage


%%Page: 40 40


%%PageMedia: y742x600


%%PageBoundingBox: 0 0 144 178


40 DoPDFPage


%%Page: 41 41


%%PageMedia: y1347x835


%%PageBoundingBox: 0 0 626 1010


41 DoPDFPage


%%Page: 42 42


%%PageMedia: y880x600


%%PageBoundingBox: 0 0 216 317


42 DoPDFPage


%%Page: 43 43


%%PageMedia: y1694x680


%%PageBoundingBox: 0 0 245 610


43 DoPDFPage


%%Page: 44 44


%%PageMedia: y3132x678


%%PageBoundingBox: 0 0 163 752


44 DoPDFPage


%%Page: 45 45


%%PageMedia: y600x800


%%PageBoundingBox: 0 0 600 450


45 DoPDFPage


%%Page: 46 46


%%PageMedia: y696x600


%%PageBoundingBox: 0 0 144 167


46 DoPDFPage


%%Page: 47 47


%%PageMedia: y953x600


%%PageBoundingBox: 0 0 600 953


47 DoPDFPage


%%Page: 48 48


%%PageMedia: y538x600


%%PageBoundingBox: 0 0 288 258


48 DoPDFPage


%%Page: 49 49


%%PageMedia: y800x600


%%PageBoundingBox: 0 0 600 800


49 DoPDFPage


%%Page: 50 50


%%PageMedia: y1000x808


%%PageBoundingBox: 0 0 291 360


50 DoPDFPage


%%Page: 51 51


%%PageMedia: y1026x600


%%PageBoundingBox: 0 0 600 1026


51 DoPDFPage


%%Page: 52 52


%%PageMedia: y1562x600


%%PageBoundingBox: 0 0 144 375


52 DoPDFPage


%%Page: 53 53


%%PageMedia: y767x777


%%PageBoundingBox: 0 0 777 767


53 DoPDFPage


%%Page: 54 54


%%PageMedia: y1540x537


%%PageBoundingBox: 0 0 3711744 10644480


54 DoPDFPage


%%Page: 55 55


%%PageMedia: y1540x537


%%PageBoundingBox: 0 0 3711744 10644480


55 DoPDFPage


%%Page: 56 56


%%PageMedia: y625x281


%%PageBoundingBox: 0 0 135 300


56 DoPDFPage


%%Page: 57 57


%%PageMedia: y1209x600


%%PageBoundingBox: 0 0 144 290


57 DoPDFPage


%%Page: 58 58


%%PageMedia: y1024x519


%%PageBoundingBox: 0 0 389 768


58 DoPDFPage


%%Page: 59 59


%%PageMedia: y1024x585


%%PageBoundingBox: 0 0 140 246


59 DoPDFPage


%%Page: 60 60


%%PageMedia: y887x600


%%PageBoundingBox: 0 0 288 426


60 DoPDFPage


%%Page: 61 61


%%PageMedia: y860x600


%%PageBoundingBox: 0 0 450 645


61 DoPDFPage


%%Page: 62 62


%%PageMedia: y852x600


%%PageBoundingBox: 0 0 450 639


62 DoPDFPage


%%Page: 63 63


%%PageMedia: y762x778


%%PageBoundingBox: 0 0 778 762


63 DoPDFPage


%%Page: 64 64


%%PageMedia: y825x600


%%PageBoundingBox: 0 0 144 198


64 DoPDFPage


%%Page: 65 65


%%PageMedia: y1200x2036


%%PageBoundingBox: 0 0 1466 864


65 DoPDFPage


%%Page: 66 66


%%PageMedia: y1158x600


%%PageBoundingBox: 0 0 286 552


66 DoPDFPage


%%Page: 67 67


%%PageMedia: y375x484


%%PageBoundingBox: 0 0 484 375


67 DoPDFPage


%%Page: 68 68


%%PageMedia: y979x600


%%PageBoundingBox: 0 0 600 979


68 DoPDFPage


%%Page: 69 69


%%PageMedia: y1024x723


%%PageBoundingBox: 0 0 542 768


69 DoPDFPage


%%Page: 70 70


%%PageMedia: y1429x600


%%PageBoundingBox: 0 0 600 1429


70 DoPDFPage


%%Page: 71 71


%%PageMedia: y785x600


%%PageBoundingBox: 0 0 288 377


71 DoPDFPage


%%Page: 72 72


%%PageMedia: y856x600


%%PageBoundingBox: 0 0 600 856


72 DoPDFPage


%%Page: 73 73


%%PageMedia: y871x600


%%PageBoundingBox: 0 0 600 871


73 DoPDFPage


%%Page: 74 74


%%PageMedia: y717x492


%%PageBoundingBox: 0 0 236 344


74 DoPDFPage


%%Page: 75 75


%%PageMedia: y1433x1156


%%PageBoundingBox: 0 0 555 688


75 DoPDFPage


%%Page: 76 76


%%PageMedia: y774x600


%%PageBoundingBox: 0 0 288 372


76 DoPDFPage


%%Page: 77 77


%%PageMedia: y778x600


%%PageBoundingBox: 0 0 288 374


77 DoPDFPage


%%Page: 78 78


%%PageMedia: y710x784


%%PageBoundingBox: 0 0 784 710


78 DoPDFPage


%%Page: 79 79


%%PageMedia: y1024x760


%%PageBoundingBox: 0 0 570 768


79 DoPDFPage


%%Page: 80 80


%%PageMedia: y500x370


%%PageBoundingBox: 0 0 370 500


80 DoPDFPage


%%Page: 81 81


%%PageMedia: y1200x1792


%%PageBoundingBox: 0 0 1792 1200


81 DoPDFPage


%%Page: 82 82


%%PageMedia: y2664x828


%%PageBoundingBox: 0 0 199 639


82 DoPDFPage


%%Page: 83 83


%%PageMedia: y1379x357


%%PageBoundingBox: 0 0 268 1034


83 DoPDFPage


%%Page: 84 84


%%PageMedia: y675x1080


%%PageBoundingBox: 0 0 518 324


84 DoPDFPage


%%Page: 85 85


%%PageMedia: y536x600


%%PageBoundingBox: 0 0 144 129


85 DoPDFPage


%%Page: 86 86


%%PageMedia: y500x375


%%PageBoundingBox: 0 0 375 500


86 DoPDFPage


%%Page: 87 87


%%PageMedia: y500x321


%%PageBoundingBox: 0 0 321 500


87 DoPDFPage


%%Page: 88 88


%%PageMedia: y228x600


%%PageBoundingBox: 0 0 450 171


88 DoPDFPage


%%Page: 89 89


%%PageMedia: y538x420


%%PageBoundingBox: 0 0 101 129


89 DoPDFPage


%%Page: 90 90


%%PageMedia: y450x600


%%PageBoundingBox: 0 0 600 450


90 DoPDFPage


%%Page: 91 91


%%PageMedia: y500x375


%%PageBoundingBox: 0 0 375 500


91 DoPDFPage


%%Page: 92 92


%%PageMedia: y500x375


%%PageBoundingBox: 0 0 375 500


92 DoPDFPage


%%Trailer


currentdict pdfclose


end


end


end


%%EOF



No comments:

twitter-updates