protected override async void OnPrintClicked() { ShowWindow(); await Task.Delay(500); var elm = GetPreviewWindow().mainPanel.Children[0]; await Task.Delay(500); PrintPreviewer.FitTo(InchesWidth, InchesHeight, elm as FrameworkElement); CloseWindow(); }
protected override async void OnPrintClicked() { var win = new PrintWindow1(); win.DataContext = this.MainReport; win.printPanel.Padding = new Thickness(30, 60, 30, 30); win.Show(); await Task.Delay(1000 * 1); PrintPreviewer.FitTo(8.5, 11, win.printPanel); win.Close(); }
// --------------------------------------------------------------------------------------------------------------------------------------------------------- /// <summary> /// Prints the current active view /// </summary> public void PrintCurrentView() { if (this.CurrentView == null) { return; } /* * var PrintSettings = new PrintDialog(); * var DoPrint = PrintSettings.ShowDialog(); * if (!DoPrint.IsTrue()) * return; * * var Margin = (ReportConfiguration.DEFAULT_PAGE_MARGIN_CMS * 2.56) * Display.WPF_DPI; * var SourceDocument = this.CurrentView.ToDocument(PrintSettings.PrintableAreaWidth, * PrintSettings.PrintableAreaHeight, * null, // Old (now can use Info-Card): this.CurrentView.OwnerCompositeContainer.OwnerComposition.Name, * null, // Old (now can use Info-Card): this.CurrentView.Name, * PrintSettings.PrintTicket.PageOrientation.IsOneOf(PageOrientation.Landscape, PageOrientation.ReverseLandscape), * false, // Borders are not necessary * Margin, Margin, Margin, Margin); */ var DialogResult = Display.DialogPrintSetup(); if (DialogResult == null) { return; } // PENDING (?): APPLY THE SPECIFIED SETTINGS. var SourceDocument = this.CurrentView.ToDocument(DialogResult.Item1.Landscape ? DialogResult.Item1.PrintableArea.Height : DialogResult.Item1.PrintableArea.Width, DialogResult.Item1.Landscape ? DialogResult.Item1.PrintableArea.Width : DialogResult.Item1.PrintableArea.Height, null, // Old (now can use Info-Card): this.CurrentView.OwnerCompositeContainer.OwnerComposition.Name, null, // Old (now can use Info-Card): this.CurrentView.Name, false, // Borders are not necessary DialogResult.Item1.Margins.Left, DialogResult.Item1.Margins.Top, DialogResult.Item1.Margins.Right, DialogResult.Item1.Margins.Bottom); var DocTitle = this.CurrentView.OwnerCompositeContainer.OwnerComposition.Name + " - " + this.CurrentView.Name; PrintPreviewControl = new PrintPreviewer(SourceDocument, null, DocTitle); Display.OpenContentDialogWindow(ref WinPrintPreview, "Print Preview of: " + DocTitle, PrintPreviewControl); }
public SampleControl() { InitializeComponent(); var previewer = new PrintPreviewer <OrderFormPage>( new OrderFormPage(), new DataGridPrintablePaginator <Order>().Paginate, PrinterSelector <IPrinter> .FromLocalServer <IPrinter>(q => new Printer(q)) ); DataContext = previewer; Loaded += (sender, e) => { previewer.UpdatePreview(); }; }
public static void GeneratePdfXpsReport(CompositionEngine Engine) { if (Engine == null) { return; } if (!ProductDirector.ValidateEditionPermission(AppExec.LIC_EDITION_STANDARD, "Generate PDF/XPS Report")) { return; } if (Engine.TargetComposition.CompositeContentDomain.ReportingConfiguration == null) { Engine.TargetComposition.CompositeContentDomain.ReportingConfiguration = new ReportConfiguration(); } if (!ReportingManager.EditReportConfiguration("PDF/XPS", Engine.TargetComposition.CompositeContentDomain.ReportingConfiguration)) { return; } var Generator = new ReportStandardGenerator(Engine.TargetComposition, Engine.TargetComposition.CompositeContentDomain.ReportingConfiguration); var Title = "Report of " + Engine.TargetComposition.Name; ProgressiveThreadedExecutor <int> .Execute("Generating " + Title, Generator.Generate, (opresult) => { if (opresult.WasSuccessful && !File.Exists(Generator.GeneratedDocumentTempFilePath)) { opresult = OperationResult.Failure <int>("Cannot write temporal report file at: " + Generator.GeneratedDocumentTempFilePath); } if (!opresult.WasSuccessful) { Display.DialogMessage("Report not completed!", opresult.Message, EMessageType.Warning); return; } try { var GeneratedDocument = Display.LoadDocumentFromXPS(Generator.GeneratedDocumentTempFilePath); var Location = new Uri(Generator.GeneratedDocumentTempFilePath, UriKind.Absolute); var Package = System.IO.Packaging.PackageStore.GetPackage(Location); DocViewerControl = new PrintPreviewer(GeneratedDocument, Generator.GeneratedDocumentTempFilePath, Engine.TargetComposition.Name); Display.OpenContentDialogWindow(ref WinFlowDocViewer, Title, DocViewerControl); Package.Close(); // Package remains open, so must closed! //if you don't remove the package from the PackageStore, you won't be able to //re-open the same file again later (due to System.IO.Packaging's Package store/caching //rather than because of any file locks) System.IO.Packaging.PackageStore.RemovePackage(Location); if (File.Exists(Generator.GeneratedDocumentTempFilePath)) { File.Delete(Generator.GeneratedDocumentTempFilePath); } } catch (Exception Problem) { Display.DialogMessage("Attention!", "Cannot show generated Report.\n" + (!Generator.GeneratedDocumentTempFilePath.IsAbsent() && File.Exists(Generator.GeneratedDocumentTempFilePath) ? "It can still be found at: " + Generator.GeneratedDocumentTempFilePath : "") + "\nProblem: " + Problem.Message); } }); }