I have a web application where I need to create, and then print, potentially tens of thousands of images at once. I need to support most modern Mac/PC browsers, but not mobile or tablet. My current plan is to:

  1. Create a web page where the user can select image creation options.
  2. When user finishes selection, click a button which will instruct the server to generate all of the images.
  3. Have the server generate an HTML page with all of the images generated, using appropriate CSS styles to ensure one image per page is printed.
  4. Load the HTML into a hidden iFrame on the initial page
  5. Print it using the technique outlined here

I know how to do all of this. However, I'm really worried that if there are enough images it will run the client's browser out of memory. If I have, say, 100,000 pages to print - are browsers smart enough to only download what it's spooling to the printer? Or does everything get downloaded immediately?

  • While it certainly depends on the browser, I am fairly certain none of the common ones will support this "streaming" - rather they download everything, then format/parse it (who knows what that last line of the file does, perhaps change the background color of the entire page?), and then start spooling only once they have decoded the entire page. Feb 16, 2015 at 17:28
  • 3
    With that many images you'll likely want to give your user control over the process - pause, reprint the past 10 images (paper jam), etc. Feb 16, 2015 at 17:53
  • 2
    I think you would be much better off with a desktop application here. Feb 16, 2015 at 19:07
  • 1
    I have to ask - what are you printing? I just measured a 500 sheet ream of 20# paper at just under 2 inches. You're talking about printing 100k pages - which would be 200 reams - or a stack of paper a bit over 30 feet high if printed single sided. I suspect most consumer grade printers (ink or laser) will wear out long before printing that much. Besides, the cost in ink or toner will be enormous. Feb 16, 2015 at 20:01
  • 1
    To do this a PDF generation sounds like a much more logical procedure. Since I expect it's likely you want a pdf anyway I would make it that format instantly. It moves the responsibility of printing all pages to the client. And you can verify the document to ensure all pages are in there. Feb 17, 2015 at 6:57

2 Answers 2


If you know the user's printer type and brand, you can generate the content you want printed in the Page Description Language that corresponds to the user's printer.

This content can be generated server-side to eliminate the need for expensive client-side browser action.

The printer can be specified by the user via <select> or a similar method of your choice.

For example, let's say that I wanted to print the following image in Zebra Programming Language (ZPL):

enter image description here

This image is 19,576 bytes, but it can be reduced to a mere 2,864 bytes of ZPL:


You could allow the user to print the code in a new window using JavaScript:

window.open( 'data:text/plain;base64,' + window.btoa( zpl_code ), 'Print ZPL Image', 'height=100, width=500' );

The result would look like this:

enter image description here

Try it online!

Then if the user wants to see the images that they are printing in the browser, the images could load via AJAX as the user scrolls in the main window.

Note: The user will need to allow raw data printing in order to use this method.

  • 1
    This is cool, I never knew any of this existed.
    – neilsimp1
    Jun 1, 2018 at 12:03

I don't have a solution, but contributing information about what I've tried. I'm also trying to do this, to print thumbnails of thousands of video clips. I wrote a script to make thumbnails watermarked with the disk image and clip name. Then I wrote another CGI script to display all the "*jpg" in a directory. All the directories from one year of clips could display on the same web page -- if the browser doesn't run out memory. Chrome never finishes rendering. Firefox renders all the thumbnails correctly, but doesn't "Print to PDF" correctly, or "Print to PostScript" correctly....there are "gaps" or white space where on the HTML render in the browser, there -were- images. I tried increasing cache/memory, etc. but still gaps if I display more than about 100 directories of thumbnails. It's only about 240MB worth of images, but it's about 10,000 little images. I think it's the number of images, not the disk space or RAM needed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.