question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with Image rendering.

See original GitHub issue

Thanks for the Plugin. It made my work so easy. I am facing only one issue. I have created a pdf for a HTML table and added an image as header. It is working fine. But I have another feature where I need to send the pdf via email. So I am doing the following,

  1. Create a pdf on the client side side using jspdf and jspdf-autotable.
  2. Sending it to server (NodeJS) using FormData.
  3. When I send the image all the elements in the pdf are intact except the header image which is not getting rendered properly.

Clinet side: (AngularJS)

  var doc = pdfService.createPdf( ... ); // This steps gives me the pdf in expected format.
  var fileName = "Expense_Reporting.pdf";
  var uploadData = new Blob([doc.output()], {
                    type: 'application/pdf'
                });
  var formData = new FormData();
  formData.append("pdf", uploadData, fileName);
  var request = new XMLHttpRequest();
  request.open("POST", "/mailapi/sendmail");
  request.send(formData);

Server Side (NodeJS)

var fs = require('fs');
var formidable = require('formidable');
// other code 
form.parse(req, function(err, fields, files) {
   mFileName = files.pdf.name;
   mFileType = files.pdf.type;
});

form.on('end', function() {
   mFilePath = this.openedFiles[0].path;
}

When I open the file it looks as below,

image_issue_git

Note: When the same pdf doc is downloaded on client side it working great.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ChandniGondhiyacommented, Feb 23, 2016

@simonbengtsson : I found the solution as below from : http://www.codediesel.com/nodejs/processing-file-uploads-in-node-js/

var express = require(‘express’); var app = express(); var fs = require(‘fs-extra’); var http = require(‘http’); var bodyParser = require(‘body-parser’); var util = require(‘util’); var formidable = require(‘formidable’), form = new formidable.IncomingForm();

http.createServer(function(req,res){ if (req.url == ‘/’ && req.method.toLowerCase() == ‘post’) {
var form = new formidable.IncomingForm(); form.parse(req, function(err, fields, files) { res.writeHead(200, {‘content-type’: ‘application/pdf’,“Access-Control-Allow-Origin”: “*”}); res.write(‘received upload:\n\n’); res.end(util.inspect({fields: fields, files: files})); });

     form.on('end', function(fields, files) {         

        var temp_path = this.openedFiles[0].path;           
        var file_name = this.openedFiles[0].name;            
        var new_location = 'C:/wamp/www/pdfs/';

        fs.copy(temp_path, new_location + file_name, function(err) {  
            if (err) {
                console.error(err);
            } else {
                console.log("Successfully copied to destination folder!")
            }
        });
    }); 
    return;
}

}) .listen(3000, function() { console.log(‘Server app listening’); });

With this code, I am able to perfectly save a pdf generated by jsPDF and html2canvas on the server.

0reactions
sureeebabucommented, Nov 7, 2017

how to Generate same autoTable in two different places

Read more comments on GitHub >

github_iconTop Results From Across the Web

image-rendering - CSS: Cascading Style Sheets | MDN
The image-rendering CSS property sets an image scaling algorithm. The property applies to an element itself, to any images set in its other ......
Read more >
Image Rendering Issues - Oxygen XML Editor
Problem I encounter image rendering issues in Oxygen XML Web Author . Cause This happens when your documents contain images that are in...
Read more >
Rendering issues in Outlook and how to fix them
Background not rendering. Solution: Unfortunately, Outlook 2007 – 2013 does not support background images. If you want the background image to show on...
Read more >
iOS11 image rendering issues - css - Stack Overflow
What I am doing is lazyloading a list of images on scroll but randomly some images fail to render. I have tried debugging...
Read more >
Unexpected image rendering behavior in the Library module
Solutions to resolve the image display or rendering problems in the Library module in Lightroom Classic CC 7.0.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found