splunk
splunk

Reputation: 6815

Cannot set a custom filename to a document when saving it as PDF using ReactToPrint

I'm using the react-to-print library for printing a document. Basically when I click a button the following function is called for managing the printing:

const handlePrint = useReactToPrint({
    documentTitle: subject,  // I want the downloaded file to have subject variable value as filename
    content: () => componentRef.current,
    onAfterPrint: () => setIsPrinting(false)
});

On localhost everything works fine, but in production, the React application is embedded in an iframe. This seems to cause a problem with the name of the document that is downloaded.

Instead of what is specified in documentTitle attribute the filename is the same as the page title of the page that embeds my react app.

Is there a way to set a custom name to the downloaded file even if the printed element is inside an app embedded in an iframe?

Upvotes: 1

Views: 42

Answers (0)

Related Questions