Exemple #1
0
        public virtual void CreatePDF(String dest)
        {
            // Create a pdf document along with a Document (default root layout element) instance
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest));
            Document    document    = new Document(pdfDocument);

            // ភាសាខ្មែរ
            String text = "\u1797\u17B6\u179F\u17B6\u1781\u17D2\u1798\u17C2\u179A";

            PdfFont font = PdfFontFactory.CreateFont(FONTS_FOLDER + "KhmerOS.ttf",
                                                     PdfEncodings.IDENTITY_H);

            // Create an action with an URI. Use the action together with text to create a Link element
            Link link = new Link(text, PdfAction.CreateURI("http://itextpdf.com"));

            // Overwrite some default document properties. From now on they will be used for all the elements
            // added to the document unless they are overwritten inside these elements
            document
            .SetFont(font)
            .SetFontSize(10);

            document
            .Add(new Paragraph(link))
            .Add(new Paragraph(text));

            document.Close();
        }
        public virtual void CreatePDF(String dest)
        {
            // Create a pdf document along with a Document (default root layout element) instance
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest));
            Document    document    = new Document(pdfDocument);

            // സാേങ്കതിക പദസൂചികഒരു സ്വതന്ത്ര
            String text = "\u0D38\u0D3E\u0D47\u0D19\u0D4D\u0D15\u0D24\u0D3F\u0D15\u0020\u0D2A\u0D26\u0D38\u0D42\u0D1A"
                          + "\u0D3F\u0D15\u0D12\u0D30\u0D41\u0020\u0D38\u0D4D\u0D35\u0D24\u0D28\u0D4D\u0D24\u0D4D\u0D30";

            PdfFont font = PdfFontFactory.CreateFont(FONTS_FOLDER + "NotoSansMalayalam-Regular.ttf",
                                                     PdfEncodings.IDENTITY_H);

            // Create an action with an URI. Use the action together with text to create a Link element
            Link link = new Link(text, PdfAction.CreateURI("http://itextpdf.com"));

            // Overwrite some default document properties. From now on they will be used for all the elements
            // added to the document unless they are overwritten inside these elements
            document
            .SetFont(font)
            .SetFontSize(10);

            document
            .Add(new Paragraph(link))
            .Add(new Paragraph(text));

            document.Close();
        }
Exemple #3
0
        public virtual void CreatePDF(String dest)
        {
            // Create a pdf document along with a Document (default root layout element) instance
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest));
            Document    document    = new Document(pdfDocument);

            // רע ומר היה להם ליהודים
            String text = "\u05E8\u05E2\u0020\u05D5\u05DE\u05E8\u0020\u05D4\u05D9\u05D4\u0020\u05DC\u05D4\u05DD" +
                          "\u0020\u05DC\u05D9\u05D4\u05D5\u05D3\u05D9\u05DD";

            PdfFont font = PdfFontFactory.CreateFont(FONTS_FOLDER + "NotoSerifHebrew-Regular.ttf",
                                                     PdfEncodings.IDENTITY_H);

            // Create an action with an URI. Use the action together with text to create a Link element
            Link link = new Link(text, PdfAction.CreateURI("http://itextpdf.com"));

            // Overwrite some default document properties. From now on they will be used for all the elements
            // added to the document unless they are overwritten inside these elements
            document
            .SetFont(font)
            .SetFontSize(10)

            // In Hebrew text goes from right to left, that's why we need to overwrite the default iText's alignment
            .SetTextAlignment(TextAlignment.RIGHT);

            document
            .Add(new Paragraph(link))
            .Add(new Paragraph(text));

            document.Close();
        }
