JsObjExporter icon indicating copy to clipboard operation
JsObjExporter copied to clipboard

Type: “PDF” does not change the file name:

Open abvas opened this issue 5 years ago • 5 comments

Type: “PDF” does not change the file name: No matter what is in fileName, the file name is equal to the page title. Tell me what I'm doing wrong. Thankyou.

abvas avatar May 31 '20 15:05 abvas

Hi there. Thanks for using this library. You are doing nothing wrong. This is indeed a bug which affects pdf printable. I will work on it in the coming days and will keep you updated.

gharibi avatar Jun 01 '20 10:06 gharibi

Thank you so much. I will wait for a solution to the problem.

abvas avatar Jun 01 '20 15:06 abvas

The printer which actually generates the pdf is fired by the execCommand.print(). In fact it is the browser which fires up the print dialog. Unfortunately from the code we don't have any access to these methods. In some cases object.src=<title> can be used but for our case it won't work as we have a framework.

There is one solution which is not the best and is to change the page title to your file name right before the print job triggers. Afterwards you can set the page title back to what it was.

gharibi avatar Jun 04 '20 17:06 gharibi

Is it worth looking into https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeprint to change title before print and then move it back to what it was after print has happened.

mfsbo avatar Apr 03 '22 23:04 mfsbo

@mfsbo could you give it a try to resolve this issue with your suggestion?

gharibi avatar Sep 18 '22 08:09 gharibi