Exemple #1
0
        public void ApplyHeader(Section section)
        {
            //var settingRepository = new SettingSqlRepository(_databaseHelper);
            //var bgImage = settingRepository.GetSetting("BackgroundImageUrl");
            var bgImage = "http://www.thargelion.se/Images/Logotype/Thargelion-White-Full.png";

            section.Header.Height = UnitValue.Parse("6.5cm");

            var image = new Image
            {
                Source       = bgImage,
                Height       = UnitValue.Parse("4.2cm"),
                Top          = UnitValue.Parse("0cm"),
                IsBackground = true
            };

            section.Header.ElementList.Add(image);
            section.Header.ElementList.Add(new Text
            {
                Value         = "Sida {PageNumber} ({TotalPages})",
                TextAlignment = TextBase.Alignment.Right,
                Width         = "100%",
                Visibility    = PageVisibility.WhenMultiplePages
            });
        }
        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);
        }