mikolalysenko / node-latex

node.js wrapper for LaTeX
MIT License
25 stars 20 forks source link

Graphics rendering #18

Closed matt-lindsay closed 7 years ago

matt-lindsay commented 7 years ago

Hi guys,

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 your consideration.

`var fs = require('fs');

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

fs.readFile(input, 'utf8', function (err, data) { if (err) throw err; console.log('>>> Tex file imported.'); trog.push(data); var options = { 'command': 'pdflatex' }; require('latex')(trog, 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 run compile this tex file from the terminal using the command pdflatex the image renders fine. Are you able to help me in rendering the included image please?

Thanks.

matt-lindsay commented 7 years ago

Hi guys, to follow up: I've resolved this by including the image's full path in the include statement e.g. \includegraphics[scale=1]{/home/ubuntu/workspace/pdf-production/logo.jpg}