Exemple #4
0
        public virtual void CreatePDF(String dest)
        {
            // Create a pdf document along with a Document (default root layout element) instance
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest));
            Document    document    = new Document(pdfDocument);

            // மனித உரிமைகள் பற்றிய உலகப் பிரகடனம்
            String text =
                "\u0BAE\u0BA9\u0BBF\u0BA4\u0020\u0B89\u0BB0\u0BBF\u0BAE\u0BC8\u0B95\u0BB3\u0BCD\u0020\u0BAA\u0BB1\u0BCD"
                + "\u0BB1\u0BBF\u0BAF\u0020\u0B89\u0BB2\u0B95\u0BAA\u0BCD\u0020\u0BAA\u0BBF\u0BB0\u0B95\u0B9F\u0BA9\u0BAE\u0BCD";

            PdfFont font = PdfFontFactory.CreateFont(FONTS_FOLDER + "NotoSansTamil-Regular.ttf",
                                                     PdfEncodings.IDENTITY_H);

            // Create an action with an URI. Use the action together with text to create a Link element
            Link link = new Link(text, PdfAction.CreateURI("http://itextpdf.com"));

            // Overwrite some default document properties. From now on they will be used for all the elements
            // added to the document unless they are overwritten inside these elements
            document
            .SetFont(font)
            .SetFontSize(10);

            document
            .Add(new Paragraph(link))
            .Add(new Paragraph(text));

            document.Close();
        }
Exemple #5
0
        public virtual void CreatePdf(String dest)
        {
            PdfDocument             pdf       = new PdfDocument(new PdfWriter(dest));
            Document                document  = new Document(pdf);
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            resultSet.RemoveAt(0);
            foreach (IList <String> record in resultSet)
            {
                Div div = new Div().SetKeepTogether(true).SetBorderLeft(new SolidBorder(2)).SetPaddingLeft(3).SetMarginBottom
                              (10);
                String url   = String.Format("http://www.imdb.com/title/tt{0}", record[0]);
                Link   movie = new Link(record[2], PdfAction.CreateURI(url));
                div.Add(new Paragraph(movie.SetFontSize(14))).Add(new Paragraph(String.Format("Directed by {0} ({1}, {2})", record
                                                                                              [3], record[4], record[1])));
                FileInfo file = new FileInfo(String.Format("../../../resources/img/{0}.jpg", record[0]));
                if (file.Exists)
                {
                    iText.Layout.Element.Image img = new Image(ImageDataFactory.Create(file.FullName));
                    img.ScaleToFit(10000, 120);
                    div.Add(img);
                }
                document.Add(div);
            }
            document.Close();
        }
