I want to create a pdf file with several pages. Each page should contain only an image without any margins. It works fine when I'm exporting just one image as pdf, but some weird margins appear when I'm trying to print several pages.

So here is an example (both images have a proper A4 size for 150 dpi):

img1 = ImageResize[ExampleData[{"TestImage", "Aerial"}], {1240, 1754}];
img2 = ImageResize[ExampleData[{"TestImage", "Aerial2"}], {1240, 1754}];

Exporting of one image works fine:

Export["test1.pdf", img1]

But I fail to print several pages without any margins:

        "PrintingMargins"->{{0, 0}, {0, 0}}

So how could I create a pdf looking like "test1.pdf" but with several pages?

  • $\begingroup$ PageSize and PaperSize are measured in printer's points (1/72 inches). Change to "PaperSize" -> {595, 842} for A4 paper. The margins will also be reduced, if you keep "PageSize"->{1240, 1754} . $\endgroup$
    – LouisB
    Commented Apr 10, 2020 at 0:11
  • $\begingroup$ "PaperSize" doesn't really matter, the problem is in the difference between exporting one page and exporting several pages. Changing "PaperSize" doesn't help to get rid of weird margins which don't appear during one page exporting. $\endgroup$
    – Dmitriy
    Commented Apr 10, 2020 at 9:28

1 Answer 1


I've found a possible solution which is weird yet useful.

toCell[img_] := Cell[
    CellMargins -> {{0, 0}, {0, 0}},
    "Magnification" -> 1]

nb = CreateDocument[
    toCell /@ {img1, img2},
        Visible -> False, 
        PageBreakBelow -> True, 
        PrintingOptions -> {
            "PageSize" -> {1240, 1754}, 
            "PaperSize" -> {1240, 1754},
            "RestPagesHeader" -> False, 
            "RestPagesFooter" -> False,
            "PageHeaderMargins" -> {0, 0},
            "PrintingMargins" -> {{0, -142}, {0, 0}}}];
Export["test3.pdf", nb]

There are two key points:

  • converting images into cells;
  • changing right margin of "PrintingMargins" into negative (exact value depends on page and/or paper size).

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.