Home > Microsoft .Net Development Tips > .NET Developer > Printing in Windows Presentation Foundation
Win Development Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

.NET DEVELOPER

Printing in Windows Presentation Foundation


Mark Shurmer
06.18.2008
Rating: --- (out of 5)


.NET Architecture Essentials Channel
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


How does printing work in Windows Presentation Foundation (WPF)? We gathered some helpful excerpts and examples from the WPF Reflections blog, by Mark Shurmer below.


If you have ever worked with printing in MFC, then printing in WPF is so advanced, as to make you dizzy. Even if you ever tried printing with Windows Forms, then printing in WPF is a bit of a revelation.

How does it work?

Most of the printing stuff is in the System.Printing namespace, and a good starting place is the PrintDialog class. By instantiating the PrintDialog class, you can display the standard XP or Vista print dialog to allow the user to choose where to print, and how.

What else does it give you?

You can call two different methods to do printing. PrintVisual allows you to print any class that derives from System.Windows.Media.Visual, which is a lot. And PrintDocument, which allows you to print any DocumentPaginator (e.g. FlowDocument or XpsDocument).

Troubleshooting tips

Your element, canvas, grid or other object may print out very small. I explain why this happens and demonstrate how you can use a Transform before printing to correct.

Also, when printing a multiple-page document from a FlowDocumentPageViewer or FlowDocumentReader, the pages may scale to the same size as the document being shown on the screen. Here's how to change the height and width of the document before printing.

If you enjoyed this article, be sure to visit the WPF Reflections blog for more Windows Presentation Foundation techniques.

   GOT DEVELOPER QUESTIONS? YOUR PEERS HAVE ANSWERS
Your fellow developers have faced the same or similar problems.
So ask your own question on the IT Knowledge Exchange community.

Rate this Tip
To rate tips, you must be a member of SearchWinDevelopment.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
.NET Developer
Visual Studio 2008 code metrics tools will help keep code clean
Downloadable MSDN library released for VS 2008 SP 1
Widgetbox provides good example of how to use Facebook Developer Toolkit
Microsoft previews new features in Visual Studio 2010
ASP.NET Ajax components: Vendor roundtable -- Part 3
Best practices of the AJAX kind
Visual Studio 2008 and .NET Framework 3.5 SP1 introduces ADO .NET Entity Designer
Check the MSDN Virtual Labs for regular, compelling new content
Book Excerpt: Sams Teach Yourself Visual Basic 2008 in 24 Hours -- Complete Starter Kit
ASP.NET Ajax components: Vendor roundtable -- Part 2

.NET Framework 3.0 design and architecture tools
WPF application speeds development, back-end integration
Designing Windows Communication Foundation service contracts
ILOG Rules for .NET integrates with Office 2007, .NET 3.0
.NET development in the trenches
Microsoft developers balancing age-old issues, barrage of new technology
SearchVB.com's Podcast Page
Visual Studio 2008 Learning Guide: Multi-targeting
Introduction to the Web Service Software Factory
Beginning Windows CardSpace development
Windows Developments: Product news, June 2007

.NET Framework 3.5 and Visual Studio 2008 development
News roundup: Microsoft will not buy Yahoo!, MLB won't use Silverlight
Microsoft offers startups free development tools, MSDN subscription
Microsoft announces promotions for Visual Studio, MSDN
Visual Studio 2008 code metrics tools will help keep code clean
Microsoft PDC gives a taste of Windows 7, Visual Studio 2010
Downloadable MSDN library released for VS 2008 SP 1
Mono 2.0 moves .NET apps to Linux - includes migration analyzer
Rise of .NET enterprise apps drives need for performance management
Book excerpt: Murach's VB 2008
Mainsoft introduces .NET-to-Java translation tool

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
.NET 3.0  (SearchWinDevelopment.com)
IronRuby  (SearchWinDevelopment.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Database Programming Solutions - .NET XML, Visual Studio LINQ, ORM .NET
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2000 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts