WPF Printing on Server

I was wondering if anyone knew if you can do wpf printing on the server (no UI). The printing features in WPF are great and we are using it to do some report printing on the client, but the customer also wants to be able to trigger a print job to happen on the server.

Is this supported? All the examples I've seen use a print dialog which we wouldn't be able to use.

--

Bryant

[404 byte] By [BryantLikes] at [2007-12-24]
# 1

Hey!

Did you find a solution to this? I have the same type of problem and I haven't figured out how to do it yet. Maybe it is possible to use the print dialog and set preferences in code instead of in the gui?

Any ideas?

OlleGustafsson at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...
# 2

Not sure if this will work but try this

public void PrintForm(PrintDialog printDialog)

{

if (printDialog == null) return;

PrintCapabilities printCapabilites = printDialog.PrintQueue.GetPrintCapabilities();

double width = printCapabilites.PageImageableArea.OriginWidth;

double height = printCapabilites.PageImageableArea.OriginHeight;

Size size = new Size(printCapabilites.PageImageableArea.ExtentWidth, printCapabilites.PageImageableArea.ExtentHeight);

Rect rectangle = new Rect(new System.Windows.Point(width, height), size);

this.gridForm.UpdateLayout();

this.gridForm.Measure(size);

this.gridForm.Arrange(rectangle);

XmlElement item = this.DataContext as XmlElement;

printDialog.PrintVisual(this.gridForm, "Incident No. (" + item.GetAttribute("number") + ")");

if (printHistory)

{

PrintableHistory window = new PrintableHistory();

window.DataContext = this.DataContext;

window.PrintForm(printDialog);

}

}

public void PrintForm()

{

PrintForm(new PrintDialog());

Close();

}

What we does is create the window, call the public PrintForm method that prints the form use the PrintDialog that isn't shown.

The big thing that we found is that we had to UpdateLayout, Measure and Arrange only the component (the grid) that we were going to print not the window.

Hey presto, no dialog.

Not sure if this will work from a Windows service.

KerryJones at 2007-8-31 > top of Msdn Tech,Visual Studio Orcas,Windows Presentation Foundation (WPF)...

Visual Studio Orcas

Site Classified