5

There are plenty of tools that can rotate a PDF. Is there a tool that can mirror it, too?

I am not looking for a solution that first converts to a bitmap, then mirrors and then converts the bitmap to PDF, but for a tool that can do the mirroring with no loss of quality. So in PostScript terms I am looking for 1 -1 scale 0 -height transform.

1
  • In case you can't find a tool: Use mutool to decompress streams in pdf file, open in editor, insert q 1 0 0 -1 0 0 cm (push state, modify transformation matrix) before and Q (pop state) after what you want to mirror (use anything to automate). Not sure if you'll need a translation, too.
    – dirkt
    Jan 14, 2018 at 16:00

3 Answers 3

3

You can try pstops from package psutils. Convert the pdf to PostScript using GhostScript's ps2pdf first, then apply H for a horizontal flip.

pdf2ps in.pdf in.ps
pstops H in.ps out.ps

The PostScript output looks correct in gv, but when I converted it back to pdf with pdf2ps, it got flipped vertically too.

enter image description here

2
  • Thanks for your answer, but I'm getting pstops: cannot open input file H in pstops 2.05. Any idea what could be the issue?
    – Jon
    Feb 11, 2022 at 18:16
  • 1
    It looks like pstops has been greatly changed since the version I used. For example, you now need to use -S 0H instead of just H and you need to specify the input paper size (e.g. --inpaper=210mmx297mm for A4 size). I tried using the latest github version, but the output PostScript showed an error when viewed in ghostscript. Perhaps see if you can install an older version, before the change to version 2.
    – meuh
    Feb 11, 2022 at 19:40
0

Based on @meuh's answer I have built:

https://gitlab.com/ole.tange/tangetools/blob/master/mirrorpdf/mirrorpdf

0

I had to use following command line syntax of pstops tool to flip one A4 page:

pstops -P A4 -S 0H in.ps out.ps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .