You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, first of all—thanks for the great library! I'm using @react-pdf-viewer/print along with @react-pdf-viewer/core and everything works smoothly when rendering the PDF using the component.
However, I'd like to request a feature that allows printing a PDF without rendering it into the DOM using .
❓Use Case:
I have a use case where I want to programmatically print a PDF (e.g., shipping label) without showing it to the user in the interface. Currently, the printPlugin().print() method only works after has been rendered and loaded into the DOM. If Viewer is not mounted, print() doesn't do anything.
🧩 What I tried:
const printPluginInstance = printPlugin();
const { print } = printPluginInstance;
print(); // Doesn’t work unless is mounted
🛠️ Feature Suggestion:
Expose a method in the printPlugin that allows printing a PDF from a URL directly, without requiring to be rendered. Example API idea:
Render pages into an off-screen canvas or hidden iframe
Trigger the browser's print dialog
🔄 Workaround:
Right now, the only way to achieve this is by manually creating an iframe with the PDF URL and triggering iframe.contentWindow.print(), but this approach:
Has cross-origin limitations
Doesn’t allow control over page size or print layout
Doesn't benefit from the plugin’s customization options
✅ Expected Outcome:
Ability to print a PDF directly via plugin, without visually rendering it.
Works in headless or minimized UI workflows (e.g., batch label printing).
Let me know if this is feasible or if there’s any recommended workaround using existing APIs!
Thanks again for your great work 🙏
The text was updated successfully, but these errors were encountered:
Hi, first of all—thanks for the great library! I'm using @react-pdf-viewer/print along with @react-pdf-viewer/core and everything works smoothly when rendering the PDF using the component.
However, I'd like to request a feature that allows printing a PDF without rendering it into the DOM using .
❓Use Case:
I have a use case where I want to programmatically print a PDF (e.g., shipping label) without showing it to the user in the interface. Currently, the printPlugin().print() method only works after has been rendered and loaded into the DOM. If Viewer is not mounted, print() doesn't do anything.
🧩 What I tried:
const printPluginInstance = printPlugin();
const { print } = printPluginInstance;
print(); // Doesn’t work unless is mounted
🛠️ Feature Suggestion:
Expose a method in the printPlugin that allows printing a PDF from a URL directly, without requiring to be rendered. Example API idea:
const printPluginInstance = printPlugin();
await printPluginInstance.printFromUrl(pdfUrl);
This could internally:
Use PDF.js to load the file
Render pages into an off-screen canvas or hidden iframe
Trigger the browser's print dialog
🔄 Workaround:
Right now, the only way to achieve this is by manually creating an iframe with the PDF URL and triggering iframe.contentWindow.print(), but this approach:
Has cross-origin limitations
Doesn’t allow control over page size or print layout
Doesn't benefit from the plugin’s customization options
✅ Expected Outcome:
Ability to print a PDF directly via plugin, without visually rendering it.
Works in headless or minimized UI workflows (e.g., batch label printing).
Let me know if this is feasible or if there’s any recommended workaround using existing APIs!
Thanks again for your great work 🙏
The text was updated successfully, but these errors were encountered: