Ejemplo n.º 1
0
        public override async Task <bool> InvokeAsync(string paramList)
        {
            var section  = CreateSection();
            var template = new Template(section);

            var table = CreateTableDefinition();

            section.Pane.ElementList.Add(table);

            //Add some column lines for the table
            section.Pane.ElementList.Add(new Line {
                Left = "4cm", Width = "0", Color = Color.Gray, Top = "10%", Height = "80%"
            });
            section.Pane.ElementList.Add(new Line {
                Left = "8cm", Width = "0", Color = Color.Gray, Top = "10%", Height = "80%"
            });

            var data = GetData();

            var documentProperties = CreateDocumentProperties();

            await PdfCommand.RenderPdfAsync(template, documentProperties, data, null, false);

            return(true);
        }
Ejemplo n.º 2
0
        public override async Task <bool> InvokeAsync(string paramList)
        {
            var section = new Section {
                Name = "Main", Margin = new UnitRectangle {
                    Left = "2cm", Right = "1cm", Top = "1cm", Bottom = "1cm"
                }
            };

            section.Footer.Height = "3cm";
            section.Footer.ElementList.Add(new Line {
                Width = "100%", Height = "100%"
            });
            section.Footer.ElementList.Add(new Line {
                Top = "100%", Width = "100%", Height = "-100%"
            });
            section.Footer.ElementList.Add(new Text {
                Value = "Some text in the footer" + Environment.NewLine + "on two lines"
            });
            section.Footer.ElementList.Add(new TextBox {
                Left = "5cm", Height = "3cm", Value = "Some more text in the footer" + Environment.NewLine + "on two lines."
            });
            //section.Footer.ElementList.Add(new TextBox { Left = "5cm", Height = "3cm", Value = "Some  more   text in the footer" + Environment.NewLine + "on two lines. The second line is too long and needs to be split over several lines automatically. And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf asf asf asf asf asf  And even more text that spans over several pages asf asd asd asd asd asd asd asf asf a" + Environment.NewLine + "b" + Environment.NewLine + "asf" + Environment.NewLine + "asf" + Environment.NewLine + "asf" + Environment.NewLine + "asf..." });

            var template = new Template(section);

            await PdfCommand.RenderPdfAsync(template);

            return(true);
        }
Ejemplo n.º 3
0
        public override async Task <bool> InvokeAsync(string paramList)
        {
            var section = new Section {
                Name = "Main", Margin = new UnitRectangle {
                    Left = "2cm", Right = "1cm", Top = "3cm", Bottom = "3cm"
                }
            };
            var template = new Template(section);

            await PdfCommand.RenderPdfAsync(template);

            return(true);
        }
        public async override Task <bool> InvokeAsync(string paramList)
        {
            var sectionA = new Section {
                Name = "Section A"
            };

            sectionA.Pane.ElementList.Add(new Text {
                Font = new Font {
                    Size = 22
                }, Top = "50%", TextAlignment = TextBase.Alignment.Center, Value = "Multi section demo"
            });
            var template = new Template(sectionA);

            var sectionB = new Section {
                Name = "Section B", Margin = new UnitRectangle {
                    Left = "2cm", Right = "1cm", Top = "1cm", Bottom = "1cm"
                }, Footer = { Height = "3cm" }
            };

            sectionB.Footer.ElementList.Add(new Text {
                Value = "Some text on page {PageNumber}."
            });
            sectionB.Footer.ElementList.Add(new Text {
                Left = "5cm", Value = "Some text on the last page.", Visibility = PageVisibility.LastPage
            });
            template.SectionList.Add(sectionB);

            var sectionC = new Section {
                Name = "Section C", Margin = new UnitRectangle {
                    Left = "2cm", Right = "1cm", Top = "1cm", Bottom = "1cm"
                }, Footer = sectionB.Footer
            };

            sectionC.Pane.ElementList.Add(new TextBox {
                Width = "3cm", Height = "2cm", Value = "This is a text that spans over several pages. The first part should appear on one page and the last part on another."
            });
            sectionC.Pane.ElementList.Add(new TextBox {
                Left = "5cm", Width = "3cm", Height = "2cm", Value = "This is a short text."
            });
            sectionC.Pane.ElementList.Add(new TextBox {
                Left = "10cm", Width = "3cm", Height = "2cm", Value = "This is a short text for the last page only.", Visibility = PageVisibility.LastPage
            });
            sectionC.Pane.ElementList.Add(new TextBox {
                Left = "15cm", Width = "3cm", Height = "2cm", Value = "This is a text for all pages but for the first one.", Visibility = PageVisibility.AllButFirst
            });
            template.SectionList.Add(sectionC);

            await PdfCommand.RenderPdfAsync(template);

            return(true);
        }
Ejemplo n.º 5
0
        public override async Task <bool> InvokeAsync(string paramList)
        {
            var index = 0;
            var documentProperties = CreateDocumentProperties(paramList, ref index);
            var template           = CreateTemplate();

            var debug = QueryParam("Debug", GetParam(paramList, index++), new List <KeyValuePair <bool, string> > {
                new KeyValuePair <bool, string>(true, "Yes"), new KeyValuePair <bool, string>(false, "No")
            });

            await PdfCommand.RenderPdfAsync(template, documentProperties, null, null, debug);

            return(true);
        }
Ejemplo n.º 6
0
        public override async Task <bool> InvokeAsync(string paramList)
        {
            //var index = 0;
            //var language = QueryParam<string>("Language", GetParam(paramList, index++), () => new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("English", "English"), new KeyValuePair<string, string>("Svenska", "Svenska") });
            var language = "English";

            var template = GetTemplate();
            var data     = GetData(language);

            var documentProperties = new DocumentProperties
            {
                Title   = data.Get("Title"),
                Author  = "Daniel Bohlin",
                Creator = "Daniel Bohlin",
                Subject = "This is a manual for Tharga reporter generated by the tharga reporter itself."
            };

            await PdfCommand.RenderPdfAsync(template, documentProperties, data, null, false);

            return(true);
        }