В следующем TeX-файле текст хранится внутри блока - \mytextbox
- до установки блока внутри текстового блока.Как только у вас есть текст в поле, вы можете вернуть измерения.Я пишу \the
h
восемь t
(в p
oin t
s) в текстовый файл textboxheight.txt
.
\documentclass{article}
\usepackage{lipsum,newfile}
\newsavebox{\mytextbox}
\begin{document}
\savebox{\mytextbox}{%
\begin{minipage}{\linewidth}
%\setlength{\parindent}{15pt}% Restore \parindent, if needed
\strut % To achieve the appropriate baseline skip on first line
\lipsum*[1]% A first paragraph of random text
\lipsum*[2]% A second paragraph of random text
\strut % To achieve the appropriate baseline skip on last line
\end{minipage}}
\noindent
\usebox{\mytextbox}
\newoutputstream{boxdim}% Open output stream
\openoutputfile{textboxheight.txt}{boxdim}% Open file to write to
\addtostream{boxdim}{\the\ht\mytextbox}% Write text box height to file
\closeoutputstream{boxdim}% Close output stream
\end{document}
На этом этапе ваш код Python может читать textboxheight.txt
и все остальное, я уверен.
Можно было бы вывести высоту в другом измерении , если необходимо.