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

convert xaml to pdf?

I'm developing a LOB app for my company.  The app has forms and auto-complete textboxes for people to fill out.  Can syncfusion convert an xaml grid to pdf similar to the new api in windows 8.1 where you can render an xaml to bitmap?


If not, how would I go about using syncfusion to convert the generated bitmap into pdf? 


9 Replies

GL George Livingston Syncfusion Team November 26, 2013 08:55 AM UTC

Hi Nate,

Thank you for using Syncfusion product.

Yes it is possible to insert the images into the PDF document. At present, we do support JPEG encoded images.  Please find the sample available in the link below,

DrawImageSample.zip

Please let us know if you need any further assistance.

Regards,

George



NS Nate Snowball November 27, 2013 01:17 AM UTC

Can you please give me an example where the image is already generated in the app and not from a file?  Remember that my app takes a snapshot of the xaml grid and creates a bitmap out of it.  What I'm trying to do now is create a pdf file out of this image.



GL George Livingston Syncfusion Team November 27, 2013 10:56 AM UTC

Hi Nate,

Thank you for your update.

We have created the sample to convert XAML to bitmap and then to PDF, Please find the sample available in the link below,

http://www.syncfusion.com/downloads/support/directtrac/116000/XamlToPdfWinRT-1905009446.zip

Please let us know if the solution helps.

Regards,

George



NS Nate Snowball November 27, 2013 05:10 PM UTC

One last question.  How do I set the page orientation?  I know it should be something obvious, but I can't seem to get it.  Many thanks.



GL George Livingston Syncfusion Team November 28, 2013 12:54 PM UTC

Hi Nate,

Thank you for your update.

Please use the below code snippet to set the page orientation, herewith we have attached the sample for your reference.

PdfDocument document = new PdfDocument();

document.PageSettings.Orientation = PdfPageOrientation.Landscape;

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/115661/XamlToPdfWinRT1456811131.zip

Please let us know if you need any further assistance.

Regards,

George



SF Syed Faisal Shah June 1, 2018 05:48 AM UTC

H,

When I try to download the sample it says access denied.


SL Sowmiya Loganathan Syncfusion Team June 4, 2018 09:56 AM UTC

Hi Nate, 

Please find the below KB link to convert XAML to PDF in UWP platform, since we have marked WinRT as classic platform. 


Please let us know if you have any concerns. 

Regards, 
Sowmiya L 



PA padmaja October 14, 2018 05:21 PM UTC

Its only converting the visible portion of the window, If the window has scroll bars or multipage, Its not converting the entire content.


KC Karthikeyan Chandrasekar Syncfusion Team October 15, 2018 12:03 PM UTC

Hi Padmaja, 
Thank you for contacting Syncfusion support. At present we do not have direct API for converting XAML to PDF. We can achieve this feature by converting the XAML to Image and then image to PDF. In this KB we have provided a work around sample for converting XAML to Image using the RenderTargetBitmap. XAML to image conversion depends on the UI element which we are given in the RenderAsync method. 

We have created a simple sample, enabled the scroll bar and added the Textbox control in bottom of the XAML page. The textbox is not visible in the current view of XAML page, and the text box preserved fine in the output PDF. Please make sure parameter of the  RenderAsync method is the parent of all UI element, so that the child controls will be preserved in the image. 

Code snippet: 
            //Create the Bitmpap from xaml page 
            await renderTargetBitmap.RenderAsync(SyncfusionForm); 
            var pixelBuffer = await renderTargetBitmap.GetPixelsAsync(); 
 
Please find the sample and output PDF below for your reference. 
Kindly check the above sample and let us know if you need further assistance on this. 
Regards, 
Karthikeyan  


Loader.
Live Chat Icon For mobile
Up arrow icon