MULTIMEDIA

Silverlight : Print a Document

10/9/2010 4:45:30 PM
Silverlight 4 now contains printer support which you can easily take advantage of.

In Silverlight, to print, all you need to do is generate any UIElement-derived object and pass it to the printing system, as this code demonstrates:

private void buttonPrint_Click(object sender, RoutedEventArgs e)
{
PrintDocument doc = new PrintDocument();
doc.PrintPage += new EventHandler<PrintPageEventArgs>(doc_PrintPage);
doc.Print();
}

void doc_PrintPage(object sender, PrintPageEventArgs e)
{
//simply set the PageVisual property to the UIElement
//that you want to print
e.PageVisual = canvas;
e.HasMorePages = false;
}

The PrintPage event handler sets the PageVisual property to whatever control you want printed—it’s as easy as that.

Other  
  •  Silverlight : Capture a Webcam
  •  Silverlight : Make Your Application Run out of the Browser
  •  Silverlight : Put Content into a 3D Perspective
  •  Silverlight : Response to Timer Events on the UI Thread
  •  Silverlight : Build a Download and Playback Progress Bar
  •  Silverlight : Play a Video
  •  C# 4.0 : Add a Static Constructor and Initialization
  •  C# 4.0 : Add a Constructor
  •  .NET Compact Framework : Font Selection
  •  .NET Compact Framework : Drawing Text
  •  Programming the Service Bus
  •  WCF Services : Generics
  •  WCF Services : Delegates and Data Contracts
  •  WCF Services : Enumerations
  •  WCF Services : Versioning
  •  WCF Services : Data Contract - Equivalence
  •  WCF Services : Data Contract - Hierarchy
  •  WCF Services : Data Contract - Attributes
  •  Executing Work on a Background Thread with Updates
  •  Persisting Data on the Client with Silverlight 4
  •  
    Top 10
    What’s New In Speakers? – April 2013 (Part 3)
    What’s New In Speakers? – April 2013 (Part 2)
    What’s New In Speakers? – April 2013 (Part 1)
    Genius LuxePad 9100 Bluetooth Tablet Keyboard
    Philips Hue - Color Your World
    Supertooth HD Voice - Cup On And Start Talking
    Sathero SH200 - A Lightest Digital Satellite TV Signal Meter
    Ferguson Ariva 102 Mini - The Smallest HD Receiver
    Canon EOS M - Live Up To Its Pedigree?
    On The Origin Of PCs
    Most View
    Give Your Tablet A New Lease Of Life (Part 1)
    Exchange Server 2007: Recover a Non-Mailbox Role
    Toshiba Stor.E Steel S Titanium 500GB
    Smali Form Factor Cases (Part 3) - Silverstone TJ08-E
    All About Battery Life (Part 3)
    Lenovo IdeaPad Y480 Review – Laptop With Excellent Construction Quality And Ergonomic Design
    Is Windows 8 Already In Deep Trouble? (Part 2)
    Do You Really Need Security?
    Programming .NET Components : Building a Distributed Application (part 3) - Programmatic Configuration Example, Administrative Configuration
    Building Android Apps: Creating a Dynamic Manifest File
    Intel Next Unit Of Computing DC3217BY
    Motorola Xoom 2 - General Tablet Use
    The Future Of Apple: Chip Off The Block (Part 2)
    Philips 227EQPH Display With IPS, Thin And Light Design
    Visual Studio 2010 : Introducing the Visual Studio Extensibility - Deploying Visual Studio Extensions
    Sharkoon T9
    Hot 5 Products To Make Your Life Interesting
    Saying Hello to Web Services
    Canon EOS 6D - Full-Frame Your Photos
    Windows Vista : Migrating User State Data - Evaluating Migration Technologies, Using Windows Easy Transfer