Generated PDF does not have image included from its Handlebars template










1















app.get('/individual_report/:athlete_id', function(req, res) 
database.select('*').from('participants').then(data =>
if (data.length)
res.render('individual_report',
name: data
);
const hbsfile = fs.readFileSync(__dirname + '/../public/views/individual_report.hbs', 'utf8');
const document =
template: hbsfile,
context:
options:
dataForPDF: data,
ssl_logo: '../public/static/assets/image/white_ssl_logo.png',
,

,
path: __dirname + '/../public/reports/' + data[0].first_name + " " + data[0].last_name + ''s scores.pdf'
;
pdf.create(document, options).then(res =>
console.log(res)
).catch(error =>
console.error(error)
);
else
res.json(
msg: 'Invalid athlete ID'
);

).catch(err => res.sendStatus(400));
);


The above node express route renders a html page and also generates a PDF using the HandleBars .hbs template.



<img class="ssl_logo" src="options.ssl_logo" alt="logo.png" width="120" height="50" />


This is what I have in the .hbs file that should display the logo image file.



The image is not rendered in the browser and also in the PDF file. However, the alt attribute is rendered on the browser and in the PDF. I looked into the console log and I get this unknown at the source attribute:



img class="ssl_logo" src(unknown) alt="logo.png" width="120" height="50"



I am using the dynamic-html-pdf node package to generate this report and can anyone suggest me something that might make this works? Thank you.










share|improve this question


























    1















    app.get('/individual_report/:athlete_id', function(req, res) 
    database.select('*').from('participants').then(data =>
    if (data.length)
    res.render('individual_report',
    name: data
    );
    const hbsfile = fs.readFileSync(__dirname + '/../public/views/individual_report.hbs', 'utf8');
    const document =
    template: hbsfile,
    context:
    options:
    dataForPDF: data,
    ssl_logo: '../public/static/assets/image/white_ssl_logo.png',
    ,

    ,
    path: __dirname + '/../public/reports/' + data[0].first_name + " " + data[0].last_name + ''s scores.pdf'
    ;
    pdf.create(document, options).then(res =>
    console.log(res)
    ).catch(error =>
    console.error(error)
    );
    else
    res.json(
    msg: 'Invalid athlete ID'
    );

    ).catch(err => res.sendStatus(400));
    );


    The above node express route renders a html page and also generates a PDF using the HandleBars .hbs template.



    <img class="ssl_logo" src="options.ssl_logo" alt="logo.png" width="120" height="50" />


    This is what I have in the .hbs file that should display the logo image file.



    The image is not rendered in the browser and also in the PDF file. However, the alt attribute is rendered on the browser and in the PDF. I looked into the console log and I get this unknown at the source attribute:



    img class="ssl_logo" src(unknown) alt="logo.png" width="120" height="50"



    I am using the dynamic-html-pdf node package to generate this report and can anyone suggest me something that might make this works? Thank you.










    share|improve this question
























      1












      1








      1








      app.get('/individual_report/:athlete_id', function(req, res) 
      database.select('*').from('participants').then(data =>
      if (data.length)
      res.render('individual_report',
      name: data
      );
      const hbsfile = fs.readFileSync(__dirname + '/../public/views/individual_report.hbs', 'utf8');
      const document =
      template: hbsfile,
      context:
      options:
      dataForPDF: data,
      ssl_logo: '../public/static/assets/image/white_ssl_logo.png',
      ,

      ,
      path: __dirname + '/../public/reports/' + data[0].first_name + " " + data[0].last_name + ''s scores.pdf'
      ;
      pdf.create(document, options).then(res =>
      console.log(res)
      ).catch(error =>
      console.error(error)
      );
      else
      res.json(
      msg: 'Invalid athlete ID'
      );

      ).catch(err => res.sendStatus(400));
      );


      The above node express route renders a html page and also generates a PDF using the HandleBars .hbs template.



      <img class="ssl_logo" src="options.ssl_logo" alt="logo.png" width="120" height="50" />


      This is what I have in the .hbs file that should display the logo image file.



      The image is not rendered in the browser and also in the PDF file. However, the alt attribute is rendered on the browser and in the PDF. I looked into the console log and I get this unknown at the source attribute:



      img class="ssl_logo" src(unknown) alt="logo.png" width="120" height="50"



      I am using the dynamic-html-pdf node package to generate this report and can anyone suggest me something that might make this works? Thank you.










      share|improve this question














      app.get('/individual_report/:athlete_id', function(req, res) 
      database.select('*').from('participants').then(data =>
      if (data.length)
      res.render('individual_report',
      name: data
      );
      const hbsfile = fs.readFileSync(__dirname + '/../public/views/individual_report.hbs', 'utf8');
      const document =
      template: hbsfile,
      context:
      options:
      dataForPDF: data,
      ssl_logo: '../public/static/assets/image/white_ssl_logo.png',
      ,

      ,
      path: __dirname + '/../public/reports/' + data[0].first_name + " " + data[0].last_name + ''s scores.pdf'
      ;
      pdf.create(document, options).then(res =>
      console.log(res)
      ).catch(error =>
      console.error(error)
      );
      else
      res.json(
      msg: 'Invalid athlete ID'
      );

      ).catch(err => res.sendStatus(400));
      );


      The above node express route renders a html page and also generates a PDF using the HandleBars .hbs template.



      <img class="ssl_logo" src="options.ssl_logo" alt="logo.png" width="120" height="50" />


      This is what I have in the .hbs file that should display the logo image file.



      The image is not rendered in the browser and also in the PDF file. However, the alt attribute is rendered on the browser and in the PDF. I looked into the console log and I get this unknown at the source attribute:



      img class="ssl_logo" src(unknown) alt="logo.png" width="120" height="50"



      I am using the dynamic-html-pdf node package to generate this report and can anyone suggest me something that might make this works? Thank you.







      image express pdf-generation






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 13 '18 at 22:40









      calvertcalvert

      757




      757






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Welp, I am going to answer my own post. For some reason this piece of code is not reading the local image file, so what I did was uploading the image to google drive, get the shareable link, google how to modify the shareable link because the link that is generated will not work in our code, and replace the image file address with the link.



          Hope this will help those who is or will have this issue. (Ultimately you have to solve the problem yourself, haizzzz)






          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290579%2fgenerated-pdf-does-not-have-image-included-from-its-handlebars-template%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Welp, I am going to answer my own post. For some reason this piece of code is not reading the local image file, so what I did was uploading the image to google drive, get the shareable link, google how to modify the shareable link because the link that is generated will not work in our code, and replace the image file address with the link.



            Hope this will help those who is or will have this issue. (Ultimately you have to solve the problem yourself, haizzzz)






            share|improve this answer



























              0














              Welp, I am going to answer my own post. For some reason this piece of code is not reading the local image file, so what I did was uploading the image to google drive, get the shareable link, google how to modify the shareable link because the link that is generated will not work in our code, and replace the image file address with the link.



              Hope this will help those who is or will have this issue. (Ultimately you have to solve the problem yourself, haizzzz)






              share|improve this answer

























                0












                0








                0







                Welp, I am going to answer my own post. For some reason this piece of code is not reading the local image file, so what I did was uploading the image to google drive, get the shareable link, google how to modify the shareable link because the link that is generated will not work in our code, and replace the image file address with the link.



                Hope this will help those who is or will have this issue. (Ultimately you have to solve the problem yourself, haizzzz)






                share|improve this answer













                Welp, I am going to answer my own post. For some reason this piece of code is not reading the local image file, so what I did was uploading the image to google drive, get the shareable link, google how to modify the shareable link because the link that is generated will not work in our code, and replace the image file address with the link.



                Hope this will help those who is or will have this issue. (Ultimately you have to solve the problem yourself, haizzzz)







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 16:55









                calvertcalvert

                757




                757



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53290579%2fgenerated-pdf-does-not-have-image-included-from-its-handlebars-template%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    政党

                    天津地下鉄3号線