Convert WPF to PDF - wpf

I have a WPF application and I want to be able to save the output of the application to a PDF document, the item I want to save can be a Visual a Drawing or a FixedDocument (I can create it as any of those options, and it's easy to convert between them).
Is there any library that can convert directly from WPF to PDF (without writing code to walk the visual tree and recreate it using PDF primitives).

If you got your WPF visual tree rendered in to XPS then try this XPS to PDF converter NIXPS.

For this sceneario I recommend using XpsDocumentWriter class to get a XPS document, then converting it to PDF using Amyuni PDF Creator
Disclaimer: I work for Amyuni Technologies

We have just released a new library that facilitates this: NiPDF v1.0
Here is a link to an example on our site that converts WPF to PDF.
It is a 100% managed .NET assembly, and you don't need to learn an arcane API top be able to use it.

Related

create application like simple PowerPoint in c# wpf?

I want to create create application like simple PowerPoint in c# WPF, I meant exactly that I want to create page like slides and can arrange in time line with various speed and transition and can seeing in preview panel.I tries on Microsoft PowerPoint interoperability but as I found It just create PowerPoint file not provide framework to interact!!.
Please show me sample code or sample way to-do or how do it?
One method I have used is to have a WPF WebBrowser control and then navigate to a pptx file. This will open PowerPoint inside the WebBrowser control. You will not be able to interact with the PowerPoint application from your WPF host, but that is about as good as it gets.
Try this control from syncfusion: http://www.syncfusion.com/products/file-formats/presentation. They now offer a free community version with all if their controls.

How to annotate a PDF document in WPF

First I need to show a PDF File in an WPF application . It appears the only two ways are using a web control or some sort of WinForms/Com based solution using the Acrobat reader component.
Assuming I get it to show up in a UI my problem is I want to add annotations to the PDF itself. Is this even possible.

View PdfSharp document in a WPF control

I'm using the companion MigraDoc and PdfSharp libraries to generate a report.
The PdfSharp documentation repeatedly refers to WPF and talks about you can "draw on a PDF page as well as in a window", but I can't figure out how to view my PdfDocument in a viewer. All of the examples just kick the rendering off to another program by opening the documents with Process.Start().
Do either of these libraries include WPF controls for viewing the documents? Ideally I'm looking for a basic document viewer control, similar to the built-in RichTextEditor viewer for FlowDocuments.
(I'm using the PdfSharp and MigraDoc libraries that are distributed through NuGet.)
You can use WPF PDF Viewer. It wraps the Adobe PDF Reader COM Component as a WPF control
PDF Viewer is an ActiveX control which needed to be hosted using WindowsFormHost. If you need a WPF renderer for PDR, Adobe didnt introduced it yet. You need to create it yourself and parse the PDF document.
Here are few links which will help you how to host a PDF document on your WPF window :
http://www.codeproject.com/Articles/380019/Using-Adobe-Reader-in-a-WPF-app
http://hugeonion.com/2009/04/06/displaying-a-pdf-file-within-a-wpf-application/
Telerik has a PDF Viewer created using WPF which does the rendering of a PDF document using WPF. Its called RADPDFViewer
http://blogs.telerik.com/blogs/posts/12-02-29/introducing-pdf-viewer-for-silverlight-wpf.aspx
You have to either use one that is shipped by Adobe or you need to create it of your own just like Telerik did.

Show pdf inside silverlight application. PDF to XAML

I need to create silverlight application where customer will see some pdf files.
PDF files have to be inside silverlight control and not rendered as images (customer wants to select text)
For this purposes i need some free libriaries or code to convert pdf file to xaml (or just open pdf so i can convert it to xaml).
Which library can read pdf and help me to convert data to xaml?
Can I read somehow pdf file and write custom convertation tool?
I saw iTextSharp. Is this library can read pdf and help me with my issue?
I will be thankfull for any ideas or links.
I make use of the Acrobat Reader plugin to do the displaying for me. It does require a different method depending on whether your application is running inside or outside the browser (I check if the application is running inside the browser and change the means of display accordingly). If running inside the browser, I overlay the application with an IFrame, as I describe in this article: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-6.aspx. Otherwise, I use the WebBrowser control. I have a control which does this all for you in the source code that accompanies my book, which is downloadable from the Apress website here: http://www.apress.com/9781430272076/.
Hope this helps...
Chris

Another way to display an XPS document using WPF

I would like to ask if there are any other alternatives, aside from DocumentViewer, for displaying an XPS document in a WPF application? A ready-to-use control or class in .NET if possible.
This is because DocumentViewer is a little slow when you are scrolling through the pages.
Thanks!
No, unless there are any third-party controls that I'm unaware of.
Use NiXPS to convert your XPS document to PDF and use any PDF viewer for WPF out there. This way you will get better performance than you do with DocumentViewer.

Resources