We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Printing with DocIO UWP

Hi guys!


I just wanted to know if someone has a workaround to print generated Docx directly or via pdf or any other solutions from an UWP app?

Seems that doc.renderasImage isn't in UWP library


Regards,

romane



18 Replies

SV Sarathkumar V Syncfusion Team November 25, 2015 06:38 AM UTC

Hi Romane,

Thank you for using Syncfusion products.

You can use SfRichTextBoxAdv control to load Word documents. Using GetPageAsImageAsync() method, you can retrieve the page in SfRichTextBoxAdv as BitmapImage by specifying the page number. You can then print these bitmap images using PrintManager. We have prepared a sample to demonstrate the same. Please do find the sample from below link.

Sample Link:
http://www.syncfusion.com/downloads/support/forum/121264/ze/SfRichTextBoxAdv_UWP_Print474028334.zip

Please let us know if you have any other queries.

Regards,
Sarath



RD Romane Donnet November 25, 2015 09:23 AM UTC

Hi Sarath!
Thanks for your quick answer!

Your sample seems very promising but when I tested it, it doesn't seems to work... after I re-linked the references to syncfusion UWP docIO and the other then the projets achived to compile. I started it and seemed to work at first. Then I double clicked on a docx file generated on Office 365 Word but the "await richTextBoxAdv.LoadAsync(stgFile);" method doesn't seems to work :( It doesn't bug or breakpoint it just says nothing and doesnt display anything on the screen. When i try to print it says that the pdf fil is corrupt and with a normal printer doesnt work as well.




AP Arumuga Perumal S Syncfusion Team November 26, 2015 07:05 AM UTC

Hi Romane,

Please find the modified sample to illustrate loading word documents into SfRichTextBoxAdv control and printing contents from the following link.

Sample Link:
Sample

If you have installed Essential Studio for Universal Windows in your machine, you can refer our Syncfusion UWP assemblies from following location.

Assembly Reference:
$system drive: \Program Files\Syncfusion\Essential Studio\version \Assemblies for Universal Windows\10.0\

Eg:
C:\Program Files\Syncfusion\Essential Studio\13.3.0.7 \Assemblies for Universal Windows\10.0\

If the problem still persists, please share us the input document so that we can investigate on it further and provide you with proper solution.

Regards,
Arumuga Perumal S.



RD Romane Donnet November 27, 2015 12:47 PM UTC

Hi!

Your sample works your were right about the assemblies! I was importing them from :

C:\Program Files (x86)\Syncfusion\Essential Studio\13.3.0.7\Universal Windows\10.0\SDK\References\CommonConfigurationeutral

As soon as i have imported from :

C:\Program Files\Syncfusion\Essential Studio\13.3.0.7 \Assemblies for Universal Windows\10.0\
It started to work!!

Next question :
I saw that the generation was in few steps : Selecting, loading into richtextBox, generating bitmap, printing.
1. My concerne is that the bitmaps generated are really ugly!! 
2. Is it mendatory to have a print preview? can't i just launch the printmanager without it?
3. I'm trying to make a silent print a the end for my customer. I mean he click on a button that takes a template modifies it and direclty print it without prompting anything on UWP do you think its possible?

My document generation works perfectly! Thanks to you! I have a beautiful Word document generated really fast! 2 secondes for 100 pages!! But i'm wondering why is it so difficult to just print a word document from an app...
I know for fact that you can't call system commands anymore in UWP like "winword.exe myfile.doc /p /q" to print silently something but isn't there any workaround?

Thanks a lot!!!!


AP Arumuga Perumal S Syncfusion Team November 30, 2015 12:22 PM UTC

Hi Romane,

Thank you for your update.

We are glad to hear that the sample is working fine at your end.

Regarding “Query 1”:
At this moment, there is no direct support for printing contents from SfRichTextBoxAdv control in Universal Windows Platform and printing is achieved only by BitmapImage of pages in SfRichTextBoxAdv control. Direct printing of contents will enhance the image quality. We have already logged this requirement as a feature request and this will be implemented in our next Essential Studio main release 2015 Volume 4. We request to check our website periodically for feature related updates.

Regarding “Query 2, 3 & 4”:
It is mandatory to show print preview and it is not possible to print directly without prompting Print Preview UI in Universal Windows apps. For more information, kindly refer the MSDN forum from following link.

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/fe210048-e463-408d-8351-de0cd1d1cf70/uwpprinting-without-preview?forum=wpdevelop

Regards,
Arumuga Perumal S.


MC Molino Charles June 8, 2017 01:05 PM UTC

Hi,

Is it possible to do the same but with Excel Document ?
I search a way to print it to PDF consedering that it's not possible to convert Excel to pdf in UWP.

Regards, 
Charles


AP Arumuga Perumal S Syncfusion Team June 9, 2017 11:11 AM UTC

Hi Charles

Thank you for contacting Syncfusion support

Currently, our Syncfusion XlsIO library don’t have support for Excel to PDF conversion in UWP platform. We have added it to our feature request list and it will be implemented in any of our upcoming releases. However, we have created a sample to convert an Excel file into PDF in UWP platform using web services which can be downloaded from the below link.

Excel to PDF Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/ExcelToPDF-42963853

We request you to host the service from your side to convert Excel document into PDF in UWP platform and the web service sample can be download from the below link.

Web Service Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/WebServices1853215665  

Regards,
Arumuga Perumal S. 



MC Molino Charles June 9, 2017 11:26 AM UTC

Hi,
I tried this sample and it works well with le excel document you provide, but when I try with my excel document, the pdf still looks like the older one and I don't understand why.

Regards, 
Charles


SS Sridhar Sukumar Syncfusion Team June 12, 2017 05:34 AM UTC

Hi Charles, 
 
We need to have the actual Excel file that is causing the issue as to investigate further on this, as we suspect that the issue raises only in the particular document. You can also create an incident from Direct-Trac to share your Excel document for further investigation. The documents shared will not be disclosed and used only for testing purpose. 
  
Regards, 
Sridhar. 



MC Molino Charles June 12, 2017 07:18 AM UTC

Hi,
I tried with 3 differents excel document and I changed the document name inside " assembly.GetManifestResourceStream() " nothing append.
And if I keep ExceltoPDF.xlsx inside the function and rename my document ExceltoPDF.xlsx, the PDF doesn't change.
The only difference I see between your document and mine is the size, your document is 36KB and mines are 6032KB or 531KB.

Regards,
Charles.

Attachment: Doc_ca334606.rar


MC Molino Charles June 13, 2017 10:17 AM UTC

Hi,
Sorry for bothering you again, I am currently looking for printing word document and I use this sample but the quality is very bad because It use images.
I want to know if there is a way to do it differently.
And if it's possible to direct print to pdf.

Regards, 
Charles


SS Sridhar Sukumar Syncfusion Team June 13, 2017 11:06 AM UTC

Hi Charles, 
  
Thank you for updating us. 
  
We suspect that the issue might be raised due to the input document is not added into embedded resource. The input document should be added into embedded resource in UWP application to manipulate it. Please refer the following screenshot to achieve this. 
 
Screenshot: 
 
 
 
We have also modified the sample for this which can be downloaded from the following location. 
  
Sample link:  
  
Regards, 
Sridhar. 



MC Molino Charles June 13, 2017 11:38 AM UTC

Hi,
Thanks for the quick answer but it doesn't work, but don't worry I will find another way.
Currently I want to know how to print word document to PDF with better quality.
Right now the pdf is print as an image and I don't want that.

Thanks you again, 
Regards,
Charles


VM Venkatesan Mani Syncfusion Team June 13, 2017 01:15 PM UTC

Hi Charles,

Thank you for your update.

In our SfRichtTextBoxAdv control we have provided support for built in printing and PageLayout for Mobile devices. Kindly update to latest version of Essential Studio version 15.2.0.43. It is available for download under the following link.

https://www.syncfusion.com/forums/130773/essential-studio-2017-volume-2-service-pack-release-v15-2-0-43-available-for-download

Please find the release notes from the following link:
https://help.syncfusion.com/uwp/release-notes/v15.2.0.40?type=all#sfrichtextboxadv

We have prepared a sample to demonstrate the built-in printing support using the command in SfRichTextBoxAdv control. Please find the sample from the below link:

Sample link:
Sample.zip.

API reference link for PrintDocumentCommand: https://help.syncfusion.com/cr/cref_files/uwp/sfrichtextboxadv/frlrfSyncfusionUIXamlRichTextBoxAdvSfRichTextBoxAdvClassPrintDocumentCommandTopic.html

Note: The print support works properly from Windows 10 Anniversary Edition (10.0; Build: 14393). In the previous editions, there is a known issue with content misalignment In UWP PrintManger. Kindly refer the MSDN forum from following link.
MSDN link:
https://social.msdn.microsoft.com/Forums/windowsapps/en-US/79b55ad0-9479-4d99-92c2-58b79480849a/uwp-problems-with-printing?forum=wpdevelop    

Regards,
Venkatesan M.




MC Molino Charles June 14, 2017 07:49 AM UTC

Hi,

Thanks you very much, that's perfect.

Regards, 
Charles


VM Venkatesan Mani Syncfusion Team June 15, 2017 04:46 AM UTC

Hi Charles,

Thank you for your update.

Please let us know if you require any further assistance. We will be happy to assist you.

Regards,
Venkatesan M. 



MC Molino Charles July 4, 2017 08:36 AM UTC

Hi,

I just wanted to know if it was possible to do the same ( print word document ) but with an Excel document ?

I know that SfRichTextBoxAdv can't open Excel document but maybe an other control could and would allow me to print it ?

Regards,

Charles



VM Venkatesan Mani Syncfusion Team July 5, 2017 01:13 PM UTC

Hi Charles,

Thank you for your update.

Our SfSpreadsheet control allows you to view/edit the excel documents. At present our SfSpreadSheet control does not have printing support. We have already logged this requirement as feature request. We will implement these features in any of our forthcoming releases. We usually have a timeframe of at least three months between releases. The feature implementation would also greatly depend on the factors like product design, code compatibility and complexity. We request you to visit our website periodically for feature related updates.

Regards,
Venkatesan M. 


Loader.
Live Chat Icon For mobile
Up arrow icon