2

I create one PDF from N images. That's easy and straightforward with this command line:

convert front1.png back1.png front2.png back2.png result.pdf

Unfortunately some information gets lost in this process. The file result.pdf has four pages, but it is not clear if it contains two pages with front and back, or if it contains for front pages.

I would like to store this information in the meta data of the created result.pdf.

Is there an official standard to store the front/back information in PDF?

I tried to find something here, but could not find relevant information: http://www.adobe.com/products/xmp/standards.html

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
guettli
  • 25,042
  • 81
  • 346
  • 663

3 Answers3

4

Check out the pdf specification (1.7) at http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf

On page 580 (under interactive features) it lists that you can set preferences such as duplex and simplex.

I don't know whether this is possible using ImageMagick. I know it is possible using iText.

See this question : Printing a PDF duplex using Java

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
Joris Schellekens
  • 8,483
  • 2
  • 23
  • 54
  • Yes, there something under the heading "Duplex". There can be Simplex, DuplexFlipShortEdge, DuplexFlipLongEdge. AFAIK these values are for the whole document. I guess I would need something like "this particular page is a front-side (or back-side)". – guettli Aug 29 '17 at 07:58
3

As far as the PDF format is concerned, pages are pages: they aren't truly considered to be 'front' or 'back'

That concept only becomes meaningful when the pages are rasterized onto a physical piece of paper, i.e. printed.

That doesn't mean PDF is completely ignorant of the concept.

There are a couple of ways it comes into play:

  • PDF can carry an internal indicator of whether the document is intended to be printed in Duplex (there are a few options for this, as mentioned in Joris's answer). However, these are really just advisements to the print system you send it through. There is no guarantee that a given print system will actually respect the setting and put pages on both sides of the paper in the way you expect.
  • The content of the PDF may be laid out as if it were to be printed duplex (e.g. mirrored page layouts, etc.). But this is just part of the content stream; the PDF format itself is agnostic (other than the options mentioned above).

So it's difficult to say a given page is 'front' or 'back'. You could check if the Duplex flag is set, and if it is, take the page number and divide by two: it's a front page if it's even and a back page if it's odd (remember that page numbers start with zero in PDF).

But there can still be edge cases.

For example, if you were to print a range (say pages 3-7), and you expect page 3 to be a 'back' page, the first page out of the printer likely won't be blank on it's front and have page 3 on the back (which is what you'd expect from what I suggested above).

Most printers will start on the front of the first sheet of paper, and your 'front' and 'back' pages will be out of order.

piet.t
  • 11,718
  • 21
  • 43
  • 52
Rob Lyman
  • 364
  • 1
  • 8
0

An alternative could be to use articles: section 8.3.2 in the PDF reference v1.7. You could have 2 articles, one for the front pages, and another for the back pages.

PDF Reference v1.7 - 8.3.2: "Some types of documents may contain sequences of content items that are logically connected but not physically sequential".

Tjaart
  • 496
  • 8
  • 20