Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Automate PNG to PDF conversion?

  1. #1
    Join Date
    Aug 2006
    Location
    Canada
    Beans
    386
    Distro
    Hardy Heron (Ubuntu Development)

    Question Automate PNG to PDF conversion?

    Is there a way to automate a mass conversion of PNG to PDF and then make all those PDF files into one PDF file (in an ordered fashion)?

  2. #2
    Join Date
    Jul 2006
    Beans
    353

    Re: Automate PNG to PDF conversion?

    Quote Originally Posted by arijarot View Post
    Is there a way to automate a mass conversion of PNG to PDF and then make all those PDF files into one PDF file (in an ordered fashion)?
    You can use convert from the ImageMagick package to convert multiple PNG files to one PDF file:

    Code:
    convert *.png outputfile.pdf
    You could also do this as a two-step process--convert each individual PNG file to a PDF file with convert and then merge the individual PDF files into a master PDF file with Ghostscript or PDFtk. This would pretty much require a shell script if the number of PNG files is large.

    I'm not sure what you mean by "an ordered fashion."
    Last edited by noynac; May 10th, 2008 at 07:43 PM.

  3. #3
    Join Date
    Aug 2006
    Location
    Canada
    Beans
    386
    Distro
    Hardy Heron (Ubuntu Development)

    Re: Automate PNG to PDF conversion?

    Thank you, noynac, I will give this a try (minus the shell scripting, as I don't know how lol). What I meant by "orderly fashion," was that I want to combine all the pdf files into one while maintaining their numbered sequence.

  4. #4
    Join Date
    Apr 2006
    Location
    Anchorage, AK
    Beans
    125
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Automate PNG to PDF conversion?

    I'm looking to do the same thing.

    Code:
    convert *.png book.pdf
    works well, but it messes up the numbering. The png's are scans of pages named book(*).png and convert throws them together in random order in the pdf. How do I tell convert to do book(1).png then book(2).png etc?

  5. #5
    Join Date
    Dec 2009
    Location
    UK
    Beans
    128
    Distro
    Ubuntu 11.04 Natty Narwhal

    Re: Automate PNG to PDF conversion?

    Quote Originally Posted by z987k View Post
    Code:
    convert *.png book.pdf
    works well, but it messes up the numbering. The png's are scans of pages named book(*).png and convert throws them together in random order in the pdf. How do I tell convert to do book(1).png then book(2).png etc?
    Someone here may have a more elegant solution but a quick one that will work is to convert each png separately (dependant on the number of files you have you may need to script this!!!), then use ghostscript to join them up. Ensure that the created .pdf files are named in order, i.e page1 = book(1).pdf, page2 = book(2).pd etc. then use this:

    Code:
    gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=<output>.pdf <pathtoinputfiles>*.pdf

  6. #6
    Join Date
    Apr 2006
    Location
    Anchorage, AK
    Beans
    125
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Automate PNG to PDF conversion?

    Figured it out.

    The file names need to be in numerical order. So lets say we have book1, book2, ... book10, book11, ... through book100.png

    convert *.png book.pdf would order the files in the pdf incorrectly because book1 would go right before book100. Renaming them book001 etc solves this.

  7. #7
    Join Date
    Dec 2009
    Location
    UK
    Beans
    128
    Distro
    Ubuntu 11.04 Natty Narwhal

    Talking Re: Automate PNG to PDF conversion?

    Quote Originally Posted by z987k View Post
    Figured it out.

    The file names need to be in numerical order. So lets say we have book1, book2, ... book10, book11, ... through book100.png

    convert *.png book.pdf would order the files in the pdf incorrectly because book1 would go right before book100. Renaming them book001 etc solves this.
    I have never used
    Code:
    convert *.png book.pdf
    but i think the same would apply for the ghostscript command, just I have never got up to page 100 to find out!!!
    Glad you got it sorted

  8. #8
    Join Date
    May 2008
    Location
    Green Bay, WI
    Beans
    30
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Automate PNG to PDF conversion?

    This all works for me pretty well except the pdf created is in landscape format, even though the images themselves are in portrait. Is there any way to force convert to make the pdf in portrait?
    |f y0u (@n r3@d +#!5 y0u 53r!0u5|y n33d +0 93+ |@!d.
    acidicninja

  9. #9
    wojox is offline I Ubuntu, Therefore, I Am
    Join Date
    Apr 2009
    Beans
    8,630

    Re: Automate PNG to PDF conversion?

    Quote Originally Posted by BigRedButton View Post
    This all works for me pretty well except the pdf created is in landscape format, even though the images themselves are in portrait. Is there any way to force convert to make the pdf in portrait?
    If you

    Code:
    man convert
    It will show you the switches. Try:

    Code:
    convert -rotate 90

  10. #10
    Join Date
    Jan 2006
    Location
    Syracuse, NY USA
    Beans
    86
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Smile Re: Automate PNG to PDF conversion?

    Thank you all so much - this just saved me some real headache.
    Code:
    convert *.png output.pdf
    Worked like a charm, exactly as I needed it to. If there's one thing I can count on in life, it's Ubuntu Forums providing the answers I need.
    "Violence is the last refuge of the incompetent." ~Isaac Asimov, The Foundation Series

    http://adamw.lifemax.net

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •