Thanks to Remy F, I could write this solution, with the help of this LaTeX file, which import output.pdf, and rotate it:
\documentclass \usepackage[paperwidth=6.38in,paperheight=10.32in,bindingoffset=0in,top=-0.39in,bottom=0in,left=-0.29in,right=0in,footskip=0in] \usepackage \begin \pagestyle \begin[t] \includegraphics[scale=0.233,angle=-4] \end \end
Then:
pdflatex output_tex.tex
Creates output_tex.pdf:
It would be nice to be able to tune the scale and margins automatically to be able to automatize the process.
EDIT: I have made some progress to obtain the deskew angle automatically:
angle=`convert output.pdf -deskew 40 -format "%[deskew:angle]" info:`
If I automatize, it leads to:
#/bin/bash name=$ ext=$ convert -density 300 -quality 100 $.$ext -level 0%,100%,4.0 -black-threshold 75% $_convert.$ext pdfsandwich -noimage -coo "-normalize -density 300 -black-threshold 75%" $_convert.$ext -o $_ocr.$ext angle=`convert $_ocr.$ext -deskew 40 -format "%[deskew:angle]" info:` angle=`echo "$*-1" | bc` echo " angle = $angle" sed -e "s/ANGLE/$angle/" -e "s/FILE/$_ocr.$ext/" /var/ocr/pdfrotate.tex > $_ocr_straight.tex pdflatex $_ocr_straight.tex rm $_convert.$ext $_ocr_straight.tex $_ocr_straight.aux $_ocr_straight.log
With /var/ocr/pdfrotate.tex:
\documentclass \usepackage[paperwidth=6.38in,paperheight=10.32in,bindingoffset=0in,top=-0.39in,bottom=0in,left=-0.29in,right=0in,footskip=0in] \usepackage \begin \pagestyle \begin[t] \includegraphics[scale=0.233,angle=ANGLE] \end \end
The scale looks right and is document dependent. But unfortunatly, the geometry parameters top and left I tuned for my trial page are not good for other pages. I don't know how to automatize them. Possibly by bluring the original page and the result one, and performing an optimisation of a correlation of them, with top and left as parameters.