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.

jsPDF file is saved without any extension

See original GitHub issue

Support plan

  • Community,
  • no
  • no

Context

  • node version: 14.15.4
  • module (formidable) version: 1.2.2
  • environment (e.g. node, browser, native, OS): AWS ubuntu
  • used with (i.e. popular names of modules):
  • any other relevant information: I am using React.js .

What are you trying to achieve or the steps to reproduce?


//Nodejs
const newPath = files.autoPdf.path 

//Also tried this... It saves the string to mongodb with extension... But the file gets saved without any extension.

const newPath = `${files.autoPdf.path}.pdf`


//React.js
const pdf = new Blob([this.state.doc.output("blob")], {
        type: "application/pdf",
      });

File without any extension

# File with extension

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Zahirmasoodicommented, Feb 14, 2021

Blob does not have a name You need to use https://developer.mozilla.org/en-US/docs/Web/API/File/File Create a file instance with the blob, and there you can give it a name with the extension. Then put the file in the formData

const pdf = new File([this.state.doc.output(“blob”)], “myTest1.pdf”, { type: “application/pdf”, });

formData.append(“autoPdf”, pdf);

SOLVED! Thanks, man!

0reactions
GrosSacASaccommented, Feb 14, 2021

Blob does not have a name You need to use https://developer.mozilla.org/en-US/docs/Web/API/File/File Create a file instance with the blob, and there you can give it a name with the extension. Then put the file in the formData

Read more comments on GitHub >

github_iconTop Results From Across the Web

jsPDF saving the file without extension when sent to nodejs ...
This works fine. It saves the file with .pdf extension. Now the problem is that I am sending this file to the express.js...
Read more >
jsPDF - Documentation - GitHub Pages
jspdf.js, line 3163. Consumes the current path without any effect. Mainly used in combination with clip or clipEvenOdd. The PDF "n" ...
Read more >
Generating PDFs from Web Pages on the Fly with jsPDF
Massimo Cassandro demonstrates how to make use of jsPDF, a JavaScript library for generating PDF documents from web pages.
Read more >
How to render a PDF generated with jsPDF in a LWC
1 Answer 1 · You can get Pdfjs here · Once you download it, load that as a Static resource in Setup >...
Read more >
jspdf generate pdf file in browser in javascript - YouTube
Get the full source code of application ...
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