Exemple #1
0
        private static SimpleDocumentRenderer CreatePDFPRinter(string file)
        {
            string pfn = Path.Combine(KnownFolders.Downloads, file);

            SimpleDocumentRenderer doc = new SimpleDocumentRenderer("Microsoft Print to PDF");

            doc.Document.PrinterSettings.PrintFileName = pfn;
            doc.Document.PrinterSettings.PrintToFile   = true;
            return(doc);
        }
Exemple #2
0
        private static void Main1(string[] args)
        {
            //Test1();
            //Test2();
            const string           file = "testcode2.pdf";
            SimpleDocumentRenderer doc  = CreatePDFPRinter(file);

            Test3(doc);

            //var doc = new SimpleGridPrinter("Xerox VersaLink C405 Biolab Bullpen");
            //Test3(doc);
        }
        private static int PrintFile(string PrinterName, string PrintFileName)
        {
            var doc = new SimpleDocumentRenderer(PrinterName);

            if (!String.IsNullOrWhiteSpace(PrintFileName))
            {
                doc.Document.PrinterSettings.PrintToFile   = true;
                doc.Document.PrinterSettings.PrintFileName = PrintFileName;
            }
            TestPrinter.PrintTestRecipeStepsReport(doc);
            return(0);
        }
        internal static void PrintTestRecipeStepsReport(SimpleDocumentRenderer doc)
        {
            int[] widths = new int[] { 50, 200, 350, 150 };

            Func <string[]> GetStep2 = MakeStepGetter();

            int i                   = -1;
            int max_rows            = 100;
            CallbackRowRenderer row = new CallbackRowRenderer((row_renderer) =>
            {
                TextCell cell(int idx)
                {
                    return(row_renderer.Cells[idx] as TextCell);
                }
                if (i++ >= max_rows)
                {
                    return(false);
                }
                if (i == 0)
                {
                    cell(0).SetText("#", MyFonts.Consolas10);
                    cell(1).SetText("Timestamp", MyFonts.Consolas10);
                    cell(2).SetText("Step Text", MyFonts.Consolas10);
                    cell(3).SetText("Step Type", MyFonts.Consolas10);
                    return(true);
                }

                var step = GetStep2();

                cell(0).SetText(i.ToString(), MyFonts.Consolas6);
                for (int j = 0; j < 3; ++j)
                {
                    cell(j + 1).SetText(step[j], MyFonts.Consolas6);
                }

                return(true);
            });

            doc.AddRow(new TextCell("Recipe Steps Report", MyFonts.Consolas20, Alignment.Center, 0));
            doc.AddRow(new TextCell(" ", MyFonts.Consolas10)); // spacer
            doc.AddRow(row);

            for (int n = 0; n < 4; ++n)
            {
                row.AddCell(new TextCell("", MyFonts.Consolas6, Alignment.Left, widths[n]));
            }

            doc.Print();
        }
Exemple #5
0
        private static void AddRowWithText(SimpleDocumentRenderer printer, string text1, string text2, string text3)
        {
            Row row = new Row();

            printer.AddRow(row);

            TextCell c1 = new TextCell(text1, MyFonts.Consolas10);

            row.AddCell(c1);
            TextCell c2 = row.AddTextCell(text2, MyFonts.Consolas10);
            TextCell c3 = row.AddTextCell(text3, MyFonts.Consolas10);

            c1.Width = 200;
            c2.Width = 200;
            c3.Width = 200;
        }
Exemple #6
0
        private static void Test1()
        {
            const string           file = "testcode.pdf";
            SimpleDocumentRenderer doc  = CreatePDFPRinter(file);

            string lorem_text = File.ReadAllText(Path.Combine(KnownFolders.Downloads, "lorem2.txt"));

            string[] lorem_words = lorem_text.Split(' ');
            int      index       = 0;

            string lorem() => lorem_words[index++ % lorem_words.Length];
            string lorem2() => lorem() + " " + lorem();

            for (int i = 0; i < 3; ++i)
            {
                AddRowWithText(doc, lorem2(), lorem2(), lorem2());
            }
            doc.Print();
        }
Exemple #7
0
        private static void Test2()
        {
            const string           file = "testcode2.pdf";
            SimpleDocumentRenderer doc  = CreatePDFPRinter(file);

            int[] widths = new int[] { 50, 200, 350, 150 };

            Func <string[]> GetStep2 = MakeStepGetter();

            for (int i = 0; i < 200; ++i)
            {
                Row      row  = new Row();
                string[] step = GetStep2();
                row.AddCell(new TextCell(i.ToString(), MyFonts.Consolas6, Alignment.Left, widths[0]));
                for (int j = 0; j < 3; ++j)
                {
                    row.AddCell(new TextCell(step[j], MyFonts.Consolas6, Alignment.Left, widths[j + 1]));
                }

                doc.AddRow(row);
            }
            doc.Print();
        }
        private void _Init(SimpleDocumentRenderer p)
        {
            Printer = p;

            int[] widths = new int[] { 75, 175, 300, 150 };

            _title    = new ReportTitle("Recipe Steps Report");
            _metadata = new ReportMetadata("Batch name: \"test\"");
            _headers  = new RecordTableRow(ReportFonts.ColumnHeaderFont, "#", "Timestamp", "Step", "Type");

            _recordRow = new CallbackRowRenderer(UpdateRow);
            _record    = new RecipeStepRecord(_recordRow);

            p.AddRow(_title);
            p.AddRow(_metadata);
            p.AddRow(_headers);
            p.AddRow(_recordRow);

            _metadata.Margin.Top    = 25;
            _metadata.Margin.Bottom = 25;

            _headers.SetWidths(widths);
            _record.SetWidths(widths);
        }