It want a PDF (or PNG) output of a Latex document on one long page, trimmed without the white borders, in minimal runtime.
standalone packages have this built in in some way and I would like to use their approach. However, both packages have been written with additional goals in mind and have unwanted side effects on paragraphs, floats, footnotes, itemizations, macros etc. which break my documents in other places.
Where do I need a hint?
I would like to extract the feature of setting the pdf page height in one Latex run at the end of this run - as it is used in
preview but I fail to extract the core functionality from these packages: I am simply not good enough in reading their macros. Here I would appreciate some hint.
What else have I tried and failed with?
\pdfsavepositionto write the document length to a file, read the file again in the next pdflatex run and then set the paper size as required. Works fine but needs two invocations of pdflatex, which doubles the runtime and is unwanted for my use case.
pdf-cropon the result. pdf-crop uses ghostscript to pick up the bounding-box (which takes very long) and it removes the PDF annotations embedded into the file, both of which is a show stopper for my use case. I need the annotations and the timing of ghostscript doubles the runtime.
nodefor PDF->PNG rendering, detecting the bounding box in the PNG, cropping to this box (and for my processing of the annotations). Works, but is very slow.
So there I am looking at
standalone code and trying to extract these probably quite short functionalities...without luck.