How to assemble 500 image slices into a printable PDF
January 29, 2013 7:52 AM Subscribe
I have about 500 PNGs. Each is 8" wide and anywhere from 1" to 5" high. I need to assemble them into a PDF, as many images as possible that will fit per page without cutting off.
The tools at my disposal are Adobe Creative Suite 4, Acrobat Pro, Office, and a knowledge of HTML/CSS/PHP. I am on a Windows machine and open to purchasing software if it's < $50.
Ideally, I want to automate this as much as possible. The images are already in correct order by filename.
Things I have tried:
Assembling a PDF from multiple files, but it puts each image on its own page.
Generating a PHP script that writes all the files to HTML, but when printing to PDF, images are still getting cutoff because browsers suck at printing. I don't really want to have to account for image sizes in my script and generate multiple HTML pages.
The tools at my disposal are Adobe Creative Suite 4, Acrobat Pro, Office, and a knowledge of HTML/CSS/PHP. I am on a Windows machine and open to purchasing software if it's < $50.
Ideally, I want to automate this as much as possible. The images are already in correct order by filename.
Things I have tried:
Assembling a PDF from multiple files, but it puts each image on its own page.
Generating a PHP script that writes all the files to HTML, but when printing to PDF, images are still getting cutoff because browsers suck at printing. I don't really want to have to account for image sizes in my script and generate multiple HTML pages.
Personally, I'd hack together an imagemagick (montage) solution. You'll find it on OS X and many Linux installs by default, though they do have a binary distribution for Windows/Cygwin.
posted by Brian Puccio at 8:09 AM on January 29, 2013
posted by Brian Puccio at 8:09 AM on January 29, 2013
Could you download a free trial of something like this library and write some one off code to knock it out? That's a really easy library to use and pretty comprehensive in functionality.
posted by Jacob G at 8:10 AM on January 29, 2013
posted by Jacob G at 8:10 AM on January 29, 2013
Best answer: Dump them all into a Word document as inline images.
They should page break appropriately.
Then use a PDF print filter.
You might want to write a VB script to make them all the same width if they don't automatically size themselves usefully.
posted by seanmpuckett at 8:33 AM on January 29, 2013 [1 favorite]
They should page break appropriately.
Then use a PDF print filter.
You might want to write a VB script to make them all the same width if they don't automatically size themselves usefully.
posted by seanmpuckett at 8:33 AM on January 29, 2013 [1 favorite]
The full version of Acrobat will allow you to do this. Just select all your files and then right click and choose 'combine supported files in acrobat'. It will then make a single pdf with one picture per page.
posted by Confess, Fletch at 8:51 AM on January 29, 2013
posted by Confess, Fletch at 8:51 AM on January 29, 2013
This is what text markup languages are for. A couple of minutes looking at the AsciiDoc reference makes me think you could do something like this with the image command:
It might be a bit of a fiddly process installing this, though. There are a ton of other markup languages that can do this; personally, I'd use LaTeX, but that's just 'cos I've been using it for 20+ years. Can't InDesign import HTML, too?
posted by scruss at 9:03 AM on January 29, 2013 [1 favorite]
image:pic001.png image:pic002.png image:pic003.png ...This can be processed directly into PDF via the magic of DocBook.
It might be a bit of a fiddly process installing this, though. There are a ton of other markup languages that can do this; personally, I'd use LaTeX, but that's just 'cos I've been using it for 20+ years. Can't InDesign import HTML, too?
posted by scruss at 9:03 AM on January 29, 2013 [1 favorite]
I've done things like this with a script to write LaTeX source (basically just throwing an \includegraphics*{...} around each filename and adding some header/footer code) and running pdflatex with the graphicx package. LaTeX is free -- standard on Linux, available on pretty much everything.
posted by jackbishop at 9:36 AM on January 29, 2013
posted by jackbishop at 9:36 AM on January 29, 2013
Have you tried using CSS pagination settings in the HTML, as discussed here for example? You might have to print it from one particular browser because support isn't consistently cross-browser, but my recollection from using it almost a decade ago was that it worked just fine after a little tweaking.
posted by XMLicious at 9:38 AM on January 29, 2013
posted by XMLicious at 9:38 AM on January 29, 2013
Best answer: I work for a company and for them I make PDF libraries (dotPDF from Atalasoft) and in a previous life I worked for Adobe on Acrobat. This is something that can be done relatively easily using my toolkit if you know C# or VB. The bad news is that it is out of your price range. The good news is that if you're halfway competent with code, you could easily get this done during the evaluation period. The bad news is that once that period is over, you can't use your tool anymore. The good is that it comes with froyo. The bad news is that's a lie.
OK - what you need to do is something along the lines of this as steps:
measure every image (make sure each image has resolution tags), drop as many images as you can per page until you're out of images.
The tricky part is this - if the images are aren't the same size (and they aren't), you have to paginate somehow. You basically have to accumulate all the bounding boxes of images that you have already put on the page and see if you can put the next one in somewhere without overlapping. You could easily burn several days just figuring that one out, but a chunk of code that can give you a list of data structures for images and their locations, per page - that would be easy:
Now, the "hard part" could be anything - it could be straight code in place, it could be output from another program that you just convert to what you need. What I would do myself is go through all the files in order and make the FilePostion class for each one in one list, then starting in the upper left of the page, fit a rectangle and to the leftmost and highest spot that can hold it without overlapping any other rectangles. If it doesn't fit, accumulate your current list, reinitialize the "current" and try again.
If all of this is Greek, just ignore it, I can't help you directly (sorry).
posted by plinth at 12:21 PM on January 29, 2013
OK - what you need to do is something along the lines of this as steps:
measure every image (make sure each image has resolution tags), drop as many images as you can per page until you're out of images.
The tricky part is this - if the images are aren't the same size (and they aren't), you have to paginate somehow. You basically have to accumulate all the bounding boxes of images that you have already put on the page and see if you can put the next one in somewhere without overlapping. You could easily burn several days just figuring that one out, but a chunk of code that can give you a list of data structures for images and their locations, per page - that would be easy:
public class FilePosition {
public string Path { get; set; }
public PdfBounds Location { get; set; }
}
public class Tiler {
public static List<List<FilePosition>> ToPageLayout(string[] paths) { /* hard part */ }
public static void ToPdf(string outputPdf, List<List<FilePosition>> layout)
{
PdfGeneratedDocument doc = PdfImageCompressor.CreateDocument();
foreach (List<FilePosition> files in layout) {
PdfPage page = PdfDefaultPages.Letter;
foreach (FilePosition file in files) {
using (AtalaImage image = new AtalaImage(file.Path, null)) {
string resName = doc.Resources.Images.Add(image);
PdfImageShape shape = new PdfImageShape(resName, file.Location);
page.DrawlingList.Add(shape);
}
}
doc.Pages.Add(page);
}
doc.Save(outputPdf);
}
}
Now, the "hard part" could be anything - it could be straight code in place, it could be output from another program that you just convert to what you need. What I would do myself is go through all the files in order and make the FilePostion class for each one in one list, then starting in the upper left of the page, fit a rectangle and to the leftmost and highest spot that can hold it without overlapping any other rectangles. If it doesn't fit, accumulate your current list, reinitialize the "current" and try again.
If all of this is Greek, just ignore it, I can't help you directly (sorry).
posted by plinth at 12:21 PM on January 29, 2013
Response by poster: Best answer to the Word solution which addresses the pagination issue of stacking multiple images with varying sizes with a minimum of fuss. Thanks also, plinth -- I have the pseudocode figured out in my head, I just don't have the time to learn a new library. Hopefully I can revisit with the more elegant solution.
posted by Wossname at 4:53 PM on January 29, 2013
posted by Wossname at 4:53 PM on January 29, 2013
« Older What can I do in my free time which could lead to... | How do you remember to take your vitamins? Newer »
This thread is closed to new comments.
posted by Wossname at 7:55 AM on January 29, 2013