Unable to print all pages of large documents

Hi, We use GroupDocs Viewer for .NET with asp.net core 8 application. Viewer type jpg has been set.
When I render pdf document, it correctly renders as images per page.

However for some pdfs clicking on print button, only shows few pages/blank pages/random pages etc. but doesn’t show all pages.
After digging more into this, when overall size of all the rendered images of pdf is higher more than 60 mb or so, clicking on print button print window only shows fewer pages available for printing.
Issue is seen with both chrome and edge. it doesn’t appear browser issue.

Download the sample PDF “sample_pdf_printing_problem_1.pdf” which can be used to reproduce the problem. (use the download button on the github page)

For this pdf - overall size of all rendered images with default quality set of 90 is 87mb. when we set quality to 40, overall image folder size reduces to 39 mb, and then only all pages are available for printing.

This is blocker for us as we can’t print some of large pdfs.

@sachinerande

Thank you for sharing the file. When viewer type is jpg or png we print images instead of PDF, so it could be an issue with printing the images. Images are printed to protect text from being copied from PDF.

In you use case do you need to print images or PDF files?

@vladimir.litvinchik : we would like to protect our docs and so we need only print images only as said on Groupdocs viewer for .NET - original pdfs returned to browser on clicking Print button - Free Support Forum - groupdocs.com

we are happy with what jpg viewer is doing now, but why only few images are available for printing for large documents? Images are well rendered, but when clicked on print button, print windows opens but not all pages are available there. need a fix for this issue only.

@sachinerande

Got it, we’ll take a look what may cause this issue and update you.

1 Like

@vladimir.litvinchik could you update on this please? we are blocked on lot of complaints on this problem.

@sachinerande

Unfortunately, I do not have any updates at the moment. It is in my schedule for this week. As soon as I check it I will let you know.

@vladimir.litvinchik : Thanks for letting me know, we will await on this.

@vladimir.litvinchik : This might help to troubleshoot/fix the problem.
I tried replacing in “main.js” file
looks like printing with
e.contentWindow.document.execCommand("print",!1) has a problem.

I tried following and it loads all pages in print preview window.
e.contentWindow.print()

so effectively I tried replacing and it appear to work.
printFrame(e){try{e.focus(),e.contentWindow.document.execCommand("print",!1)}catch(i){e.contentWindow.print()}
by
printFrame(e){try{e.focus(),e.contentWindow.print()}catch(i){e.contentWindow.document.execCommand("print",!1)}

May be execCommand has been deprecated.

@sachinerande

Thank you for sharing the solution. At the time when I was writing the code I have read about the deprecation but it worked well, so I decided to keep execCommand. Now I see that is wasn’t the best decision.

I’ll double check it and publish new package version.

Thanks again!

1 Like

@sachinerande

I have applied the fix that you have suggested. Print works well for a large files on my end.

I have published the fix - NuGet Gallery | GroupDocs.Viewer.UI 6.0.30.

Please note that there is also version that has the following pattern 8.0.x. This version uses UI from GroupDocs.Viewer App. See README for more details on configuration.

Package version 8.0.x is still using PDF for printing. I’ going to fix this so print feature is working the same as in 6.0.x version.