Click here to Skip to main content
15,890,882 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: How to download executable file Pin
fjparisIII24-Feb-10 13:42
fjparisIII24-Feb-10 13:42 
GeneralRe: How to download executable file Pin
Matt Cavanagh24-Feb-10 13:45
Matt Cavanagh24-Feb-10 13:45 
GeneralRe: How to download executable file Pin
fjparisIII24-Feb-10 14:12
fjparisIII24-Feb-10 14:12 
QuestionRIA Services and Silverlight Pin
jonatan_55623-Feb-10 4:36
jonatan_55623-Feb-10 4:36 
QuestionLogin persistence Pin
Etienne_12323-Feb-10 3:10
Etienne_12323-Feb-10 3:10 
QuestionHost a new page [modified] Pin
Yonathan111122-Feb-10 21:29
professionalYonathan111122-Feb-10 21:29 
AnswerRe: Host a new page Pin
ToddHileHoffer24-Feb-10 6:57
ToddHileHoffer24-Feb-10 6:57 
QuestionPrinting nested WPF Custom Controls to XPS (and PDF) Pin
mmsinclair22-Feb-10 5:10
mmsinclair22-Feb-10 5:10 
Hi there,

Hoping someone can help me with some issues I am having printing custom WPF controls. I have custom publishing application with a lot of WPF Custom Controls which host other Custom Controls - I would like to print these controls to XPS (or ideally PDF) so that they can be sent to a print house to be printed. The ideal format for me would be PDF, although in theory I should be able to convert XPS to PDF with the myriad of applications out there (currently I've used PDFCreator, Ghostscript, gDoc, PDFsharp, to name a few). I also use lots of render transforms and layout transforms to position visuals and control their size and orientation.

My main requirement is that the output file is a vector image and not a bitmap. Print media requires very high quality files, or the result looks awful!


The questions I'm hoping the smart members of the CodeProject can help me with are:

1. Has anyone done some preprocessing on a tree of Custom Controls and somehow converted them to more primitive WPF drawing components, like paths and formatted text? (This will help remove the dependency on the data).

2. Is there a way to create an XPS file well so that large amounts of image data are converted by PDFsharp (or similar) properly?



There are two approaches I've tried, each with its own set of problems:

1. Write the custom control as a Visual to an XPS fixed page document. Then convert to PDF using PDFsharp or PDFCreator.

2. Render the custom control to a high resolution bitmap, place the Image in a Canvas, create an XPS document, then convert to PDF. (My reason of not creating a PDF file directory, is that I would like to overlay other WPF controls on top of the bitmap, if possible). I'd like to avoid this.


The problems I've come across for each are:

1. Custom controls written to XPS file
a. Not all of the controls are rendered properly in the XPS viewer.
b. Strangely, if I print to PDF using PDF Creator from the XPS viewer, the controls that didn't display before get magically printed to the PDF file as bitmap images.
c. Bitmap images display in the XPS viewer, but don't convert to PDF (even though the image stream is inside the PDF file with bounding boxes!).

2. Render to high resolution bitmap
a. I lose the vector data, so I need to make sure the resolution of the output image matches the printing device and could result in odd edge and aliasing artifacts.
b. PDFsharp seems to think an Image in a Canvas is like a bitmap pattern. Why is it doing this? Any ideas on how to write a single image (without tiling) to a XPS file?
c. Writing the image directly to a PDF file is very easy, but this isn't what I want to do. I need to overlay the image with WPF Custom Controls.


Is there some way to open a RenderContext and then "render" the contents to a DrawingVisual?

Could this be a serialization issue in one of the classes my Custom Controls reference? I have vague recollections that these get obfuscated and stored inside the XPS file?


I'll be really indebted to anyone who could help. I'm really hoping there is a simple-ish way to do this. It could even by something like implementing some interfaces in my controls that allow WPF to traverse the nested Custom Controls, or to try to strip out all of the internal visuals. Or to make the WPF printing process use the Visuals inside my Custom Controls directly, rather than needing bound data. Or there is a way to do this using the framework and it's yet another wing of WPF to explore!

Many thanks
Mark



p.s. I have one final constraint: I can't buy any 3rd party components, so the "ultimate XPS to PDF converter" component that you may have would not be an option for me! For this project, I need to be cheap and write my own code.
QuestionHow I get Application_Exit Eventhandler in javascript code Pin
xodeblack22-Feb-10 4:24
xodeblack22-Feb-10 4:24 
AnswerRe: How I get Application_Exit Eventhandler in javascript code Pin
Daniel Vaughan25-Feb-10 7:04
Daniel Vaughan25-Feb-10 7:04 
Questionsilverlight (strange) [modified] Pin
Yonathan111121-Feb-10 21:21
professionalYonathan111121-Feb-10 21:21 
QuestionChildWindow Odd Behaviour Pin
Jammer21-Feb-10 6:36
Jammer21-Feb-10 6:36 
QuestionWPF DataGrid: Clipping on ColumnHeadersPresenter Pin
Mikey_H20-Feb-10 20:52
Mikey_H20-Feb-10 20:52 
QuestionDispose called on Window forms Dynamic controls Pin
Member 336560720-Feb-10 7:06
Member 336560720-Feb-10 7:06 
AnswerRe: Dispose called on Window forms Dynamic controls Pin
Luc Pattyn21-Feb-10 4:53
sitebuilderLuc Pattyn21-Feb-10 4:53 
Questioncreate a text blocked kind contact in hotmail Pin
rafaelht310819-Feb-10 13:09
rafaelht310819-Feb-10 13:09 
QuestionWPF Grid double clicked event Pin
sughasini18-Feb-10 23:08
sughasini18-Feb-10 23:08 
AnswerRe: WPF Grid double clicked event [add timmer] Pin
ProtoBytes19-Feb-10 4:30
ProtoBytes19-Feb-10 4:30 
QuestionHow to hide a control when its available space is too small Pin
daniel radford18-Feb-10 22:30
daniel radford18-Feb-10 22:30 
AnswerRe: How to hide a control when its available space is too small Pin
ProtoBytes19-Feb-10 4:31
ProtoBytes19-Feb-10 4:31 
QuestionSDK trouble in WPF Pin
Etienne_12318-Feb-10 6:07
Etienne_12318-Feb-10 6:07 
AnswerRe: SDK trouble in WPF Pin
Pete O'Hanlon18-Feb-10 9:51
mvePete O'Hanlon18-Feb-10 9:51 
GeneralRe: SDK trouble in WPF Pin
Etienne_12321-Feb-10 3:51
Etienne_12321-Feb-10 3:51 
QuestionText Box Validation in C#, not XAML? Pin
MattFunke18-Feb-10 4:49
MattFunke18-Feb-10 4:49 
AnswerRe: Text Box Validation in C#, not XAML? Pin
Stryder_118-Feb-10 6:17
Stryder_118-Feb-10 6:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.