Exemple #6
0
        public virtual void TableHeaderLinkTest01()
        {
            String      outFileName = destinationFolder + "tableHeaderLinkTest01.pdf";
            String      cmpFileName = sourceFolder + "cmp_tableHeaderLinkTest01.pdf";
            PdfDocument pdfDoc      = new PdfDocument(new PdfWriter(outFileName));
            Document    doc         = new Document(pdfDoc);
            PdfAction   action      = PdfAction.CreateURI("http://itextpdf.com/", false);
            int         numCols     = 3;
            int         numRows     = 24;
            Table       table       = new Table(numCols);

            for (int x = 0; x < numCols; x++)
            {
                Cell   headerCell  = new Cell();
                String cellContent = "Header cell\n" + (x + 1);
                Link   link        = new Link(cellContent, action);
                link.SetFontColor(ColorConstants.BLUE);
                headerCell.Add(new Paragraph().Add(link));
                table.AddHeaderCell(headerCell);
            }
            for (int x = 0; x < numRows; x++)
            {
                table.AddCell(new Cell().SetHeight(100f).Add(new Paragraph("Content cell " + (x + 1))));
            }
            doc.Add(table);
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }
        protected void ManipulatePdf(String dest)
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
            Document    doc    = new Document(pdfDoc);

            Image     img    = new Image(ImageDataFactory.Create(IMG));
            Paragraph anchor = new Paragraph().Add(img);

            anchor.SetProperty(Property.ACTION, PdfAction.CreateURI("https://lowagie.com/"));

            Table table = new Table(UnitValue.CreatePercentArray(3)).UseAllAvailableWidth();

            table.AddCell(anchor);
            table.AddCell("A");
            table.AddCell("B");
            table.AddCell("C");

            img = new Image(ImageDataFactory.Create(IMG));
            img.SetNextRenderer(new LinkImageRenderer(img));
            table.AddCell(img);

            doc.Add(table);

            doc.Close();
        }
        public virtual void CreatePdf(String dest)
        {
            PdfDocument pdf = new PdfDocument(new PdfWriter(dest));

            pdf.AddNewPage();
            pdf.GetCatalog().SetPageMode(PdfName.UseOutlines);
            PdfOutline root = pdf.GetOutlines(false);
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            resultSet.RemoveAt(0);
            foreach (IList <String> record in resultSet)
            {
                PdfOutline movie = root.AddOutline(record[2]);
                PdfOutline imdb  = movie.AddOutline("Link to IMDB");
                imdb.SetColor(ColorConstants.BLUE);
                imdb.SetStyle(PdfOutline.FLAG_BOLD);
                String url = String.Format("http://www.imdb.com/title/tt{0}", record[0]);
                imdb.AddAction(PdfAction.CreateURI(url));
                PdfOutline info = movie.AddOutline("More info:");
                info.SetOpen(false);
                info.SetStyle(PdfOutline.FLAG_ITALIC);
                PdfOutline director = info.AddOutline("Directed by " + record[3]);
                director.SetColor(ColorConstants.RED);
                PdfOutline place = info.AddOutline("Produced in " + record[4]);
                place.SetColor(ColorConstants.MAGENTA);
                PdfOutline year = info.AddOutline("Released in " + record[1]);
                year.SetColor(ColorConstants.DARK_GRAY);
            }
            pdf.Close();
        }
Exemple #9
0
        public virtual void CreatePDF(String dest)
        {
            // Create a pdf document along with a Document (default root layout element) instance
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest));
            Document    document    = new Document(pdfDocument);

            //ผม เรา ฉัน
            String text = "\u0E1C\u0E21\u0020\u0E40\u0E23\u0E32\u0020\u0E09\u0E31\u0E19";

            PdfFont font = PdfFontFactory.CreateFont(FONTS_FOLDER + "NotoSansThai-Regular.ttf",
                                                     PdfEncodings.IDENTITY_H);

            // Create an action with an URI. Use the action together with text to create a Link element
            Link link = new Link(text, PdfAction.CreateURI("http://itextpdf.com"));

            // Overwrite some default document properties. From now on they will be used for all the elements
            // added to the document unless they are overwritten inside these elements
            document
            .SetFont(font)
            .SetFontSize(10);

            document
            .Add(new Paragraph(link))
            .Add(new Paragraph(text));

            document.Close();
        }
