Ejemplo n.º 1
0
        private void Footer(IPdfStyling pdfStyling, Section section)
        {
            TextFrame footer = section.AddTextFrame();

            footer.RelativeVertical = RelativeVertical.Margin;

            footer.Height = Unit.FromCentimeter(3.5);
            footer.Width  = pdfStyling.MaxWidthInPoints;
            footer.Top    = pdfStyling.MaxHeightInPoints - Unit.FromCentimeter(1);

            Paragraph p = footer.AddParagraph();

            p.AddText("Alle Rezepte auf");
            p.Format.SpaceBefore = 0;
            p.Format.SpaceAfter  = 0;
            p.Format.Font.Color  = pdfStyling.ParagraphSmallColor;
            p.Format.Alignment   = ParagraphAlignment.Center;

            Paragraph website = footer.AddParagraph();

            website.AddText("www.rimuss.ch");
            website.Format.SpaceBefore = 0;
            website.Format.SpaceAfter  = 0;
            website.Format.Font.Color  = Color.FromCmyk(38, 46, 82, 36);
            website.Format.Alignment   = ParagraphAlignment.Center;
        }
Ejemplo n.º 2
0
        private Table SetTableStyle(ref Section section, Color tableColor)
        {
            TextFrame frame = section.AddTextFrame();

            frame.MarginTop = new Unit(6, UnitType.Centimeter);
            frame.Width     = new Unit(16, UnitType.Centimeter);

            //TABLE LABEL
            Paragraph p = frame.AddParagraph();

            p.AddFormattedText("Purchased goods:", TextFormat.Bold);

            frame.AddParagraph("").AddLineBreak();

            //TABLE
            Table table = frame.AddTable();

            table.Style               = "Table";
            table.Borders.Color       = tableColor;
            table.Borders.Width       = 0.25;
            table.Borders.Left.Width  = 0.5;
            table.Borders.Right.Width = 0.5;
            table.Rows.LeftIndent     = 0;
            return(table);
        }
Ejemplo n.º 3
0
        private void CreateHeader()
        {
            // Create the text frame for the address
            headerFrame                    = section.AddTextFrame();
            headerFrame.Height             = "1.0cm";
            headerFrame.Width              = "7.0cm";
            headerFrame.Left               = ShapePosition.Left;
            headerFrame.RelativeHorizontal = RelativeHorizontal.Margin;
            headerFrame.Top                = "1.0cm";
            headerFrame.RelativeVertical   = RelativeVertical.Page;

            // Put sender in address frame
            Paragraph paragraph = headerFrame.AddParagraph(Definition.Title.Text);

            paragraph.Style             = "Reference";
            paragraph.Format.Font.Name  = "Times New Roman";
            paragraph.Format.Font.Size  = 7;
            paragraph.Format.SpaceAfter = 3;

            // Add the print date field
            paragraph = section.AddParagraph();
            paragraph.Format.SpaceBefore = "1cm";
            paragraph.Style = "Reference";
            paragraph.AddFormattedText(Definition.SubTitle.Text, TextFormat.Bold);
            paragraph.AddTab();
            paragraph.AddText("Beep Reports, ");
            paragraph.AddDateField("dd.MM.yyyy");
        }
Ejemplo n.º 4
0
        public static void verticalBarCode()
        {
            string   reportFilename = "verticalBarCode.pdf";
            Document document       = new Document();

            Console.WriteLine(document.DefaultPageSetup.LeftMargin);
            Section section = document.AddSection();

            section.PageSetup.TopMargin  = Unit.FromPoint(30);
            section.PageSetup.LeftMargin = Unit.FromPoint(20);

            TextFrame leftTF = section.AddTextFrame();

            leftTF.Orientation      = TextOrientation.Downward;
            leftTF.WrapFormat.Style = WrapStyle.None;
            // leftTF.MarginLeft = Unit.FromInch(1);
            //leftTF.MarginRight = Unit.FromInch(1);

            //make sure the font is embedded
            var  options = new XPdfFontOptions(PdfFontEncoding.Unicode);
            Font fontEan = new Font("mrvcode39s", 20);

            leftTF.AddParagraph().AddFormattedText("*12343*", fontEan);
            // Now generate a pdf
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

            // Set the MigraDoc document
            pdfRenderer.Document = document;

            // Create the PDF document
            pdfRenderer.RenderDocument();

            // Save the PDF document...
            pdfRenderer.Save(reportFilename);
        }
