static void imgStyle(ref Image img, ImageSelection image) { var directories = MetadataExtractor.ImageMetadataReader.ReadMetadata(image.getPath()); foreach (var directory in directories) { foreach (var tag in directory.Tags) { if (tag.Name == "Orientation" && directory.Name == "Exif IFD0") { OrientationChecking.rotateChecking(ref img, tag.Description); break; } } if (directory.HasError) { foreach (var error in directory.Errors) { Console.WriteLine($"ERROR: {error}"); } } } img.SetHorizontalAlignment(HorizontalAlignment.CENTER); img.SetAutoScale(true); }
public virtual void PrecisionTest01() { String outFileName = destinationFolder + "precisionTest01.pdf"; String cmpFileName = sourceFolder + "cmp_precisionTest01.pdf"; String imageFileName = sourceFolder + "LOGO_PDF_77.jpg"; PdfDocument pdfDoc = new PdfDocument(new PdfWriter(outFileName)); PdfPage page = pdfDoc.AddNewPage(); PdfCanvas currentPdfCanvas = new PdfCanvas(page); Rectangle rc = new Rectangle(56.6929131f, 649.13385f, 481.889771f, 136.062988f); iText.Layout.Canvas canvas = new iText.Layout.Canvas(currentPdfCanvas, pdfDoc, rc); Table table = new Table(UnitValue.CreatePointArray(new float[] { 158f })); table.SetTextAlignment(TextAlignment.LEFT); iText.Layout.Element.Image logoImage = new iText.Layout.Element.Image(ImageDataFactory.Create(imageFileName )); Paragraph p = new Paragraph().Add(logoImage.SetAutoScale(true)); Cell cell = new Cell(); cell.SetKeepTogether(true); cell.Add(p); table.AddCell(cell.SetHeight(85.03937f).SetVerticalAlignment(VerticalAlignment.TOP).SetPadding(0)); canvas.Add(table); pdfDoc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
public virtual void TableTest01() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(new FileStream(destinationFolder + "tableTest01.pdf" , FileMode.Create))); pdfDocument.SetTagged(); Document document = new Document(pdfDocument); Table table = new Table(3); table.AddCell(CreateParagraph1()); iText.Layout.Element.Image image = new iText.Layout.Element.Image(ImageDataFactory.Create(sourceFolder + imageName )); image.SetAutoScale(true); table.AddCell(image); table.AddCell(CreateParagraph2()); table.AddCell(image); table.AddCell(new Paragraph("abcdefghijklkmnopqrstuvwxyz").SetFontColor(Color.GREEN)); table.AddCell("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ); document.Add(table); document.Close(); CompareResult("tableTest01.pdf", "cmp_tableTest01.pdf"); }
public Table getTable(PdfDocumentEvent docEvent) { Style styleText = new Style().SetTextAlignment(TextAlignment.RIGHT).SetFontSize(12).SetBold(); Style styleDatos = new Style().SetTextAlignment(TextAlignment.RIGHT).SetFontSize(8); Style styleCell = new Style().SetBorder(Border.NO_BORDER); float[] cellWidth = { 10f, 50f, 33f }; Table tableEvent = new Table(UnitValue.CreatePercentArray(cellWidth)).UseAllAvailableWidth().SetBorder(Border.NO_BORDER); Cell cell = new Cell().Add(Img.SetAutoScale(true)).AddStyle(styleCell); tableEvent.AddCell(cell).SetTextAlignment(TextAlignment.RIGHT); cell = new Cell().Add(new Paragraph("CENTRE TERAPÈUTIC ONIX").AddStyle(styleText)).AddStyle(styleCell); tableEvent.AddCell(cell); cell = new Cell() .Add(new Paragraph("Tel.: 931 058 931\n")) .Add(new Paragraph("Mail: centerapeutic.onix @gmail.com")).AddStyle(styleDatos).AddStyle(styleCell); tableEvent.AddCell(cell); return(tableEvent); }
public Table getTable(PdfDocumentEvent docEvent) { float[] cellWidth = { 20f, 80f }; Table tableEvent = new Table(UnitValue.CreatePercentArray(cellWidth)).UseAllAvailableWidth(); Style styleCell = new Style().SetBorder(Border.NO_BORDER); Style styleText = new Style().SetTextAlignment(TextAlignment.RIGHT).SetFontSize(10f); Cell cell = new Cell().Add(img.SetAutoScale(true)); tableEvent.AddCell(cell.AddStyle(styleCell).SetTextAlignment(TextAlignment.LEFT)); PdfFont bold = PdfFontFactory.CreateFont(StandardFonts.HELVETICA); cell = new Cell() .Add(new Paragraph("Bookter.in\n").SetFont(bold)) .Add(new Paragraph("Be good, read good!\n").SetFont(bold)) .Add(new Paragraph(DateTime.Now.ToShortDateString())) .AddStyle(styleText) .AddStyle(styleCell); tableEvent.AddCell(cell); return(tableEvent); }
public virtual void ImageTest11() { String outFileName = destinationFolder + "imageTest11.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest11.pdf"; PdfWriter writer = new PdfWriter(outFileName); PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc); iText.Layout.Element.Image image = new iText.Layout.Element.Image(ImageDataFactory.Create(sourceFolder + "Desert.jpg" )); image.SetAutoScale(true); doc.Add(image); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
public virtual void DivTest01() { PdfDocument pdfDocument = new PdfDocument(new PdfWriter(destinationFolder + "divTest01.pdf")); pdfDocument.SetTagged(); Document document = new Document(pdfDocument); Div div = new Div(); div.Add(CreateParagraph1()); iText.Layout.Element.Image image = new iText.Layout.Element.Image(ImageDataFactory.Create(sourceFolder + imageName )); image.SetAutoScale(true); div.Add(image); div.Add(CreateParagraph2()); div.Add(image); div.Add(CreateParagraph2()); document.Add(div); document.Close(); CompareResult("divTest01.pdf", "cmp_divTest01.pdf"); }
public virtual void ImageTest18() { String outFileName = destinationFolder + "imageTest18.pdf"; String cmpFileName = sourceFolder + "cmp_imageTest18.pdf"; PdfWriter writer = new PdfWriter(outFileName); PdfDocument pdfDoc = new PdfDocument(writer); Document doc = new Document(pdfDoc); iText.Layout.Element.Image image = new iText.Layout.Element.Image(ImageDataFactory.Create(sourceFolder + "Desert.jpg" )); image.SetAutoScale(true); Div container = new Div(); container.SetBorder(new SolidBorder(1f)); container.SetWidth(UnitValue.CreatePercentValue(50f)); container.SetHeight(UnitValue.CreatePointValue(300f)); container.Add(image); doc.Add(container); doc.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }
public virtual void FlushOnDrawCheckCircularReferencesTest() { String outFileName = destinationFolder + "flushOnDrawCheckCircularReferencesTest.pdf"; String cmpFileName = sourceFolder + "cmp_flushOnDrawCheckCircularReferencesTest.pdf"; PdfDocument pdf = new PdfDocument(new PdfWriter(outFileName)); //Initialize document Document document = new Document(pdf); iText.Layout.Element.Image img = new iText.Layout.Element.Image(ImageDataFactory.Create(sourceFolder + "itis.jpg" )); img.SetAutoScale(true); Table table = new Table(4); table.SetWidthPercent(100); for (int k = 0; k < 5; k++) { table.AddCell("Hello World from iText7"); List list = new List().SetListSymbol("-> "); list.Add("list item").Add("list item").Add("list item").Add("list item").Add("list item"); Cell cell = new Cell().Add(list); table.AddCell(cell); Cell c = new Cell().Add(img); table.AddCell(c); Table innerTable = new Table(3); int j = 0; while (j < 9) { innerTable.AddCell("Hi"); j++; } table.AddCell(innerTable); } document.Add(table); document.Close(); NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder , "diff")); }