Exemple #10
0
        public virtual void CreatePdf(String dest)
        {
            PdfDocument             pdf       = new PdfDocument(new PdfWriter(dest));
            Document                document  = new Document(pdf);
            IList <IList <String> > resultSet = CsvTo2DList.Convert(SRC, "|");

            resultSet.RemoveAt(0);
            List list = new List(ListNumberingType.DECIMAL);

            foreach (IList <String> record in resultSet)
            {
                ListItem li = new ListItem();
                li.SetKeepTogether(true);
                li.Add(new Paragraph().SetFontSize(14).Add(record[2])).Add(new Paragraph(String.Format("Directed by {0} ({1}, {2})"
                                                                                                       , record[3], record[4], record[1])));
                FileInfo file = new FileInfo(String.Format("../../../resources/img/{0}.jpg", record[0]));
                if (file.Exists)
                {
                    iText.Layout.Element.Image img = new Image(ImageDataFactory.Create(file.FullName));
                    img.ScaleToFit(10000, 120);
                    li.Add(img);
                }
                String url = String.Format("http://www.imdb.com/title/tt{0}", record[0]);
                li.SetAction(PdfAction.CreateURI(url));
                list.Add(li);
            }
            document.Add(list);
            document.Close();
        }
        public virtual void CreatePDF(String dest)
        {
            // Create a pdf document along with a Document (default root layout element) instance
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(dest));
            Document    document    = new Document(pdfDocument);

            // રાજ્યમાં વસતા લોકો દ્વારા લેખનકાર્યમાં વપરાતી
            String text =
                "\u0AB0\u0ABE\u0A9C\u0ACD\u0AAF\u0AAE\u0ABE\u0A82\u0020\u0AB5\u0AB8\u0AA4\u0ABE\u0020\u0AB2\u0ACB"
                + "\u0A95\u0ACB\u0020\u0AA6\u0ACD\u0AB5\u0ABE\u0AB0\u0ABE\u0020\u0AB2\u0AC7\u0A96\u0AA8\u0A95\u0ABE\u0AB0"
                + "\u0ACD\u0AAF\u0AAE\u0ABE\u0A82\u0020\u0AB5\u0AAA\u0AB0\u0ABE\u0AA4\u0AC0";

            PdfFont font = PdfFontFactory.CreateFont(FONTS_FOLDER + "NotoSansGujarati-Regular.ttf",
                                                     PdfEncodings.IDENTITY_H);

            // Create an action with an URI. Use the action together with text to create a Link element
            Link link = new Link(text, PdfAction.CreateURI("http://itextpdf.com"));

            // Overwrite some default document properties. From now on they will be used for all the elements
            // added to the document unless they are overwritten inside these elements
            document
            .SetFont(font)
            .SetFontSize(10);

            document
            .Add(new Paragraph(link))
            .Add(new Paragraph(text));

            document.Close();
        }
            public override void Draw(DrawContext drawContext)
            {
                base.Draw(drawContext);
                PdfAnnotation annotation = new PdfLinkAnnotation(GetOccupiedAreaBBox())
                                           .SetAction(PdfAction.CreateURI("https://lowagie.com/bio"));

                drawContext.GetDocument().GetLastPage().AddAnnotation(annotation);
            }
Exemple #13
0
        public Image CreateImage(String src, String url)
        {
            Image img = new Image(ImageDataFactory.Create(src));

            // Create the url in the image by setting action property directly
            img.SetProperty(Property.ACTION, PdfAction.CreateURI(url));
            return(img);
        }
        public virtual void ActionTest01()
        {
            PdfDocument document = CreateDocument(new PdfWriter(destinationFolder + "actionTest01.pdf"), true);

            document.GetCatalog().SetOpenAction(PdfAction.CreateURI("http://itextpdf.com/"));
            document.Close();
            System.Console.Out.WriteLine(MessageFormatUtil.Format("Please open document {0} and make sure that you're automatically redirected to {1} site."
                                                                  , destinationFolder + "actionTest01.pdf", "http://itextpdf.com"));
        }
        public virtual void ActionTest02()
        {
            PdfDocument document = CreateDocument(new PdfWriter(destinationFolder + "actionTest02.pdf"), false);

            document.GetPage(2).SetAdditionalAction(PdfName.O, PdfAction.CreateURI("http://itextpdf.com/"));
            document.Close();
            System.Console.Out.WriteLine(MessageFormatUtil.Format("Please open document {0} at page 2 and make sure that you're automatically redirected to {1} site."
                                                                  , destinationFolder + "actionTest02.pdf", "http://itextpdf.com"));
        }
            public override void Draw(DrawContext drawContext)
            {
                base.Draw(drawContext);

                PdfLinkAnnotation linkAnnotation = new PdfLinkAnnotation(GetOccupiedAreaBBox());

                linkAnnotation.SetHighlightMode(PdfAnnotation.HIGHLIGHT_INVERT);
                linkAnnotation.SetAction(PdfAction.CreateURI(url));
                drawContext.GetDocument().GetLastPage().AddAnnotation(linkAnnotation);
            }
