Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdfmake conflict with file-saver #1634

Closed
nickolas1 opened this issue Feb 11, 2019 · 7 comments
Closed

pdfmake conflict with file-saver #1634

nickolas1 opened this issue Feb 11, 2019 · 7 comments

Comments

@nickolas1
Copy link

In my app I am importing pdfMake and downloading a pdf like so:

import * as pdfMake from 'pdfmake/build/pdfmake';
import * as pdfFonts from 'pdfmake/build/vfs_fonts';

pdfMake.vfs = pdfFonts.pdfMake.vfs;

//create document definition here

pdfMake.createPdf(docDefinition).download(`${docTitle}.pdf`);

This works fine. However, after this I added a dependency to the same file-saver version used by pdfMake (^2.0.0). As soon as I

import { saveAs } from 'file-saver';

elsewhere in my code, pdfMake silently fails downloading. Depending on an earlier version of file-saver (e.g. 1.3.8) resolves the issue, but this is not a great solution.

@talamatur
Copy link

talamatur commented Feb 12, 2019

happens to me too. Using Angular 7
Using PDFMake 0.1.40 or 0.1.51 and file-saver 2.0.0
downgrading file-saver to 1.3.1 works for me
duplicate/ related of #1599

@liborm85
Copy link
Collaborator

Is some error throwed?

@nickolas1
Copy link
Author

@liborm85 no error, it fails silently

this does seem related to that other ticket, @talamatur. Just to be very clear on what I've found when using pdfmake ^0.1.50

  • If my app does not have filemaker as a dependency, download works as expected.
  • If my app depends on the same version of file-saver that pdfmake was built with, download fails. Other file-saver actions in my app still work.
  • If I downgrade my app's file-saver dependency, download works. Other file-saver actions in my app work.

@tcsaddul
Copy link

tcsaddul commented Feb 12, 2019 via email

@nickolas1
Copy link
Author

looking at the issues in the file-saver repo I suspect the way that package is bundled (specifically eligrey/FileSaver.js#498) is the root cause, not an issue with pdfmake

@alexmller
Copy link

alexmller commented Feb 17, 2019

I can confirm that building pdfMake 1.5.2 (or 1.4.0) with FileSaver.js 1.3.8 make the download-function work again while building it with 2.0.0 breaks it.

There is no test setup in the FileSaver.js repository to ensure proper regression, leaving it in the dark where exactly the root cause is of this issue is.

As a workaround, I suggest to release pdfMake with 1.3.8 FileSaver.js unless there is a real need for the changes that subsequent releases introduce.

@liborm85
Copy link
Collaborator

Upgraded file-saver to 2.0.1.

New version 0.1.53 released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants