Monday, 8 May 2017

node-latex image rendering

I'm trying to use LaTeX's graphicx package to include a JPEG image in a template, but the package doesn't seem to render that image. I might be omitting something of course, but I have included my code below for consideration.

I am using a containerised Ubuntu 14.04 instance in Cloud 9, texlive-full package and node v6.10.2.

var fs = require('fs');

var input = process.argv[2];
var output = process.argv[3];
var temp = [];

fs.readFile(input, 'utf8', function (err, data) {
  if (err) throw err;
  console.log('>>> Tex file imported.');
  temp.push(data);
  var options = { 'command': 'pdflatex' };
  require('latex')(temp, options).pipe(fs.createWriteStream(output));
  console.log('>>> Tex file built.');
});

My tex file is as follows:

\documentclass{article} \usepackage{graphicx} \begin{document} 
\begin{center} \includegraphics[scale=1]{logo.jpg} \newline \Large NOTICE \end{center}
\sffamily Account Number: \textit{12345678} \newline
\newline MR A TEST
\newline 2 THE STREET
\newline FARNBERRY
\newline CLOUD TOWN
\newline GU15 3AA \newline
\newline Amount: 1078.52
\newline Financial Year: \textbf{2017}
\newline
\newline \small{Footer text}
\end{document}

If I compile this tex file from the terminal using the command >pdflatex filename.tex the image renders fine in a PDF. Are you able to help me in rendering the included image please?

Thanks.



via Matt Lindsay

No comments:

Post a Comment