Ejemplo n.º 5
0
        private void AddNotes()
        {
            //Written total
            TextFrame textFrame = section.AddTextFrame();

            textFrame.Width            = "17cm";
            textFrame.Left             = ShapePosition.Left;
            textFrame.WrapFormat.Style = WrapStyle.None;
            textFrame.AddParagraph();
            section.AddParagraph();
            Paragraph paragraph = section.AddParagraph();

            paragraph.Format.Font.Size = "10pt";
            paragraph.Format.Font.Name = "Arial";
            paragraph.Format.Font.Bold = true;
            paragraph.Format.Alignment = ParagraphAlignment.Left;
            paragraph.AddText(documentContent.totalWritten);
            section.AddParagraph();
            paragraph = section.AddParagraph();
            paragraph.Format.Font.Size = "10pt";
            paragraph.Format.Font.Name = "Arial";
            paragraph.Format.Font.Bold = true;
            paragraph.Format.Alignment = ParagraphAlignment.Left;
            paragraph.AddText(documentContent.taxNote);
            paragraph = section.AddParagraph();
            paragraph.Format.Font.Size = "10pt";
            paragraph.Format.Font.Name = "Arial";
            paragraph.Format.Alignment = ParagraphAlignment.Left;
            paragraph.AddText(documentContent.notes);
        }
