[Tex/LaTex] How to create PDF & EPS exactly as big as the PSTricks picture but without using pdfcrop

conversionpaper-sizepdfcropperformancepstricks

This question is made to accompany the existing question: How can I create a pdf document exactly as big as my tikz picture?.

Constraints:

  1. It is not allowed to use pdfcrop by any means whatsoever. It is because pdfcrop takes a significant amount of time as explained in Searching for a better workflow to get a cropped PDF and EPS graphics – Stage 2.
  2. Manually calculating a tight paper dimension and other related dimensions is not allowed. For example, the solution for the first case in this link is not allowed because the margin is manually setup to avoid the top and bottom parts get cropped accidently.
  3. Neither BatchA.bat nor BatchB.bat is allowed because they produce big PDF and EPS files. Any variants of them might not be allowed as well. But they might be allowed if there is a way to reduce the file size, at least the same as the file size produced by latex->dvips->ps2pdf->pdfcrop.

    BatchA.bat:

    latex -interaction=nonstopmode %1
    dvips  -R -t unknown -E %1 -o %1-temp.eps
    epstool --copy --bbox %1-temp.eps %1.eps
    epstopdf --hires %1.eps
    

    BatchB.bat:

    latex -interaction=nonstopmode %1
    dvips -R -t unknown %1 -o %1-temp.ps
    ps2eps %1-temp.ps
    epstool --copy --bbox %1-temp.eps %1.eps
    epstopdf --hires %1.eps
    

How can I create PDF and EPS exactly as big as my PSTricks picture without breaking the constraints above?

Best Answer

You can't. Not if you meanby the size of graphic you mean the rectangle around all the print. The postscript graphics are calculated by the postscript interpreter (e.g. dvips) after the (La)TeX run. So LaTeX has absolutly no chance to know where all the black or colored ink points will be.

You can try dvips -E but as the documentation says to the -E option:

Generate an EPSF file with a tight bounding box. This only looks at marks made by characters and rules, not by any included graphics. In addition, it gets the glyph metrics from the TFM file, so characters that print outside their enclosing TFM box may confuse it. In addition, the bounding box might be a bit too loose if the character glyph has significant left or right side bearings. Nonetheless, this option works well enough for creating small EPSF files for equations or tables or the like.