public virtual void CreatePdf(String dest) { PdfDocument pdf = new PdfDocument(new PdfWriter(dest)); Document document = new Document(pdf); Paragraph p = new Paragraph().Add("Go to last page").SetAction(PdfAction.CreateNamed(PdfName.LastPage)); document.Add(p); 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); } list.Add(li); } document.Add(list); p = new Paragraph().Add("Go to first page").SetAction(PdfAction.CreateNamed(PdfName.FirstPage)); document.Add(p); document.Close(); }
public virtual void CreateNamedTest() { String fileName = "createNamedTest.pdf"; PdfDocument document = CreateDocument(new PdfWriter(destinationFolder + fileName), false); document.GetPage(1).SetAdditionalAction(PdfName.O, PdfAction.CreateNamed(PdfName.LastPage)); document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + fileName, sourceFolder + "cmp_" + fileName, destinationFolder, "diff_")); }