Exemple #17
0
        public Cell CreateCellSubSectionLink(string label, string url, Style style = null)
        {
            text = new Paragraph(new Link(label,
                                          PdfAction.CreateURI(url)))
                   .AddStyle(style ?? textStyle)
                   .SetUnderline();

            return(new Cell().Add(text)
                   .SetBorder(Border.NO_BORDER)
                   .SetPaddingLeft(15));
        }
        protected void ManipulatePdf(String dest)
        {
            PdfDocument pdfDoc = new PdfDocument(new PdfWriter(dest));
            Document    doc    = new Document(pdfDoc);

            Paragraph chunk = new Paragraph(new Link("Click me", PdfAction.CreateURI(XML)));

            doc.Add(chunk);

            doc.Close();
        }
 public virtual void CreatePdf(String dest) {
     PdfDocument pdf = new PdfDocument(new PdfWriter(dest));
     Document document = new Document(pdf);
     document.Add(new Paragraph("Paragraph with orange border").SetBorder(new SolidBorder(ColorConstants.ORANGE, 5)));
     Text text = new Text("Text with orange border").SetBorder(new SolidBorder(ColorConstants.ORANGE, 5));
     document.Add(new Paragraph(text));
     Link link = new Link("Link with orange border", PdfAction.CreateURI("http://itextpdf.com"));
     link.SetBorder(new SolidBorder(ColorConstants.ORANGE, 5));
     document.Add(new Paragraph(link));
     document.Close();
 }
Exemple #20
0
        public virtual void RotatedLinkAtFixedPosition()
        {
            String    outFileName = destinationFolder + "rotatedLinkAtFixedPosition.pdf";
            String    cmpFileName = sourceFolder + "cmp_rotatedLinkAtFixedPosition.pdf";
            Document  doc         = new Document(new PdfDocument(new PdfWriter(outFileName)));
            PdfAction action      = PdfAction.CreateURI("http://itextpdf.com/", false);
            Link      link        = new Link("TestLink", action);

            doc.Add(new Paragraph(link).SetMargin(0).SetRotationAngle(Math.PI / 4).SetFixedPosition(300, 623, 100));
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }
Exemple #21
0
        public virtual void LinkTest01()
        {
            String      outFileName = destinationFolder + "linkTest01.pdf";
            String      cmpFileName = sourceFolder + "cmp_linkTest01.pdf";
            PdfDocument pdfDoc      = new PdfDocument(new PdfWriter(outFileName));
            Document    doc         = new Document(pdfDoc);
            PdfAction   action      = PdfAction.CreateURI("http://itextpdf.com/", false);
            Link        link        = new Link("TestLink", action);

            doc.Add(new Paragraph(link));
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }
Exemple #22
0
        public virtual void BorderedLinkTest()
        {
            String      outFileName = destinationFolder + "borderedLinkTest.pdf";
            String      cmpFileName = sourceFolder + "cmp_borderedLinkTest.pdf";
            PdfDocument pdfDoc      = new PdfDocument(new PdfWriter(new FileStream(outFileName, FileMode.Create)));
            Document    doc         = new Document(pdfDoc);
            Link        link        = new Link("Link with orange border", PdfAction.CreateURI("http://itextpdf.com"));

            link.SetBorder(new SolidBorder(ColorConstants.ORANGE, 5));
            doc.Add(new Paragraph(link));
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }
Exemple #23
0
        protected void ManipulatePdf(String dest)
        {
            PdfDocument pdfDoc     = new PdfDocument(new PdfReader(SRC), new PdfWriter(dest));
            PdfPage     firstPage  = pdfDoc.GetFirstPage();
            PdfAction   linkAction = PdfAction.CreateURI("https://pages.itextpdf.com/ebook-stackoverflow-questions.html");

            Rectangle     annotLocation = new Rectangle(30, 770, 90, 30);
            PdfAnnotation link          = new PdfLinkAnnotation(annotLocation)

                                          // Set highlighting type which is enabled after a click on the annotation
                                          .SetHighlightMode(PdfAnnotation.HIGHLIGHT_INVERT)
                                          .SetAction(linkAction)
                                          .SetColor(ColorConstants.RED.GetColorValue());

            firstPage.AddAnnotation(link);

            annotLocation = new Rectangle(30, 670, 30, 90);
            link          = new PdfLinkAnnotation(annotLocation)
                            .SetHighlightMode(PdfAnnotation.HIGHLIGHT_INVERT)
                            .SetAction(linkAction)
                            .SetColor(ColorConstants.GREEN.GetColorValue());
            firstPage.AddAnnotation(link);

            annotLocation = new Rectangle(150, 770, 90, 30);
            PdfAnnotation stamp = new PdfStampAnnotation(annotLocation)
                                  .SetStampName(new PdfName("Confidential"))

                                  // This method sets the text that will be displayed for the annotation or the alternate description,
                                  // if this type of annotation does not display text.
                                  .SetContents("Landscape");

            firstPage.AddAnnotation(stamp);

            annotLocation = new Rectangle(150, 670, 90, 90);
            stamp         = new PdfStampAnnotation(annotLocation)
                            .SetStampName(new PdfName("Confidential"))
                            .SetContents("Portrait")
                            .Put(PdfName.Rotate, new PdfNumber(90));
            firstPage.AddAnnotation(stamp);

            annotLocation = new Rectangle(250, 670, 90, 90);
            stamp         = new PdfStampAnnotation(annotLocation)
                            .SetStampName(new PdfName("Confidential"))
                            .SetContents("Portrait")
                            .Put(PdfName.Rotate, new PdfNumber(45));
            firstPage.AddAnnotation(stamp);

            pdfDoc.Close();
        }
