public virtual void FontsResourcesHelvFontTest() { String filename = "fontsResourcesHelvFontTest.pdf"; PdfDocument pdfDoc = new PdfDocument(new PdfReader(sourceFolder + "drWithHelv.pdf"), new PdfWriter(destinationFolder + filename)); PdfFont font = PdfFontFactory.CreateFont(sourceFolder + "NotoSans-Regular.ttf", PdfEncodings.IDENTITY_H); font.SetSubset(false); PdfAcroForm form = PdfAcroForm.GetAcroForm(pdfDoc, false); form.GetField("description").SetValue(TEXT, font, 12f); pdfDoc.Close(); PdfDocument document = new PdfDocument(new PdfReader(destinationFolder + filename)); PdfDictionary actualDocumentFonts = PdfAcroForm.GetAcroForm(document, false).GetPdfObject().GetAsDictionary (PdfName.DR).GetAsDictionary(PdfName.Font); // Note that we know the structure of the expected pdf file PdfString expectedFieldsDAFont = new PdfString("/F2 12 Tf"); PdfObject actualFieldDAFont = document.GetCatalog().GetPdfObject().GetAsDictionary(PdfName.AcroForm).GetAsArray (PdfName.Fields).GetAsDictionary(0).Get(PdfName.DA); NUnit.Framework.Assert.AreEqual(new PdfName("Helvetica"), actualDocumentFonts.GetAsDictionary(new PdfName( "F1")).Get(PdfName.BaseFont), "There is no Helvetica font within DR key"); NUnit.Framework.Assert.AreEqual(new PdfName("NotoSans"), actualDocumentFonts.GetAsDictionary(new PdfName("F2" )).Get(PdfName.BaseFont), "There is no NotoSans font within DR key."); NUnit.Framework.Assert.AreEqual(expectedFieldsDAFont, actualFieldDAFont, "There is no NotoSans(/F2) font within Fields DA key" ); document.Close(); ExtendedITextTest.PrintOutputPdfNameAndDir(destinationFolder + filename); }
public virtual void PageCountTestTableFloatLeft() { NUnit.Framework.Assert.That(() => { //TODO: DEVSIX-1570, SUP-2322. Remove junitExpectedException after the fix. String expectedText = "Page 3 of 3"; String nameFloatLeft = "htmlWithTableFloatLeft.html"; String pdfOutputName = DESTINATION_FOLDER + nameFloatLeft + ".pdf"; FileInfo pdfOutputFloatLeft = new FileInfo(pdfOutputName); HtmlConverter.ConvertToPdf(new FileInfo(SOURCE_FOLDER + nameFloatLeft), pdfOutputFloatLeft); PdfDocument pdfDocument = new PdfDocument(new PdfReader(pdfOutputFloatLeft)); String textFromPage = PdfTextExtractor.GetTextFromPage(pdfDocument.GetPage(3)); // Print the output file. No comparison will be made on the following line ExtendedITextTest.PrintOutputPdfNameAndDir(pdfOutputName); NUnit.Framework.Assert.IsTrue(textFromPage.Contains(expectedText), "Page doesn't contain text " + expectedText ); } , NUnit.Framework.Throws.InstanceOf <AssertionException>()) ; }