public async override Task <bool> InvokeAsync(string paramList)
        {
            var section = new Section();

            section.Pane.ElementList.Add(new Rectangle {
                BorderColor = Color.Black, Left = "1cm", Top = "1cm", Bottom = "1cm", Right = "1cm"
            });
            section.Pane.ElementList.Add(new Line {
                Top = "0", Left = "0", Bottom = "0", Right = "0"
            });
            var template = new Template(section);

            var documentProperties = new DocumentProperties
            {
            };

            var sampleData = new DocumentData();

            var pageSizeInfo = new PageSizeInfo("A4");

            await PdfCommand.RenderPdfAsync(template, documentProperties, sampleData, pageSizeInfo, false, true);

            //var renderer = new Renderer(template, sampleData, documentProperties, pageSizeInfo, false);
            //var printerSettings = new PrinterSettings { };
            //renderer.Print(printerSettings, true, true);

            return(true);
        }
        public override async Task <bool> InvokeAsync(string paramList)
        {
            var bgImage = @"C:\skalleberg_v1.png"; //_settingBusiness.GetSetting("BackgroundImageUrl");
            var image   = new Image
            {
                Source       = bgImage,
                Top          = "48%",
                Height       = "48%",
                IsBackground = true
            };

            var section = new Section {
                Margin = new UnitRectangle {
                    Left = "6mm", Top = "2mm", Bottom = "2mm", Right = "6mm"
                }
            };

            section.Pane.ElementList.Add(new BarCode {
                Code = "{BarCode}", Top = "10%", Left = "20%", Width = "75%", Height = "60%"
            });
            section.Pane.ElementList.Add(image);
            section.Pane.ElementList.Add(new Text {
                Value = "Begonia", Font = new Font {
                    Size = 18
                }
            });
            section.Pane.ElementList.Add(new Text {
                Value = "100.00 Kr", Font = new Font {
                    Size = 18
                }, TextAlignment = TextBase.Alignment.Right
            });
            section.Pane.ElementList.Add(new Text {
                Value = "Holland", TextAlignment = TextBase.Alignment.Right, Left = "100%", Top = "90%"
            });
            var template = new Template(section);

            var documentProperties = new DocumentProperties
            {
            };

            var sampleData = new DocumentData();

            sampleData.Add("BarCode", "A");

            var pageSizeInfo = new PageSizeInfo("89mm", "36mm");

            await PdfCommand.RenderPdfAsync(template, documentProperties, sampleData, pageSizeInfo, false, true);

            //var renderer = new Renderer(template, sampleData, documentProperties, pageSizeInfo, false);
            //var printerSettings = new PrinterSettings { };
            //renderer.Print(printerSettings, true);

            return(true);
        }
示例#3
0
        public async override Task <bool> InvokeAsync(string paramList)
        {
            var index        = 0;
            var templateFile = QueryParam <string>("Template File", GetParam(paramList, index++));
            var dataFile     = QueryParam <string>("Data File", GetParam(paramList, index++));
            var debug        = QueryParam("Debug", GetParam(paramList, index++), new List <KeyValuePair <bool, string> > {
                new KeyValuePair <bool, string>(true, "Yes"), new KeyValuePair <bool, string>(false, "No")
            });
            var output = QueryParam("Output", GetParam(paramList, index++), new List <KeyValuePair <output, string> > {
                new KeyValuePair <output, string>(TestFileCommand.output.pdf, TestFileCommand.output.pdf.ToString()), new KeyValuePair <output, string>(TestFileCommand.output.printer, TestFileCommand.output.printer.ToString())
            });

            var xmdTemplate = new XmlDocument();

            xmdTemplate.Load(templateFile);
            var template = Template.Load(xmdTemplate);

            var documentProperties = new DocumentProperties();

            var xmdData = new XmlDocument();

            xmdData.Load(dataFile);
            var documentData = DocumentData.Load(xmdData);

            switch (output)
            {
            case output.pdf:
                await PdfCommand.RenderPdfAsync(template, documentProperties, documentData, null, debug);

                break;

            case output.printer:
                await PrinterCommand.RenderPrinterAsync(template, documentProperties, documentData, null, debug);

                break;

            default:
                throw new ArgumentOutOfRangeException(string.Format("Unknown output {0}.", output));
            }

            return(true);
        }
示例#4
0
        public async override Task <bool> InvokeAsync(string paramList)
        {
            var section = new Section();

            section.Pane.ElementList.Add(new Rectangle {
                BorderColor = Color.Black, Left = "1cm", Top = "1cm", Bottom = "1cm", Right = "1cm"
            });
            section.Pane.ElementList.Add(new Line {
                Top = "0", Left = "0", Bottom = "0", Right = "0"
            });
            section.Pane.ElementList.Add(new Image {
                Source = "{Img1}", Height = "150", Top = "50", Left = "50", Width = "250"
            });
            section.Pane.ElementList.Add(new Image {
                Source = "{Img2}", Height = "150", Top = "200", Left = "50"
            });
            var template = new Template(section);

            var documentProperties = new DocumentProperties
            {
            };

            //Image from url
            var sampleData = new DocumentData();

            sampleData.Add("Img1", "http://www.thargelion.se/Images/Logotype/Thargelion-White-Icon-150.pngx");

            //Image from byte[]. Convert to string with Encoding Windows-1252
            var imageAsbyteArrayData         = GetImageAsbyteArrayData();
            var dataAsStringToSendToReporter = Encoding.GetEncoding(1252).GetString(imageAsbyteArrayData);

            sampleData.Add("Img2", dataAsStringToSendToReporter);

            var pageSizeInfo = new PageSizeInfo("A4");

            await PdfCommand.RenderPdfAsync(template, documentProperties, sampleData, pageSizeInfo, false, true);

            return(true);
        }
