Free Support Forum - groupdocs.com

Use Print functionality without loading the Viewer on page


#1

Hello Team,


Can you please let me know when you implement api method to get print url?
We would like to print document (stream from database) with click on a button that doesn’t require a viewer to be loaded on the page first.

Thank you!

#2

Hello Deric,


Thank you for the request. We have created a Jira ticket (you can see it attached) and our Product team will investigate it and then we will notify you with the results.

Thank you.

#3

Hello Deric,

As we understood, your scenario implies that your documents are stored in the database. And you want to allow users to print them without opening documents in the GroupDocs.Viewer widget. To be honest, this feature requirement cannot be done in straightforward way, and now we will describe you, why.

When you open a document in the GroupDocs.Viewer widget, the GroupDocs.Viewer opens it and converts to the HTML-compatible form. For image-based mode the document is converted to a set of images, where each image represents one document page. Extracted text is stored in the JSON and is placed over these page images, like overlay. In HTML-based mode the document is converted to the truly HTML-based representation. And only when the document is converted, you can see it in the browser and print. That's how GroupDocs.Viewer works, because browser cannot display PDF (without Adobe plugin), MS Word, Excel, PowerPoint and so on.

Now, what about document printing. There are two printing modes. First mode - HTML-printing, assumes that GroupDocs.Viewer prepares a special HTML-version of the document, designed for printing, and then opens a print dialog using JavaScript on client-side. This method has several flaws; in particular, different browsers distort some HTML-versions, and print version looks different from original.
In order to deliver a 100% copy of original document and to secure it from distortions, GroupDocs.Viewer contains a PDF-printing mode. In this mode a PDF-copy of original document is created, and then this PDF file can be printed from the browser (if browser supports PDF-printing) or from any other software. We usually suggest this printing mode for our users as more reliable and safe.

Now you can understand why it is impossible to prepare a printing without any document processing. Which solutions we can suggest for you?

First of all, GroupDocs.Viewer contains a "DocumentCache" class, which pre-generates document cache (document cache is a ready-to-use HTML-compatible version of the original document) without opening a document. It can generate image-based or HTML-based cache. We can develop a special method, which returns a PDF-version of the specified document. In fact, it can be a usual C# method, which obtains document and returns its PDF-version, which can be sent to the client-side and then printed.
If you are interested in HTML-printing mode, this also is related to the cache generation. However in this case we need to develop a mechanism, which returns a special print-version based on existent cache.

Now, when you understand how GroupDocs.Viewer works with documents and printing and how your requirement can be theoretically solved in future releases, we are waiting for your feedback. Which printing mode you want to use? What specific scenario you tries to reach?


Best regards.


#4

Hello Pavel,


Thank you for your detailed response. When you say “PDF-printing mode” do you mean other document types or is it just PDF documents? We would like to have general solution, for all browsers (recent versions) and all supported document types (.doc, .txt etc.). So I am guessing that we have to go with HTML-printing mode. We are using HTML-based representation since it is faster than image-based representation.

#5

Hi Deric,


Thank you for the question. If to set PDF printing mode it will create pdf representation only for printing and yes it spreads to all supported file types. You still can use HTML rendering mode if to set pdf printing.

Best regards.

#6
Hello,

Need to distinguish rendering modes from printing modes. Image-based mode and HTML-based mode are rendering modes - this is how you see the document in the browser, using the GroupDocs.Viewer widget. And, yes, you're right, HTML-based rendering mode is faster and better in most of cases.

But in my description I was talked about printing modes - PDF-printing and HTML-printing modes. When using PDF-printing mode, GroupDocs.Viewer converts the input document to the PDF and delivers this PDF-version for printing. Answering to your question: yes, GroupDocs.Viewer can convert a document of any type to the PDF. Then, if browser is Google Chrome, or Adobe plugin is installed, browser can open this PDF by itself, and you can print the document from browser. Otherwise, you can save PDF to your PC and then open it using Adobe Reader, Foxit PDF Reader or any other software, and print from it.

When using HTML-printing mode, PDF-version is not involved in printing process at all. GroupDocs.Viewer generates a special HTML-version of the document for printing. But in this case some browsers can distort this representation or add their own "labels" like page numbering, datetime, URL address and so on. That's why we usually recommend to use PDF-printing.

Best regards.

#7

Hello Pavel,



Thank you for further clarifications. PDF-printing mode allows printing through certain browsers only, that is why we would choose HTML-version.


#8

Hi Deric,


Thank you for the response. I will share it with the Product team and when I will get any feedback from then I will notify you.

Thank you.