I've got one typed story to print as a small (A5) book, and my wife is willing to sew pages together. But one problem is, pages in document must be in specific order: 4-1-2-3-8-5-6-7-etc.

First I tried to find it in LibreOffice print options, but found only 'brochure' mode, which doesn't satisfy our intends.

Found one video on youtube, where author copies text fragments into certain pages of a new OpenOffice document and manually draw squares with page numbers in it. It looks really silly...

Then I tried to convert it into PDF and use GhostScript (which I used to cut page ranges from PDF documents once), but no solution were found still.

Finally I decided to go more straight forward and open file in text editor (gedit) to try and rearrange pages in PostScript code directly. Even though I am front-end developer, file contents makes no sense for me. I know some programming languages but PS is not one of them yet.

It would be nice to find a solution which could be used as a script, and not requires additional software to install on Ubuntu.

  • There are some hints in the PS FAQ en.m.wikibooks.org/wiki/… – eckes Nov 14 '17 at 8:24
  • @eckes - that is kind of obvious way, when you know how to extract page ranges and merge them together by GS, but it kind of messy... there's a great chance to make a mistake and mess things up. Also annoying with big documents. – MadBrozzeR Nov 15 '17 at 7:38

Found an article which describes PDF format. Now it feels like I can make simple NodeJS script for basic editing purposes. At least page reordering feels like an easiest one, because all I need (not tested yet) is rearrange references (Kids) in <</Type/Pages ...>> object.

UPDATE Manually rearranged references in array mentioned above. Failed to replace original using text editor, as it tries to convert encoding in stream objects breaking them. Replaced it using NodeJS script. Done. Unfortunately, this is not 'SuperUser' way to solve the problem though...

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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