My MWE below produces the following in the \jobname.ypos.txt file:
{1}{1}{1}{F}{0}
{1}{1}{1}{L}{0}
{1}{1}{2}{F}{0}
{1}{1}{2}{L}{0}
{1}{1}{3}{F}{0}
{1}{1}{3}{L}{0}
Where the bunch of zeros at the end are supposed to be the y-pos coordinates coming from \pdfsavepos and pdflastypos.
I'm obviously missing something fundamental here, but can't figure it out.
MWE:
\documentclass[pagesize=pdftex, fontsize=10]{scrbook}
\usepackage[paperwidth=11.2cm, paperheight=17.4cm, top=1cm,bottom=1cm, left=1cm, right=1cm]{geometry}
\usepackage{pdfcolparallel,hanging}
\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont{Times New Roman}
% Write the position to file.
% #1 is the book number
% #2 is the chapter number
% #3 is the verse number
% #4 is the position, first (F) or last (L), to be saved
\def\msec@write@lines#1#2#3#4{%
\pdfsavepos%
\immediate\write\yposoutputfile{%
\string{#1\string}%
\string{#2\string}%
\string{#3\string}%
\string{#4\string}%
\string{\the\pdflastypos\string}%
}%
}
\begin{document}
\newwrite\yposoutputfile%
\immediate\openout\yposoutputfile=\jobname.ypos.txt%
\LARGE{1} \msec@write@lines{1}{1}{1}{F} LIBRO de la generación de Jesucristo, hijo de David, hijo de Abraham. \msec@write@lines{1}{1}{1}{L}
\msec@write@lines{1}{1}{2}{F} \textbf{2}~Abraham engendró á Isaac: é Isaac engendró á Jacob: y Jacob engendró á Judas y á sus hermanos:\msec@write@lines{1}{1}{2}{L}
\msec@write@lines{1}{1}{3}{F} \textbf{3}~Y Judas engendró de Thamar á Phares y á Zara: y Phares engendró á Esrom: y Esrom engendró á Aram:\msec@write@lines{1}{1}{3}{L}
\immediate\closeout\yposoutputfile%
\end{document}