Example #1
0
        void BtnPrintReportPDFClick(object sender, EventArgs e)
        {
            OpenFileDialog DialogOpen = new OpenFileDialog();

            // see file in sub directory test data.
            // create file with method TResultList.WriteBinaryFile
            DialogOpen.Filter = "Binary Report File (*.bin)|*.bin";
            DialogOpen.RestoreDirectory = true;
            DialogOpen.Title = "Open Binary Report File";

            if (DialogOpen.ShowDialog() == DialogResult.OK)
            {
                TResultList Results = new TResultList();
                TParameterList Parameters;
                Results.ReadBinaryFile(DialogOpen.FileName, out Parameters);

                TPetraIdentity PetraIdentity = new TPetraIdentity(
                    "TESTUSER", "", "", "", "", DateTime.MinValue,
                    DateTime.MinValue, DateTime.MinValue, 0, -1, -1, false,
                    false);

                UserInfo.GUserInfo = new TPetraPrincipal(PetraIdentity, null);

                PrintDocument doc = new PrintDocument();

                TPdfPrinter pdfPrinter = new TPdfPrinter(doc, TGfxPrinter.ePrinterBehaviour.eReport);
                TReportPrinterLayout layout = new TReportPrinterLayout(Results, Parameters, pdfPrinter, true);

                pdfPrinter.Init(eOrientation.ePortrait, layout, eMarginType.ePrintableArea);

                pdfPrinter.SavePDF("test.pdf");

                System.Diagnostics.Process.Start(Path.GetFullPath("test.pdf"));
            }
        }
Example #2
0
        void TbbImportReportBinaryFileClick(object sender, EventArgs e)
        {
            OpenFileDialog DialogOpen = new OpenFileDialog();

            // see file in sub directory test data.
            // create file with method TResultList.WriteBinaryFile
            DialogOpen.Filter = "Binary Report File (*.bin)|*.bin";
            DialogOpen.RestoreDirectory = true;
            DialogOpen.Title = "Open Binary Report File";

            if (DialogOpen.ShowDialog() == DialogResult.OK)
            {
                TResultList Results = new TResultList();
                TParameterList Parameters;
                Results.ReadBinaryFile(DialogOpen.FileName, out Parameters);

                PrintDocument doc = new PrintDocument();

                TPetraIdentity PetraIdentity = new TPetraIdentity(
                    "TESTUSER", "", "", "", "", DateTime.MinValue,
                    DateTime.MinValue, DateTime.MinValue, 0, -1, -1, false,
                    false);

                UserInfo.GUserInfo = new TPetraPrincipal(PetraIdentity, null);

                FGfxPrinter = new TGfxPrinter(doc, TGfxPrinter.ePrinterBehaviour.eReport);
                new TReportPrinterLayout(Results, Parameters, FGfxPrinter, true);
                printPreviewControl1.Document = doc;
                doc.EndPrint += new PrintEventHandler(this.PrintDocument_EndPrint);
                printPreviewControl1.InvalidatePreview();
            }
        }