示例#5
0
        public override async Task <bool> InvokeAsync(string paramList)
        {
            var section = new Section();

            section.Margin = new UnitRectangle {
                Left = "2cm", Top = "1cm", Bottom = "1cm", Right = "1cm"
            };
            section.Header.Height = "3cm";
            section.Footer.Height = "3cm";

            var r1 = new ReferencePoint();

            section.Pane.ElementList.Add(r1);
            var cellTitleFont = new Font {
                Size = 6
            };
            var cellDataFont = new Font {
                Size = 16
            };

            r1.ElementList.Add(new Rectangle {
                Height = "1cm", Width = "60mm"
            });
            r1.ElementList.Add(new Text {
                Top = "1mm", Left = "1mm", Value = "Name", Font = cellTitleFont
            });
            r1.ElementList.Add(new Text {
                Top = "3mm", Left = "1mm", Value = "{NameData}", Font = cellDataFont
            });

            r1.ElementList.Add(new Rectangle {
                Height = "1cm", Width = "60mm", Left = "60mm"
            });
            r1.ElementList.Add(new Text {
                Top = "1mm", Left = "61mm", Value = "Address", Font = cellTitleFont
            });
            r1.ElementList.Add(new Text {
                Top = "3mm", Left = "61mm", Value = "{AddressData}", Font = cellDataFont
            });

            r1.ElementList.Add(new Rectangle {
                Height = "1cm", Width = "20mm", Left = "120mm"
            });
            r1.ElementList.Add(new Text {
                Top = "1mm", Left = "121mm", Value = "Country", Font = cellTitleFont
            });
            r1.ElementList.Add(new Text {
                Top = "3mm", Left = "121mm", Value = "{CountryData}", Font = cellDataFont
            });

            //Make a copy and change it...
            var r2 = r1.Clone();

            section.Pane.ElementList.Add(r2);
            r2.Top += "1cm";

            //Create a content box.
            var r3 = new ReferencePoint {
                Top = "25mm"
            };

            section.Pane.ElementList.Add(r3);
            r3.ElementList.Add(new Rectangle {
                Height = "3cm", Width = "10cm"
            });

            //Create a checkbox with text
            var rc1 = new ReferencePoint();

            r3.ElementList.Add(rc1);
            rc1.ElementList.Add(new Rectangle {
                Left = "2mm", Width = "5mm", Height = "5mm", Top = "2mm"
            });
            rc1.ElementList.Add(new Line {
                Left = "2mm", Width = "5mm", Height = "5mm", Top = "2mm"
            });
            rc1.ElementList.Add(new Line {
                Left = "2mm", Width = "5mm", Height = "-5mm", Top = "7mm"
            });
            rc1.ElementList.Add(new Text {
                Left = "1cm", Top = "3mm", Value = "This value has been selected.", Font = cellDataFont
            });

            //Copy the checkbox and change text
            var rc2 = rc1.Clone();

            rc2.Top += "1cm";
            (rc2.ElementList.Last() as Text).Value = "Some other option.";
            r3.ElementList.Add(rc2);

            //Copy the checkbox and change text
            var rc3 = rc2.Clone();

            rc3.Top += "1cm";
            (rc2.ElementList.Last() as Text).Value = "Yet another option.";
            r3.ElementList.Add(rc3);


            var template           = new Template(section);
            var documentProperties = new DocumentProperties();
            var sampleData         = new DocumentData();

            sampleData.Add("NameData", "Kalle Anka");
            sampleData.Add("AddressData", "Storgatan 1");
            sampleData.Add("CountryData", "SE");

            var pageSizeInfo = new PageSizeInfo("A4");
            await PdfCommand.RenderPdfAsync(template, documentProperties, sampleData, pageSizeInfo, false, true);

            return(true);
        }
示例#6
0
        public override async Task <bool> InvokeAsync(string paramList)
        {
            var section = new Section();
            var table   = new Table
            {
                Name   = "A",
                Top    = "100",
                Bottom = "100",
                Left   = "50",
                Right  = "50",

                HeaderBackgroundColor = Color.Pink,
                //HeaderBorderColor = Color.Blue,
                //ColumnBorderColor = Color.Green,
                //ContentBorderColor = Color.DeepPink,
                //GroupBorderColor = Color.Chocolate,

                SkipLine = new SkipLine
                {
                    Height      = "5",
                    Interval    = 3,
                    BorderColor = Color.Red
                }
            };

            table.AddColumn(new TableColumn {
                Title = "First", Value = "{A1}"
            });
            table.AddColumn(new TableColumn {
                Title = "Second", Value = "{A2}"
            });
            section.Pane.ElementList.Add(table);
            var template = new Template(section);

            var documentProperties = new DocumentProperties();

            var sampleData        = new DocumentData();
            var documentDataTable = new DocumentDataTable("A");

            documentDataTable.AddRow(new Dictionary <string, string> {
                { "A1", "Some stuff" }, { "A2", "Some stuff" },
            });
            documentDataTable.AddRow(new Dictionary <string, string> {
                { "A1", "Some stuff on the second row" }, { "A2", "Blah" },
            });
            documentDataTable.AddRow(new Dictionary <string, string> {
                { "A1", "And on the third row" }, { "A2", "blah blah blah" },
            });
            for (var i = 0; i < 10; i++)
            {
                documentDataTable.AddRow(new Dictionary <string, string> {
                    { "A1", i.ToString() }, { "A2", "hästmos" },
                });
            }

            sampleData.Add(documentDataTable);

            var pageSizeInfo = new PageSizeInfo("A4");

            await PdfCommand.RenderPdfAsync(template, documentProperties, sampleData, pageSizeInfo, false, true);

            return(true);
        }