private void PrintCard() { Debug.Assert(this.CardTemplate != null); Debug.Assert(this.CardTemplate.CanPrint); this.StatusText = PrintingPrompt; PrintDialog printDlg = new PrintDialog(); if (this.PrinterSetupTicket != null) { printDlg.PrintTicket = this.PrinterSetupTicket; } if (this.PrintQueue != null) { printDlg.PrintQueue = this.PrintQueue; } double width = printDlg.PrintableAreaWidth; double height = printDlg.PrintableAreaHeight; PhotoCard cardView = this.CreateCardView(); cardView.Width = width; cardView.Height = height; cardView.Show(); if (this.SaveCards && this.SaveFileLocation.Exists) { string fileName = GetNextCardFileName(); Byte[] jpeg = cardView.GetJpgImage(2.0, 95, Constants.ScreenDPI); System.IO.File.WriteAllBytes(fileName, jpeg); } UIElement content = cardView.RootVisual; FixedDocument document = DocumentUtility.CreateFixedDocument(width, height, content); bool printError = false; try { printDlg.PrintDocument(document.DocumentPaginator, "Photo Booth"); } catch (Exception e) { printError = true; Debug.WriteLine(e); MessageBox.Show(e.Message, "Print exception"); } cardView.Close(); if (!printError) { // Wait so photo capture doesn't get too far ahead of the printer. System.Threading.Thread.Sleep(PrintingDelay); } this.SetStartPrompt(); }