Author Topic: Beginner question - repaginating.  (Read 3664 times)

Nermander

  • Hero Member
  • *****
  • Posts: 1280
  • Karma: 17
Re: Beginner question - repaginating.
« Reply #15 on: July 27, 2016, 04:08:47 pm »
I spent quite a while a few years ago writing perl scripts to do impositions with psutils pstops, the sole purpose of the scripts were to build the command line for pstops.

One way to make it easier to understand may be something like:

1. Set the sheet size (for the printer)
2. Set the sheet margins (how far to the edge can the printer print?)
3. Divide the remaining area (we can call it the print area) into rows and columns, giving us "cells"
4. For each sell, specify how the page should be scaled, rotated and aligned
5. Decide on how the pages of thenfile to impose shall be grouped. Basically there are two ways, I call them Signature and Magazine. But in reality there can be combinations of them!
6. Specify what page should go into which cell of the sheet.

After step 3 you could be given a graphical representation of the sheet, and then place "placeholders" for the pages into the cells. I did once make an attempt to use Scribus for this, creating a document for the sheet, placing guides and then my intention was to use image frames and import pages from a PDF into them (scripted of course).

As for step number 4, my script used cardinals, like N (top centered), NE (top right), SW (bottom left).

For step 5, when doing signatures, the file is grouped by a number of pages at a time (I called this blocks, because this is what pstops called them). If doing 8 page signatures, first block is pages 1-8, second block 9-16 etc.

For a magazine imposition however, the first block would contain half of the pages from the beginning of the file and half from the end. If doing 4 page signatures (booklet printing) of a 16 page document, the first block would be pages 1, 2, 15 and 16. With pstops the latter was done by using negative page numbers, so the page specification would be 1, 2, -3 and -4.

But it also possible to do "inserted" signatures (I'm not sure of the english term). For example making each signature a small "booklet" of two sheets. Then each "block" would use two sheets, first sheet would have pages 1, 2, 7 and 8, second sheet 3, 4, 5 and 6.

I started on a wiki article about my scripts a few years ago, but never got the time to insert some good examples.
https://wiki.scribus.net/canvas/How_to_make_impositions_with_pstops

I used my scripts for binding several books (downloaded from Project Gutenberg, typeset using GutenMark and LyX/LaTeX and then imposed with my scripts before printing, folding and binding, and then reading).

a.l.e

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1918
  • Karma: 26
    • the graphics lab
Re: Beginner question - repaginating.
« Reply #16 on: July 27, 2016, 04:09:12 pm »
i'm trying to learn enough c++ to create a bunch of tools that use ghostscript (or another library?) to do one type of imposition each...

i have other project that i have to finish first, though...

but in the meantime, i would be interested in knowing which command line tools / library can be used to manipulate PDFs and keep all the original PDF's properties.

i really have no experience with it and i only have read in the past that not all transformation / tools are safe for professional printing.

we will see what comes out...

a.l.e

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1918
  • Karma: 26
    • the graphics lab
Re: Beginner question - repaginating.
« Reply #17 on: July 27, 2016, 04:14:47 pm »
ps: pstops will probably not be able to keep the pdf properties...

something like this

pdfnup --nup 2x1 --frame false cards-a6.pdf --outfile cards-a5.pdf

might or might not... i don't know. and i don't have any access to tools that could tell.

Nermander

  • Hero Member
  • *****
  • Posts: 1280
  • Karma: 17
Re: Beginner question - repaginating.
« Reply #18 on: July 27, 2016, 10:15:13 pm »
I dop not think Ghostscript is the best tool for the task, the main purpose for ghostscript is to convert from postscript to other format, which means it includes loads of code to convert postscript to different bitmap formats.

I think there is a package called pdfutils which is a PDF equivalent of psutils (but the name pdfutils seems to be used by many other programs and libraries).

As I tried to explain, the PDF manipulation (scaling, rotating and placing the pages) is the easy part. In postscript, these steps are done by manipulating the coordinate system for the page (scaling, rotating and shifting). It more or less just means that each page is wrapped into a different coordinate system. And since PDF is based on postscript I believe this is easy to accomplish (jpdftweak does it fairly well).

It's the interface to create the "numbers" (scaling factor, rotating angle, placement adjustment) that is the major part.

There are also minor features I haven't mentioned before:

Creep - when folding a signature, the "inner pages" will be closer to the margin than the outer ones, the placement of the page image needs to be compensated for this (based on paper thickness).

This page contains some information on how creep is handled in InDesign.
https://helpx.adobe.com/indesign/using/printing-booklets.html

When rotating pages, sometimes the rotation may need to be adjusted by single degrees, or even fractions of a degree. This depends a lot on how the sheet is folded. So instead of rotating a page 90 degrees maybe the rotation needs to be 89,5 degrees. Most simple impositioning tools only support 90, 180 or 270 degree rotation.

 

palmate