pythonpdfpypdfhebrew

How to set PDF Binding property using Python?


I have a large number of Hebrew-language pdf files that I need to set to be shown in Two Page Scrolling view by default. I have managed to automate setting the Page Display property using PyPDF2, but the pages are shown left-to-right (e.g. page 1 on the left and page 2 on the right of the screen). Because the files are in Hebrew, I need the pages to be right-to-left. I am able to set this manually using Adobe Acrobat Pro through File > Properties > Advanced > Reading Options > Binding and selecting "Right Edge". However, I am unable to find a way to automate setting the Binding attribute with PyPDF2, pdfrw or any other Python package, or any other way that isn't Python.

Is there any way to automate this? Preferably with Python but any way could be helpful.


Solution

  • From a programming perspective this is fairly simple, but pointless. It is a symbiosis between top end PDF editors like Arabic "In Design", and PDF readers.

    RTL or R2L is sometimes called Manga Mode and there is an oriental R2L.py gist here https://gist.github.com/tatsu38/31316daf1200ab0146c33051341c4d72 by see after this background discourse for possible single line programming.

    The outcome (like many PDF surpluses) can be dictated by PDF viewer, rather than Author.

    Some well used PDF readers cannot show Right to Left as marketed primarily for Western audience. Possibly, there are oriental PDF readers that can only read RTL and not bother with LTR?

    Same file, "Authored for RTL binding" (OR LTR) but in viewer 2 different settings, Spot my error ! (Arabic is not English or Hebrew)

    2 0 obj
    <</Lang(he-IL)/Metadata 3 0 R/Pages 4 0 R/Type/Catalog/ViewerPreferences<</Direction/R2L>>>>
    endobj
    

    enter image description here

    Same file opened in Acrobat Reader where Binding self sets to right-bound, and Acrobat enabled Edge where (similar to Chromes plug-in, which is odd because Foxit can use the hint) there is no way as far as I can tell for PDF plug-in to respect RTL Binding !! enter image description here

    We saw at the beginning a gist to text edit the PDF using PykePDF/qpdf and there are many tools such as GhostScript that could do similar programmed injection.