[Tex/LaTex] Converting a text file into a .tex file using C++

text manipulation

I have a text file which contains data like this:

word: 'Swine';      conf: 92.03;pointsize:'48':,font_name:'Verdana_Bold',X1:'152', X2:'283', Y1: '166', Y2: '202
word: 'flu';    conf: 93.43;pointsize:'48':,font_name:'Verdana_Bold',X1:'299', X2:'354', Y1: '164', Y2: '202
word: 'tightens';   conf: 90.12;pointsize:'48':,font_name:'Verdana_Bold',X1:'370', X2:'551', Y1: '164', Y2: '211
word: 'its';    conf: 96.04;pointsize:'48':,font_name:'Verdana_Bold',X1:'568', X2:'617', Y1: '166', Y2: '202
word: 'grip';   conf: 90.41;pointsize:'48':,font_name:'Verdana_Bold',X1:'632', X2:'716', Y1: '166', Y2: '211
word: 'over';   conf: 94.29;pointsize:'48':,font_name:'Verdana_Bold',X1:'732', X2:'831', Y1: '175', Y2: '202
word: 'India';      conf: 94.00;pointsize:'48':,font_name:'Verdana_Bold',X1:'848', X2:'953', Y1: '164', Y2: '202

With the following meanings:

Word: Actual word to be printed
Pointsize : Font size
Font name: Name of font used
X1,X2,Y1,Y2: Coordinates of location of word in the document

I want to take all this data, and put it as it is in a latex document. Now, I know I have to make a C++ code for this, by first opening a .tex file and start writing down the data by reading from the text file. The problem I am facing is, how to set the exact fonts and size of the text as mentioned in the file? Thanks!

Edit: Finally, I want to make a pdf file from the generated .tex file using the terminal commands.
Also, I referred the link: https://priyankacool10.wordpress.com/2012/05/10/creating-tex-file-using-c-program/ and I just need to know, what all do I have to write as part of my C++ code in order to make the .tex file.
I am not asking for the entire C++ code, just the exact syntax and package details for the same.

Sample Output:

enter image description here

Edit2: I will need a C++ code for reading the input words from the text file and writing it into a tex file. Is their any other way of doing it?

Edit3: (Error)

* Redefining document command \oldstylenums with arg. spec. 'm' on line 128.
*************************************************
) (/usr/share/texlive/texmf-dist/tex/latex/fontspec/fontspec-luatex.sty
(/usr/share/texlive/texmf-dist/tex/latex/base/fontenc.sty

! Package fontenc Error: Encoding file `eu2enc.def' not found.
(fontenc)                You might have misspelt the name of the encoding.

See the fontenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.99 \ProcessOptions*

Best Answer

It seems that TeX can read the file directly, I don't think you need C++

enter image description here

If your input text is text1.txt then the above is made by the following tex, processed by xelatex.

\documentclass{article}
\usepackage{fontspec}


\newread\dfile
\openin\dfile=text1.txt

\def\printword#1: '#2'#3pointsize:'#4'#5font_name:'#6'#7\relax{%
\fontsize{#4}{\numexpr#4+6\relax}\selectfont\dofont{#6}#2 }

\def\dofont#1{\csname do #1\endcsname}
\expandafter\def\csname do Verdana_Bold\endcsname{\bfseries\fontspec{Verdana}}

\def\partest{\par}
\begin{document}

\raggedright
\loop
\ifeof\dfile\else
\read\dfile to \tmp
\ifx\tmp\partest
\par
\else
\expandafter\printword\tmp\relax
\fi
\repeat


\end{document}

With the new question and new data file you want to use picture mode

enter image description here

This does what asked although the coordinates seem rather close for 48pt text?

The font could be scaled to a proportion (say half) of the specified size.

\documentclass{article}
\usepackage{fontspec}
\textwidth60cm
\pdfpagewidth80cm

\makeatletter
\newread\dfile
\openin\dfile=text2.txt

\def\printword#1: '#2'#3pointsize:'#4'#5font_name:'#6'#7\relax{%
\edef\tmp{\zap@space#7 \@empty}%
\expandafter\getcoords\tmp\relax
{\fontsize{#4}{\numexpr#4+6\relax}\selectfont\dofont{#6}#2}}

\def\dofont#1{\csname do #1\endcsname}
\expandafter\def\csname do Verdana_Bold\endcsname{\bfseries\fontspec{Verdana}}

\def\getcoords#1X1:'#2'#3Y1:'#4'#5\relax{%
\typeout{#2/#4}%
\put(#2,4)}
\def\partest{\par}
\begin{document}

\hspace*{-10cm}\begin{picture}(200,200)
\loop
\ifeof\dfile\else
\read\dfile to \tmp
\ifx\tmp\partest
\par
\else
\expandafter\printword\tmp\relax
\fi
\repeat
\end{picture}

\end{document}