Open mseri opened 6 years ago
Also pdfrw (https://github.com/pmaupin/pdfrw) is a pure-python implementation but I have never used it
I like the idea. :+1:
Yes! That's better~
I suspect you have all moved on, as this project hasn't been touched in a year, but pdftk has been removed from deb & ubuntu due to upstream dependencies (see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=892539)
so changing this dependency would be awesome :-)
Another option is use latex with the pdfpages
package. I use the following script, which I call as
pdfstack "${tmpfolder}"/background.pdf "${tmpfolder}"/foreground.pdf "${filename}.pdf"
in place of https://github.com/reHackable/maxio/blob/a0a9d8291bd034a0114919bbf334973bbdd6a218/tools/exportNotebook#L354
(NOT tested much)
#!/bin/zsh
latex='xelatex'
bgf=$1
fgf=$2
out=$3
base=${out:r}
tmpdir=`mktemp -d`
fbase="${tmpdir}/${base}"
fbdir=${fbase:h}
/bin/mkdir -pv $fbdir
/bin/cp $bgf $fgf $fbdir
cat <<EOF > "${fbase}.tex"
\\documentclass{article}
\\usepackage{graphicx}
\\usepackage{pdfpages}
\\begin{document}
\\makeatletter
\\includepdf[pages=-,picturecommand={
\\includegraphics[page=\\AM@page]{${bgf:t}}
}]{${fgf:t}}
\\makeatother
\end{document}
EOF
cd $fbdir
${latex} $fbase
cd -
cp "${fbase}.pdf" "${base}.pdf"
My suggestion here was to reduce the need for external dependencies, but your script is quite neat and also more portable than the original
We should probably collect all these solutions somewhere since in this repo looks like there is not much of a chance to make changes
My suggestion here was to reduce the need for external dependencies, but your script is quite neat and also more portable than the original
Sure. For me latex and pdfpages are basic tools, so this indeed saved me a lot of dependencies (all the java stuff around pdftk), but of course it depends on the setup
My suggestion here was to reduce the need for external dependencies, but your script is quite neat and also more portable than the original
By the way, it seems that the list of dependencies in the README is completely off...
We could reduce the dependencies of the package by moving to PyPDF2 (https://github.com/mstamy2/PyPDF2). In this way we could have a fully pythonic implementation of the tools that is easier to make corss-platform.
If you think this could be interesting, I am going to investigate it as soon as I have some time