了解 pdf 底線高度的最佳方法

了解 pdf 底線高度的最佳方法

對於某些項目,我需要製作一頁的 PDF,沒有任何邊距。左側、右側和頂部邊距很容易設定為 0,但我還需要 pdf 具有內部內容的精確高度,因此我需要在最終垂直盒子深度的底部進行切割。我為此使用 LuaTeX,最好在單獨的腳本中完成 pdf 的垂直切割(因為我需要多次傳遞來產生我想要的 PDF)。

我正在考慮的是在 aux 檔案中輸出最終框深度的絕對高度,例如XXXcutAt:10cm,然後解析 aux 檔案並將該值傳遞到pdfcrop腳本中。

我不確定了解這個值的最佳方法...是否有一些明顯的 TeX-only 方法來獲取我所缺少的值?如果沒有,閱讀 LuaTeX 手冊似乎pdf.v是我想要的,但我對使用它的方式有點困惑......有沒有任何使用它的程式碼我可以用作範例?

答案1

在此輸入影像描述

這是純文本,但你可以在乳膠中做同樣的事情。

\setbox0=\vbox{\hsize=7.8cm
some text to fill out several lines of a paragraph with a high
proportion of g and y and f so that the depth is non zero
some text to fill out several lines of a paragraph with a high
proportion of g and y and f so that the depth is non zero
some text to fill out several lines of a paragraph with a high
proportion of g and y and f so that the depth is non zero
some text to fill out several lines of a paragraph with a high
proportion of g and y and f so that the depth is non zero
some text to fill out several lines of a paragraph with a high
proportion of g and y and f so that the depth is non zero
some text to fill out several lines of a paragraph with a high
proportion of g and y and f so that the depth is non zero}


\hoffset-1in
\voffset-1in
%asuming luatex 0.80 or older
\pdfpagewidth\wd0
\pdfpageheight\dimexpr\ht0+\dp0\relax
\shipout\box0

\bye

相關內容