[Python] Print A6 double sided booklet using python and Latex

Discussão em 'Python' iniciado por Stack, Agosto 29, 2025.

  1. Stack

    Stack Membro Participativo

    I want to print a A6 booklet double sided. Even though this question has been posted a lot on the internet I could not find any suitable solution. I figure out a way using both Latex and python. I use this Latex code :

    \documentclass[a4paper]{article}
    \usepackage[margin=0pt]{geometry}
    \usepackage[skins,raster]{tcolorbox}
    \pagestyle{empty}
    \begin{document}
    \begin{tcbraster}[raster height=\textheight,raster equal skip=0pt,blank,

    graphics pages={8,1,6,3, 2,7,4,5}]
    \tcbincludepdf{a6.pdf}% <-- The A6 document with 8 pages
    \end{tcbraster}
    \end{document}


    To rearange the page in the right order (a6.pdf being my document to print), and I use this python code :

    L=[]
    for i in range(0,100,8):
    L.append(i+8)
    L.append(i+1)
    L.append(i+6)
    L.append(i+3)
    L.append(' '+str(i+2))
    L.append(i+7)
    L.append(i+4)
    L.append(i+5)


    to generate the list of pages in the right order (here for 100 pages).


    1. How can I get python to print horizontally with coma (8,1,6,3,...)? With this thread python: printing horizontally rather than current default printing I can print horizontally but not with comas.


    2. Could I use PyPDF2 to rearrange the page and get rid of this latex script?

    Continue reading...

Compartilhe esta Página