Exemple #24
0
        public virtual void LinkActionOnDivSplitTest01()
        {
            String      outFileName = destinationFolder + "linkActionOnDivSplitTest01.pdf";
            String      cmpFileName = sourceFolder + "cmp_linkActionOnDivSplitTest01.pdf";
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));
            Document    doc         = new Document(pdfDocument);
            PdfAction   action      = PdfAction.CreateURI("http://itextpdf.com");
            Div         div         = new Div().SetHeight(2000).SetBackgroundColor(ColorConstants.RED);

            div.SetAction(action);
            doc.Add(div);
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             ));
        }
Exemple #25
0
        public virtual void RotatedLinkInnerRotation()
        {
            String    outFileName = destinationFolder + "rotatedLinkInnerRotation.pdf";
            String    cmpFileName = sourceFolder + "cmp_rotatedLinkInnerRotation.pdf";
            Document  doc         = new Document(new PdfDocument(new PdfWriter(outFileName)));
            PdfAction action      = PdfAction.CreateURI("http://itextpdf.com/", false);
            Link      link        = new Link("TestLink", action);
            Paragraph p           = new Paragraph(link).SetRotationAngle(Math.PI / 4).SetBackgroundColor(ColorConstants.RED);
            Div       div         = new Div().Add(p).SetRotationAngle(Math.PI / 3).SetBackgroundColor(ColorConstants.BLUE);

            doc.Add(div);
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }
Exemple #26
0
        private Paragraph CreateCopyrightFooter()
        {
            var link = new Link(" aquí", PdfAction.CreateURI(Configuration["Information:Download"]))
                       .SetFontColor(ColorConstants.BLUE)
                       .SetFontSize(8f);
            var bottom = new Paragraph()
                         .SetTextAlignment(TextAlignment.RIGHT)
                         .SetFontSize(8f)
                         .SetFont(PdfFontFactory.CreateFont(StandardFonts.HELVETICA))
                         .Add("Creado con ")
                         .Add(new Text("Office Eclesial\n").SetFont(PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD)))
                         .Add("Disponible para descarga")
                         .Add(link);

            return(bottom);
        }