Ejemplo n.º 6
0
        private void PaymentSection()
        {
            Section section = Pdf.LastSection;

            Table table = section.AddTable();

            table.AddColumn(Unit.FromPoint(section.Document.PageWidth()));
            Row row = table.AddRow();

            if (Invoice.Details != null && Invoice.Details.Count > 0)
            {
                foreach (DetailRow detail in Invoice.Details)
                {
                    row.Cells[0].AddParagraph(detail.Title, ParagraphAlignment.Left, "H2-9B-Color");
                    row.Cells[0].Borders.Bottom = BorderLine;

                    row = table.AddRow();
                    TextFrame frame = null;
                    foreach (string line in detail.Paragraphs)
                    {
                        if (line == detail.Paragraphs[0])
                        {
                            frame       = row.Cells[0].AddTextFrame();
                            frame.Width = section.Document.PageWidth();
                        }
                        frame.AddParagraph(line, ParagraphAlignment.Left, "H2-9");
                    }
                }
            }

            if (Invoice.Company.HasCompanyNumber || Invoice.Company.HasVatNumber)
            {
                row = table.AddRow();

                Color shading = MigraDocHelpers.TextColorFromHtml(Invoice.TextColor);

                if (Invoice.Company.HasCompanyNumber && Invoice.Company.HasVatNumber)
                {
                    row.Cells[0].AddParagraph(string.Format("Company Number: {0}, VAT Number: {1}",
                                                            Invoice.Company.CompanyNumber, Invoice.Company.VatNumber),
                                              ParagraphAlignment.Center, "H2-9B-Inverse")
                    .Format.Shading.Color = shading;
                }
                else
                {
                    if (Invoice.Company.HasCompanyNumber)
                    {
                        row.Cells[0].AddParagraph(string.Format("Company Number: {0}", Invoice.Company.CompanyNumber),
                                                  ParagraphAlignment.Center, "H2-9B-Inverse")
                        .Format.Shading.Color = shading;
                    }
                    else
                    {
                        row.Cells[0].AddParagraph(string.Format("VAT Number: {0}", Invoice.Company.VatNumber),
                                                  ParagraphAlignment.Center, "H2-9B-Inverse")
                        .Format.Shading.Color = shading;
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private TextFrame Siegarten()
        {
            var result = new TextFrame();

            result.Width = $"{_breite_Siegart}cm";

            var paragraph = result.AddParagraph();

            paragraph.Format.Font.Size = CustomStyles.fontSizeNormal;


            paragraph.AddFormattedText("\u00A8", new Font("Wingdings"));
            paragraph.AddFormattedText("SS  ");

            paragraph.AddFormattedText("\u00A8", new Font("Wingdings"));
            paragraph.AddFormattedText("TÜ  ");

            paragraph.AddFormattedText("\u00A8", new Font("Wingdings"));
            paragraph.AddFormattedText("AS");

            paragraph.AddLineBreak();
            paragraph.AddLineBreak();

            paragraph.AddFormattedText("\u00A8", new Font("Wingdings"));
            paragraph.AddFormattedText("PS  ");

            paragraph.AddFormattedText("\u00A8", new Font("Wingdings"));
            paragraph.AddFormattedText("DS  ");

            paragraph.AddFormattedText("\u00A8", new Font("Wingdings"));
            paragraph.AddFormattedText("___");

            return(result);
        }
Ejemplo n.º 8
0
        ///<summary></summary>
        public static void DrawString(TextFrame frameContainer, string text, MigraDoc.DocumentObjectModel.Font font, float xPos, float yPos)
        {
            TextFrame frame = new TextFrame();
            Paragraph par   = frame.AddParagraph();

            par.Format.Font = font.Clone();
            par.AddText(text);
            frame.RelativeVertical   = RelativeVertical.Page;
            frame.RelativeHorizontal = RelativeHorizontal.Page;
            frame.MarginLeft         = Unit.FromInch(xPos / 100);
            frame.MarginTop          = Unit.FromInch(yPos / 100);
            frame.Top   = TopPosition.Parse("0 in");
            frame.Left  = LeftPosition.Parse("0 in");
            frame.Width = frameContainer.Width;
            FontStyle fontstyle = FontStyle.Regular;

            if (font.Bold)
            {
                fontstyle = FontStyle.Bold;
            }
            System.Drawing.Font fontSystem = new System.Drawing.Font(font.Name, (float)font.Size.Point, fontstyle);
            float fontH  = fontSystem.Height;
            Unit  bottom = Unit.FromInch((yPos + fontH) / 100);

            if (frameContainer.Height < bottom)
            {
                frameContainer.Height = bottom;
            }
            frame.Height = frameContainer.Height;
            //LineFormat lineformat=new LineFormat();
            //lineformat.Width=1;
            //frame.LineFormat=lineformat;
            frameContainer.Elements.Add(frame);
        }
Ejemplo n.º 9
0
        ///<summary></summary>
        public static void DrawString(TextFrame frameContainer, string text, MigraDoc.DocumentObjectModel.Font font, RectangleF rectF,
                                      ParagraphAlignment alignment)
        {
            TextFrame frame = new TextFrame();
            Paragraph par   = frame.AddParagraph();

            par.Format.Font      = font.Clone();
            par.Format.Alignment = alignment;
            par.AddText(text);
            frame.RelativeVertical   = RelativeVertical.Page;
            frame.RelativeHorizontal = RelativeHorizontal.Page;
            frame.MarginLeft         = Unit.FromInch(rectF.Left / 100);
            frame.MarginTop          = Unit.FromInch(rectF.Top / 100);
            frame.Top   = TopPosition.Parse("0 in");
            frame.Left  = LeftPosition.Parse("0 in");
            frame.Width = Unit.FromInch(rectF.Right / 100f);        //    frameContainer.Width;
            Unit bottom = Unit.FromInch(rectF.Bottom / 100f);

            if (frameContainer.Height < bottom)
            {
                frameContainer.Height = bottom;
            }
            frame.Height = frameContainer.Height;
            //LineFormat lineformat=new LineFormat();
            //lineformat.Width=1;
            //frame.LineFormat=lineformat;
            frameContainer.Elements.Add(frame);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Renders the specified PDF styling.
        /// </summary>
        /// <param name="pdfStyling">The PDF styling.</param>
        /// <param name="section">The section.</param>
        public void Render(IPdfStyling pdfStyling, Section section)
        {
            TextFrame frame = section.AddTextFrame();

            frame.Top    = new Unit(_top);
            frame.Left   = new Unit(_left);
            frame.Width  = pdfStyling.MaxWidthInPoints;
            frame.Height = new Unit(_height);
            //frame.RelativeVertical = RelativeVertical.Margin;
            frame.RelativeVertical = _relativeVertical;

            Paragraph paragraph = frame.AddParagraph();

            if (string.IsNullOrWhiteSpace(_title) == false)
            {
                paragraph.AddFormattedText(_title.Trim(), TextFormat.Bold);
                paragraph.AddLineBreak();
            }

            int      count = _addressLines.Count();
            TextLine line;

            for (int i = 0; i < _addressLines.Count(); i++)
            {
                line = _addressLines.ElementAt(i);

                paragraph.AddLineBreak();
                paragraph.AddFormattedText(
                    text: line.Text,
                    textFormat: line.IsBold ? TextFormat.Bold : TextFormat.NotBold);
            }
        }
Ejemplo n.º 11
0
        TextFrame createClosed(int nr = 1)
        {
            Table mainTable = new Table();

            mainTable.AddColumn(Unit.FromCentimeter(8.0));
            mainTable.AddColumn(Unit.FromCentimeter(9.0));
            mainTable.AddRow();

            TextFrame frame = mainTable[0, 0].AddTextFrame();

            frame.Width  = Unit.FromCentimeter(8.0);
            frame.Height = Unit.FromCentimeter(5.0);
            Paragraph p = frame.AddParagraph();

            p.AddLineBreak();
            p.AddFormattedText("Pokój otwarty - Licytacja", font_tytuly);
            p.AddLineBreak(); p.AddLineBreak();

            string[] nazwiska = new string[4];
            for (int i = 0; i < 4; i++)
            {
                nazwiska[i] = vugraph.nazwiska_[i + 4];
            }
            Table table = CreateBidding(nr, vugraph.licytacja_open, nazwiska);

            frame.MarginLeft = Unit.FromCentimeter(0.5);
            frame.Add(table);

            TextFrame frame2 = mainTable[0, 1].AddTextFrame();

            frame2.Width      = Unit.FromCentimeter(9.0);
            frame2.Height     = Unit.FromCentimeter(5.0);
            frame2.MarginLeft = Unit.FromCentimeter(0.5);
            Paragraph p2 = frame2.AddParagraph();

            p2.AddFormattedText("Komentarz : ", font_tytuly);

            Paragraph p3 = frame2.AddParagraph();

            p3.AddFormattedText(" ", font_normal);

            mainTable.Borders.Width = szerokosc_krawedzi * 1.5;

            document.LastSection.Add(mainTable);
            return(frame);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets <see cref="TextFrame`1"/> with order information in it.
        /// </summary>
        /// <param name="orderId">Order identifier.</param>
        /// <param name="orderDate">Order issue date.</param>
        /// <returns><see cref="TextFrame`1"/> with order information.</returns>
        private TextFrame AddOrderInfo(string orderId, string orderDate)
        {
            TextFrame orderInfoFrame = new TextFrame();
            Paragraph invoiceNumPar  = new Paragraph();

            invoiceNumPar.Style = "SectionHeader";
            invoiceNumPar.Format.SpaceBefore = 0;
            invoiceNumPar.AddText("INVOICE NUMBER");
            orderInfoFrame.Add(invoiceNumPar);
            orderInfoFrame.AddParagraph(orderId);
            Paragraph invoiceOrdDate = new Paragraph();

            invoiceOrdDate.Style = "SectionHeader";
            invoiceOrdDate.AddText("DATE OF ISSUE");
            orderInfoFrame.Add(invoiceOrdDate);
            orderInfoFrame.AddParagraph(orderDate);
            return(orderInfoFrame);
        }
Ejemplo n.º 13
0
        private Document fillContent(Document doc, Realizacija_osiguranja ro, TextFrame addressFrame, Table table)
        {
            Osoba o = ro.Stavka_u_realizaciji.Where(s => s.Nosilac_Stavka_u_realiziciji == true).FirstOrDefault().Osoba;

            Paragraph paragraph = addressFrame.AddParagraph();

            paragraph.AddText(o.Ime_Osoba + " " + o.Prezime_Osoba);
            paragraph.AddLineBreak();
            paragraph.AddText(o.Adresa_Osoba);
            paragraph.AddLineBreak();
            paragraph.AddText(o.E_mail_Osoba);

            Row row;

            for (int i = 0; i < ro.Stavka_u_realizaciji.Count; i++)
            {
                Stavka_u_realizaciji sur = ro.Stavka_u_realizaciji.ElementAt(i);

                row                        = table.AddRow();
                row.TopPadding             = 1.5;
                row.Cells[0].Shading.Color = new Color(242, 242, 242);
                row.Cells[2].Shading.Color = new Color(242, 242, 242);

                row.Cells[0].AddParagraph((i + 1).ToString());

                if (sur.Osoba != null)
                {
                    row.Cells[1].AddParagraph(sur.Osoba.Ime_Osoba + " " + sur.Osoba.Prezime_Osoba + ", " + sur.Osoba.Broj_pasosa_Osoba);
                }
                else
                {
                    if (sur.Nekretnina != null)
                    {
                        row.Cells[1].AddParagraph("Nekretnina na adresi: " + sur.Nekretnina.Adresa_Nekretnina);
                    }
                    else
                    {
                        if (sur.Vozilo != null)
                        {
                            row.Cells[1].AddParagraph("Vozilo sa brojem šasije: " + sur.Vozilo.Broj_sasije_Vozilo);
                        }
                    }
                }


                row.Cells[2].AddParagraph(sur.Vrednost_Stavka_u_realizaciji.ToString());
            }


            row               = table.AddRow();
            row.TopPadding    = 1.5;
            row.Shading.Color = new Color(242, 242, 242);

            row.Cells[1].AddParagraph("Ukupna cena polise: " + ro.Ukupna_vrednost_Realizacija_osiguranja);

            return(doc);
        }
Ejemplo n.º 14
0
        TextFrame createOpen(int nr = 1)
        {
            Table mainTable = new Table();

            mainTable.AddColumn(Unit.FromCentimeter(8.0));
            mainTable.AddColumn(Unit.FromCentimeter(9.0));
            mainTable.AddRow();

            TextFrame frame = mainTable[0, 0].AddTextFrame();

            frame.Width  = Unit.FromCentimeter(8.0);
            frame.Height = Unit.FromCentimeter(5.0);
            Paragraph p = frame.AddParagraph();

            p.AddFormattedText("Pokój zamknięty - Licytacja", font_tytuly);
            p.AddLineBreak(); p.AddLineBreak();

            Table table = CreateBidding(nr, vugraph.licytacja_closed, vugraph.nazwiska_);

            frame.MarginLeft = Unit.FromCentimeter(1.0);
            frame.MarginTop  = Unit.FromCentimeter(0.5);
            frame.Add(table);

            TextFrame frame2 = mainTable[0, 1].AddTextFrame();

            frame2.Width     = Unit.FromCentimeter(9.0);
            frame2.Height    = Unit.FromCentimeter(5.0);
            frame2.MarginTop = Unit.FromCentimeter(0.5);
            frame.MarginLeft = Unit.FromCentimeter(0.5);
            Paragraph p2 = frame2.AddParagraph();

            p2.AddFormattedText("Komentarz : ", font_tytuly);
            p2.AddLineBreak();
            Paragraph p3 = frame2.AddParagraph();

            p3.AddFormattedText(" ", font_normal);

            mainTable.Borders.Width = szerokosc_krawedzi * 1.5;

            document.LastSection.Add(mainTable);
            return(frame);
        }
Ejemplo n.º 15
0
 private void addCell(Row row, int index, string text)
 {
     textFrame            = row.Cells[index].AddTextFrame();
     textFrame.Width      = row.Cells[index].Column.Width;
     textFrame.Height     = 30;
     textFrame.MarginLeft = 30;
     textFrame.AddParagraph(text);
     if ((int)row.Index == 0)
     {
         textFrame.MarginLeft = 10;
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Renders the element.
        /// </summary>
        /// <param name="pdfStyling">The PDF styling.</param>
        /// <param name="section">The section.</param>
        public void Render(IPdfStyling pdfStyling, Section section)
        {
            TextFrame hr = section.AddTextFrame();

            hr.Width            = new Unit(pdfStyling.MaxWidthInPoints);
            hr.Height           = new Unit(10);   //TODO: Custom height?
            hr.RelativeVertical = RelativeVertical.Line;

            Paragraph ruler = hr.AddParagraph();

            ruler.SetStyle(PdfStyleNames.Misc.HorizontalRule);
        }
Ejemplo n.º 17
0
        private void HorizontalRule(IPdfStyling pdfStyling, Cell cell)
        {
            TextFrame hr = cell.AddTextFrame();

            hr.Width  = _leftSideWidth;
            hr.Height = Unit.FromCentimeter(1);
            hr.Top    = Unit.FromCentimeter(1);

            Paragraph ruler = hr.AddParagraph();

            ruler.Format.Borders.Top.Color = pdfStyling.HorizontalRuleColor;
            ruler.Format.Borders.Top.Width = 0.5;
        }
        private void HorizontalRule(IPdfStyling pdfStyling, Section section)
        {
            TextFrame hr = section.AddTextFrame();

            hr.Width  = pdfStyling.MaxWidthInPoints;
            hr.Height = Unit.FromCentimeter(1);
            hr.Top    = Unit.FromCentimeter(1);

            Paragraph ruler = hr.AddParagraph();

            ruler.Format.Borders.Top.Color = pdfStyling.HorizontalRuleColor;
            ruler.Format.Borders.Top.Width = 0.5;
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates the dynamic parts of the invoice.
        /// </summary>
        void FillContent()
        {
            const double vat = 0.07;

            var paragraph = _addressFrame.AddParagraph();

            paragraph.AddText("Issued to: Shazad Saleemi");
            paragraph.AddLineBreak();
            paragraph.AddText("Email: [email protected]");
            paragraph.AddLineBreak();
            paragraph.AddText("Issued Date: 03 March, 2020");
            paragraph.Format.Alignment = ParagraphAlignment.Right;
        }
        /// <summary>
        /// Renders the element.
        /// </summary>
        /// <param name="pdfStyling">The PDF styling.</param>
        /// <param name="section">The section.</param>
        public void Render(IPdfStyling pdfStyling, Section section)
        {
            TextFrame frame = section.Headers.Primary.AddTextFrame();

            frame.Width     = new Unit(pdfStyling.MaxWidthInPoints);
            frame.Height    = new Unit(pdfStyling.HeaderTitleFontSize * 2);          //TODO: Why?
            frame.MarginTop = new Unit(pdfStyling.HeaderTitleFontSize + 3);          //TODO: Why?

            Paragraph paragraph = frame.AddParagraph();

            paragraph.AddFormattedText(_title, _textFormat);
            paragraph.Format.Alignment = _alignment;
            paragraph.SetStyle(PdfStyleNames.Title.Header);
        }
Ejemplo n.º 21
0
        private void Footer(IPdfStyling pdfStyling, Section section)
        {
            TextFrame footer = section.AddTextFrame();

            footer.RelativeVertical = RelativeVertical.Margin;

            footer.Height = Unit.FromCentimeter(3.5);
            footer.Width  = _leftSideWidth + Unit.FromCentimeter(1);
            footer.Top    = pdfStyling.MaxHeightInPoints - Unit.FromCentimeter(1);
            footer.Left   = GetTableIndent(pdfStyling);

            Paragraph p = footer.AddParagraph();

            p.AddText("Alle Rezepte auf");
            p.Format.SpaceBefore = 0;
            p.Format.SpaceAfter  = 0;
            p.Format.Font.Color  = pdfStyling.ParagraphSmallColor;
            p.Format.Alignment   = ParagraphAlignment.Center;
            p.Format.LeftIndent  = Unit.FromCentimeter(-1);            // Because we have +1cm for the page

            Paragraph website = footer.AddParagraph();

            website.AddText("www.rimuss.ch");
            website.Format.SpaceBefore = 0;
            website.Format.SpaceAfter  = 0;
            website.Format.Font.Color  = Color.FromCmyk(38, 46, 82, 36);
            website.Format.Alignment   = ParagraphAlignment.Center;
            website.Format.LeftIndent  = Unit.FromCentimeter(-1);            // Because we have +1cm for the page

            Paragraph page = footer.AddParagraph();

            page.AddText("3");
            page.Format.Font.Size   = 9;
            page.Format.SpaceBefore = Unit.FromCentimeter(0.5);
            page.Format.SpaceAfter  = 0;
            page.Format.Alignment   = ParagraphAlignment.Right;
        }
Ejemplo n.º 22
0
        private void addTitle(Document document)
        {
            MigraDoc.DocumentObjectModel.Shapes.TextFrame textFrame = new MigraDoc.DocumentObjectModel.Shapes.TextFrame();

            // Add a section to the document.
            section = document.AddSection();
            section.PageSetup.StartingNumber = 1;
            textFrame        = section.AddTextFrame();
            textFrame.Height = "3.0cm";
            textFrame.Width  = "7.0cm";
            textFrame.Left   = 10;
            textFrame.Top    = Top;
            // Put sender in address frame
            paragraph = textFrame.AddParagraph("Handels Software Partner · NotkeStr.9  · 12345 Hamburg");
        }
Ejemplo n.º 23
0
        private TextFrame Sieger()
        {
            var result = new TextFrame();

            var paragraph = result.AddParagraph();

            paragraph.Format.Font.Size = CustomStyles.fontSizeNormal;

            paragraph.AddFormattedText("\u00A8", new Font("Wingdings"));
            paragraph.AddFormattedText(" ROT");
            paragraph.AddLineBreak();
            paragraph.AddLineBreak();
            paragraph.AddFormattedText("\u00A8", new Font("Wingdings"));
            paragraph.AddFormattedText(" BLAU");

            return(result);
        }
Ejemplo n.º 24
0
        public static void verticalText()
        {
            string   reportFilename = "verticalText.pdf";
            Document document       = new Document();
            Section  section        = document.AddSection();
            Table    dataTbl        = section.AddTable();


            // Two columns - the first vertical, the next horisontal
            Column column = dataTbl.AddColumn("0.5cm"); // Left vertical text...

            column = dataTbl.AddColumn("4.25cm");

            // Create a number of rows
            for (int i = 0; i <= 20; i++)
            {
                dataTbl.AddRow();
            }


            //Merge the cells in the first column and write vertical text in it
            Cell leftSideCell = dataTbl.Rows[0].Cells[0];

            leftSideCell.MergeDown         = dataTbl.Rows.Count - 1;
            leftSideCell.VerticalAlignment = VerticalAlignment.Center;
            TextFrame leftTF = leftSideCell.AddTextFrame();

            leftTF.Orientation      = TextOrientation.Upward;
            leftTF.WrapFormat.Style = WrapStyle.None;

            Paragraph leftPar = leftTF.AddParagraph("How do I avoid this text getting wrapped ?");

            // Now generate a pdf
            PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);

            // Set the MigraDoc document
            pdfRenderer.Document = document;

            // Create the PDF document
            pdfRenderer.RenderDocument();

            // Save the PDF document...
            pdfRenderer.Save(reportFilename);
        }
Ejemplo n.º 25
0
        private void FillContent()
        {
            //XPathNavigator item = SelectItem("/invoice/to");
            MigraDoc.DocumentObjectModel.Paragraph paragraph = addressFrame.AddParagraph();
            paragraph.AddText("Dane Zamawiajacego :");
            paragraph.AddLineBreak();
            paragraph.AddText($"Imię i nazwisko: {order.UserData.Name} {order.UserData.Surname}");
            paragraph.AddLineBreak();
            paragraph.AddText($"Adres: ul. {order.UserData.Adres.Street} {order.UserData.Adres.HomeNumber}, {order.UserData.Adres.PostCode} {order.UserData.Adres.City}");

            MigraDoc.DocumentObjectModel.Paragraph priceParagraph = PriceFrame.AddParagraph();
            priceParagraph.AddText($"Cena całkowita: \n {order.OrderAmount} zł \n ");
            //paragraph.AddLineBreak();
            priceParagraph.AddText($"Rodzaj przesyłki: \n {order.OrderOption}  \n");
            //paragraph.AddLineBreak();
            priceParagraph.AddText($"Cena z przesyłką: \n {order.Amount} zł\n ");
            //paragraph.AddLineBreak();


            foreach (var orderItem in order.Ordered)
            {
                Row row = table.AddRow();
                row.TopPadding = 1.5;

                row.Cells[0].Shading.Color     = TableGray;
                row.Cells[0].VerticalAlignment = MigraDoc.DocumentObjectModel.Tables.VerticalAlignment.Center;
                row.Cells[0].Format.Alignment  = ParagraphAlignment.Left;
                row.Cells[1].Format.Alignment  = ParagraphAlignment.Left;
                row.Cells[2].Format.Alignment  = ParagraphAlignment.Left;
                row.Cells[3].Format.Alignment  = ParagraphAlignment.Left;
                row.Cells[1].Shading.Color     = TableGray;
                row.Cells[2].Shading.Color     = TableGray;
                row.Cells[3].Shading.Color     = TableGray;

                row.Cells[0].AddParagraph(orderItem.Product.Name);
                row.Cells[1].AddParagraph(orderItem.Count.ToString());
                row.Cells[2].AddParagraph($"{orderItem.Product.Price} zł");
                row.Cells[3].AddParagraph($"{orderItem.Amount} zł");

                this.table.SetEdge(0, this.table.Rows.Count - 1, 4, 1, Edge.Box, BorderStyle.Single, 0.75);
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Renders the element.
        /// </summary>
        /// <param name="pdfStyling">The PDF styling.</param>
        /// <param name="section">The section.</param>
        public void Render(IPdfStyling pdfStyling, Section section)
        {
            section.PageSetup.StartingNumber = 1;

            TextFrame frame = section.Footers.Primary.AddTextFrame();

            frame.Width     = new Unit(pdfStyling.MaxWidthInPoints);
            frame.Height    = new Unit(10);                   //TODO: Why?
            frame.MarginTop = pdfStyling.PageNumberMarginTop; //TODO: Why?
            //frame.MarginTop = new Unit(69.5);

            Paragraph paragraph = frame.AddParagraph();

            paragraph.Format.Alignment = pdfStyling.PageNumberAlignment;
            //paragraph.AddText("Page "); //TODO: Multilingual
            paragraph.AddPageField();
            paragraph.AddText(" / ");
            paragraph.AddNumPagesField();
            paragraph.SetStyle(PdfStyleNames.Paragraph.Small);
        }
Ejemplo n.º 27
0
        // Add a header paragraph to the section
        public static void AddText(this TextFrame frame, string headerText, TextStyle style = null)
        {
            Paragraph paragraphHeader = frame.AddParagraph();

            if (style != null)
            {
                paragraphHeader.Format.Alignment = style.TextAlignment;
                if (style.Font != null)
                {
                    paragraphHeader.AddFormattedText(headerText, style.Font);
                }
                else
                {
                    paragraphHeader.AddText(headerText);
                }
            }
            else
            {
                paragraphHeader.AddText(headerText);
            }
        }
Ejemplo n.º 28
0
        private void SetHeader(ref Section section)
        {
            TextFrame frame1 = section.Headers.Primary.AddTextFrame();

            frame1.RelativeVertical = RelativeVertical.Page;
            frame1.Left             = ShapePosition.Left;
            frame1.MarginTop        = new Unit(1, UnitType.Centimeter);
            frame1.Width            = new Unit(10, UnitType.Centimeter);

            TextFrame frame2 = section.Headers.Primary.AddTextFrame();

            frame2.RelativeVertical = RelativeVertical.Page;
            frame2.Left             = ShapePosition.Right;
            frame2.MarginTop        = new Unit(1, UnitType.Centimeter);
            frame2.Width            = new Unit(2, UnitType.Centimeter);

            Paragraph p = frame1.AddParagraph();

            p.AddFormattedText(CurrentRequestData.CurrentSite.Name, TextFormat.Bold);
            p = frame2.AddParagraph();
            p.AddDateField("dd/MM/yyyy");
        }
Ejemplo n.º 29
0
 public static Paragraph AddParagraph(this TextFrame frame, string text, ParagraphAlignment align, string style = null)
 {
     return(frame.AddParagraph().AddText(text, align, style));
 }
Ejemplo n.º 30
0
        // [UnitTestFunction]
        public static void Test()
        {
            Document doc  = new Document();
            Style    styl = doc.AddStyle("TestStyle1", Style.DefaultParagraphFontName);

            styl.Font.Bold = true;
            Section sec = doc.AddSection();

            sec.PageSetup.PageHeight = "30cm";

            sec.Headers.FirstPage.Format.Font.Bold = true;
            sec.Headers.Primary.AddParagraph("This is the Primary Header.");
            sec.Headers.FirstPage.AddParagraph("This is the First Page Header.");
            sec.Headers.EvenPage.AddParagraph("This is the Even Page Header.");

            Paragraph par = sec.AddParagraph("Paragraph 1");

//      par.Style = "TestStyle1";
            par.Format.ListInfo.NumberPosition = 2;


            par = sec.AddParagraph("Paragraph 2");
            par.Format.ListInfo.ListType = ListType.BulletList3;
            Image img1 = par.AddImage("logo.gif");

//      Image img1 = par.AddImage("tick_green.png");
            img1.ScaleHeight            = 5;
            img1.ScaleWidth             = 2;
            img1.Height                 = "0.3cm";
            img1.Width                  = "5cm";
            img1.PictureFormat.CropLeft = "-2cm";
            img1.FillFormat.Color       = Color.PowderBlue;
            img1.LineFormat.Width       = 2;


            par = sec.AddParagraph("Paragraph 3");
            par.AddLineBreak();
            par.Format.ListInfo.NumberPosition = 2;

            TextFrame tf = sec.AddTextFrame();

            tf.WrapFormat.Style   = WrapStyle.None;
            tf.RelativeHorizontal = RelativeHorizontal.Page;
            tf.RelativeVertical   = RelativeVertical.Page;

            tf.Top                  = Unit.FromCm(2);
            tf.Left                 = ShapePosition.Center;
            tf.Height               = "20cm";
            tf.Width                = "10cm";
            tf.FillFormat.Color     = Color.LemonChiffon;
            tf.LineFormat.Color     = Color.BlueViolet;
            tf.LineFormat.DashStyle = DashStyle.DashDotDot;
            tf.LineFormat.Width     = 2;
            tf.AddParagraph("in a text frame");
            tf.MarginTop   = "3cm";
            tf.Orientation = TextOrientation.Downward;

            Image img = sec.AddImage("test1.jpg");

            img.ScaleHeight            = 500;
            img.ScaleWidth             = 200;
            img.Height                 = "10cm";
            img.Width                  = "10cm";
            img.PictureFormat.CropLeft = "-2cm";
            img.FillFormat.Color       = Color.LawnGreen;
            img.LineFormat.Width       = 3;
            img.WrapFormat.Style       = WrapStyle.None;

            sec = doc.AddSection();//.AddParagraph("test");
            sec.PageSetup.PageWidth = "30cm";
            sec.AddParagraph("Section 2");

            DocumentRenderer docRenderer = new DocumentRenderer();

            docRenderer.Render(doc, "RtfListInfo.txt", null);
            DdlWriter.WriteToFile(doc, "RtfListInfo.mdddl");
            System.IO.File.Copy("RtfListInfo.txt", "RtfListInfo.rtf", true);
            System.Diagnostics.Process.Start("RtfListInfo.txt");
        }