Function Repository Resource:

ExportImagesToPDF

Source Notebook

Create a multipage PDF from a list of images

Contributed by: Arnoud Buzing

ResourceFunction["ExportImagesToPDF"][file, images]

exports images to a PDF file, with one image per page.

ResourceFunction["ExportImagesToPDF"][file, images, res]

uses the specified resolution res.

Details

The generated page size matches the image size, without any added padding or borders.
The default resolution is 360.
Images must be in the RGB format.
Export on a list of images behaves different: it exports the expression on a single PDF page which is oftentimes not what you want.

Examples

Basic Examples (4) 

Export a list of random images to a PDF file:

In[1]:=
ResourceFunction["ExportImagesToPDF"]["out.pdf", Table[RandomImage[1, {100, 100}, ColorSpace -> "RGB"], 3]]
Out[1]=

View in an external viewer:

In[2]:=
SystemOpen["out.pdf"]

Use Import to import the pages as images:

In[3]:=
Import["out.pdf", {"PDF", "PageImages"}]
Out[3]=

Use a lower resolution setting:

In[4]:=
ResourceFunction["ExportImagesToPDF"]["out.pdf", Table[RandomImage[1, {100, 100}, ColorSpace -> "RGB"], 3], 72];
Import["out.pdf", {"PDF", "PageImages"}]
Out[5]=

Scope (2) 

Create a PDF from ExampleData:

In[6]:=
exampleimages = ResourceFunction["ExportImagesToPDF"]["examples.pdf", Map[ExampleData, RandomChoice[ExampleData["TestImage"], 3]]]
Out[6]=
In[7]:=
Import[exampleimages]
Out[7]=

Create a PDF from ResourceData:

In[8]:=
wdrpdf = ResourceFunction["ExportImagesToPDF"][
  "familydog.pdf", {ResourceData["Sample Image: Happy Family in Red"],
    ResourceData["Sample Image: White Dog on a Beach"]}]
Out[8]=
In[9]:=
Import[wdrpdf]
Out[9]=

Export on a list of images behaves different: it exports the expression on a single PDF page which is oftentimes not what you want:

In[10]:=
Export["out.pdf", {ResourceData["Sample Image: Happy Family in Red"], ResourceData["Sample Image: White Dog on a Beach"]}]
Out[10]=
In[11]:=
SystemOpen["out.pdf"]

Publisher

Arnoud Buzing

Requirements

Wolfram Language 14.0 (January 2024) or above

Version History

  • 1.0.0 – 30 October 2024

License Information