Exemple #27
0
        public virtual void SplitLinkTest01()
        {
            String            outFileName = destinationFolder + "splitLinkTest01.pdf";
            String            cmpFileName = sourceFolder + "cmp_splitLinkTest01.pdf";
            PdfDocument       pdfDocument = new PdfDocument(new PdfWriter(outFileName));
            Document          doc         = new Document(pdfDocument);
            PdfAction         action      = PdfAction.CreateURI("http://itextpdf.com");
            PdfLinkAnnotation annotation  = new PdfLinkAnnotation(new Rectangle(1, 1)).SetAction(action);
            Link linkByAnnotation         = new Link(LONG_TEXT, annotation);

            doc.Add(new Div().SetHeight(700).SetBackgroundColor(ColorConstants.RED));
            // This paragraph is so long that it will be present on the first, second and third pages
            doc.Add(new Paragraph(linkByAnnotation));
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             ));
        }
Exemple #28
0
        public virtual void SimpleMarginsTest01()
        {
            String      outFileName = destinationFolder + "simpleMarginsTest01.pdf";
            String      cmpFileName = sourceFolder + "cmp_simpleMarginsTest01.pdf";
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));
            Document    doc         = new Document(pdfDocument);
            PdfAction   action      = PdfAction.CreateURI("http://itextpdf.com/", false);
            Link        link        = new Link("TestLink", action);

            link.SetBorder(new SolidBorder(ColorConstants.BLUE, 20));
            link.SetProperty(Property.MARGIN_LEFT, UnitValue.CreatePointValue(50));
            link.SetProperty(Property.MARGIN_RIGHT, UnitValue.CreatePointValue(50));
            doc.Add(new Paragraph(link).SetBorder(new SolidBorder(10)));
            doc.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }
Exemple #29
0
        public virtual void TestCreateLocalLinkInRotatedCell()
        {
            String      outFileName = destinationFolder + "linkInRotatedCell.pdf";
            String      cmpFileName = sourceFolder + "cmp_linkInRotatedCell.pdf";
            PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName));
            Document    document    = new Document(pdfDocument);
            Table       table       = new Table(UnitValue.CreatePercentArray(new float[] { 1, 2 }));
            Link        chunk       = new Link("Click here", PdfAction.CreateURI("http://itextpdf.com/"));

            table.AddCell(new Cell().Add(new Paragraph().Add(chunk)).SetRotationAngle(Math.PI / 2));
            chunk = new Link("Click here 2", PdfAction.CreateURI("http://itextpdf.com/"));
            table.AddCell(new Paragraph().Add(chunk));
            document.Add(table);
            document.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder
                                                                             , "diff"));
        }
Exemple #30
0
        public virtual void CanvasWithPageLinkTest()
        {
            String      testName  = "canvasWithPageLinkTest";
            String      @out      = destinationFolder + testName + ".pdf";
            String      cmp       = sourceFolder + "cmp_" + testName + ".pdf";
            PdfDocument pdf       = new PdfDocument(new PdfWriter(@out));
            PdfPage     page      = pdf.AddNewPage();
            Rectangle   pageSize  = page.GetPageSize();
            Rectangle   rectangle = new Rectangle(pageSize.GetX() + 36, pageSize.GetTop() - 80, pageSize.GetWidth() - 72
                                                  , 50);

            iText.Layout.Canvas canvas = new iText.Layout.Canvas(page, rectangle);
            canvas.Add(new Paragraph(new Link("Google link!", PdfAction.CreateURI("https://www.google.com")).SetUnderline
                                         ().SetFontColor(ColorConstants.BLUE)));
            canvas.Close();
            pdf.Close();
            NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(@out, cmp, destinationFolder));
        }