React-to-print: Default Filename in save as PDF

Created on 18 Apr 2019  路  8Comments  路  Source: gregnb/react-to-print

I am trying to give default filename for the save as pdf option in react-to-print.

good first issue help wanted

Most helpful comment

I resolved that by adding Filename tag at the top of my component that is to be print.Thanks all.

Sadly, I am not able to make it work with Chrome (Version 77.0.3865.90 (Official Build) beta (64-bit) on OSX Mojave 10.14.6 but I am not sure if it depends of chrome version). But it seems to work perfectly with firefox.

Edit: Okay, I think I've figured it out: I believe Chrome takes the highest title tag to define the title of the print export, at the contrary of Firefox, which takes the lowest.

All 8 comments

Pull requests are welcome to add support for this :)

I would probably say no to this feature only because we would need to bring in jsPDF which doesn't really generate quality PDF's on top of the cost of importing that library.

Thoughts @MatthewHerbst ?

Oh, my understand of the issue was to just be able to set a default file name in the print preview, irregardless of what is being printed. @abdurrehman1998 can you expand on what functionally you are looking for please?

You're right I misread that. I tried digging around and seems like this would work in Chrome:

https://stackoverflow.com/questions/26905908/chrome-save-to-pdf-custom-filename

but I don't see much about other browsers

I resolved that by adding Filename tag at the top of my component that is to be print.Thanks all.

I resolved that by adding Filename tag at the top of my component that is to be print.Thanks all.

Sadly, I am not able to make it work with Chrome (Version 77.0.3865.90 (Official Build) beta (64-bit) on OSX Mojave 10.14.6 but I am not sure if it depends of chrome version). But it seems to work perfectly with firefox.

Edit: Okay, I think I've figured it out: I believe Chrome takes the highest title tag to define the title of the print export, at the contrary of Firefox, which takes the lowest.

Thanks for the insight @qron!

I used ' document.title="the-name-of-the-pdf-file"; ' to set title of the page,and turns out it worked(edge firefox and chrome).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

404sand808s picture 404sand808s  路  7Comments

theghostyced picture theghostyced  路  8Comments

hoangdoan267 picture hoangdoan267  路  8Comments

MikeSha picture MikeSha  路  4Comments

AJTJ picture AJTJ  路  4Comments