Reputation: 117
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.
Upvotes: 0
Views: 1668
Reputation: 6412
It's probably the case that the latex run is done in some temporary directory and the image is not found there. Try changing the \includegraphics
to have the full path of the image:
\includegraphics[scale=1]{/full/path/to/directory/containing/logo.jpg}
Upvotes: 1
Reputation: 1243
Can you please change your .tex
file to this and give try? Also if you have perl installed, you can use the command latexmk -pdf
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{figure}
\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{figure}
\end{document}
Upvotes: 0