Skip to content

Commit

Permalink
Merge branch 'develop' into devsecops
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-ivanov committed Feb 5, 2025
2 parents d51e70e + 83ec8b0 commit e4517d0
Show file tree
Hide file tree
Showing 114 changed files with 1,180 additions and 283 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ public virtual void GetRGBAColorWithExceptionDuringParsing() {
NUnit.Framework.Assert.IsNull(resultCmyk);
}

[NUnit.Framework.Test]
public virtual void GetRGBAColorWithExceptionDuringParsingAlpha() {
float[] resultCmyk = WebColors.GetRGBAColor("rgba(44, 100, 0, 0,75)");
NUnit.Framework.Assert.IsNull(resultCmyk);
}

[NUnit.Framework.Test]
public virtual void GetCMYKColorTest() {
//corresponding color name = "violet"
Expand Down
26 changes: 26 additions & 0 deletions itext.tests/itext.kernel.tests/itext/kernel/pdf/PdfPageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using System.IO;
using iText.Commons.Utils;
using iText.IO.Source;
using iText.Kernel.Geom;
Expand Down Expand Up @@ -138,6 +139,31 @@ public virtual void SetTrimBoxTest() {
NUnit.Framework.Assert.IsTrue(pageDictionary.IsModified());
}

[NUnit.Framework.Test]
public virtual void AddAnnotationAnnotTagPDF2Test() {
byte[] docBytes;
using (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
using (PdfDocument doc = new PdfDocument(new PdfWriter(outputStream, new WriterProperties().SetPdfVersion(
PdfVersion.PDF_2_0)))) {
doc.SetTagged();
PdfPage page = new PdfPage(doc);
PdfPopupAnnotation annot = new PdfPopupAnnotation(new Rectangle(100, 100, 100, 100));
annot.SetName(new PdfString("this is a pop up"));
page.AddAnnotation(annot);
}
docBytes = outputStream.ToArray();
}
using (PdfDocument docReopen = new PdfDocument(new PdfReader(new MemoryStream(docBytes)))) {
PdfDictionary structTreeRoot = docReopen.GetCatalog().GetPdfObject().GetAsDictionary(PdfName.StructTreeRoot
);
PdfDictionary structElem = ((PdfDictionary)structTreeRoot.GetAsArray(PdfName.K).Get(0)).GetAsDictionary(PdfName
.K);
NUnit.Framework.Assert.AreEqual(PdfName.Annot, structElem.GetAsName(PdfName.S));
NUnit.Framework.Assert.AreEqual(new PdfString("this is a pop up"), structElem.GetAsDictionary(PdfName.K).GetAsDictionary
(PdfName.Obj).GetAsString(PdfName.NM));
}
}

/// <summary>Simulates indirect state of object making sure it is not marked as modified.</summary>
/// <param name="obj">object to which indirect state simulation is applied</param>
private void SimulateIndirectState(PdfObject obj) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ public virtual void PdfUA2RubberStampNoContentsAnnotationsTest() {

[NUnit.Framework.Test]
public virtual void PdfUA2ScreenAnnotationsTest() {
//TODO DEVSIX-8807 Kernel: addAnnotation method doesn't annotate content elements with Annot tag when PDF version is 2.0
String outFile = DESTINATION_FOLDER + "pdfuaScreenAnnotationTest.pdf";
String cmpFile = SOURCE_FOLDER + "cmp_pdfuaScreenAnnotationTest.pdf";
using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFile, new WriterProperties().SetPdfVersion
(PdfVersion.PDF_2_0)))) {
CreateSimplePdfUA2Document(pdfDocument);
Expand All @@ -180,10 +180,9 @@ public virtual void PdfUA2ScreenAnnotationsTest() {
pdfPage.AddAnnotation(screen);
pdfPage.Flush();
}
new VeraPdfValidator().ValidateFailure(outFile);
CompareAndValidate(outFile, cmpFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
[NUnit.Framework.Test]
public virtual void PdfUA2ScreenNoContentsAnnotationsTest() {
String outFile = DESTINATION_FOLDER + "pdfuaScreenNoContentsAnnotationTest.pdf";
Expand Down Expand Up @@ -263,8 +262,8 @@ public virtual void PdfUA2RedactionNoContentsAnnotationsTest() {

[NUnit.Framework.Test]
public virtual void PdfUA23DAnnotationsTest() {
//TODO DEVSIX-8807 Kernel: addAnnotation method doesn't annotate content elements with Annot tag when PDF version is 2.0
String outFile = DESTINATION_FOLDER + "pdfua3DAnnotationTest.pdf";
String cmpFile = SOURCE_FOLDER + "cmp_pdfua3DAnnotationTest.pdf";
using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFile, new WriterProperties().SetPdfVersion
(PdfVersion.PDF_2_0)))) {
CreateSimplePdfUA2Document(pdfDocument);
Expand All @@ -273,10 +272,9 @@ public virtual void PdfUA23DAnnotationsTest() {
pdfPage.AddAnnotation(annot);
pdfPage.Flush();
}
new VeraPdfValidator().ValidateFailure(outFile);
CompareAndValidate(outFile, cmpFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
[NUnit.Framework.Test]
public virtual void PdfUA23DNoContentsAnnotationsTest() {
String outFile = DESTINATION_FOLDER + "pdfua3DNoContentsAnnotationTest.pdf";
Expand Down Expand Up @@ -394,8 +392,8 @@ public virtual void PdfUA2AltContentDiffAnnotationTest() {
// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
[NUnit.Framework.Test]
public virtual void PdfUA2TabAnnotationsTest() {
//TODO DEVSIX-8807 Kernel: addAnnotation method doesn't annotate content elements with Annot tag when PDF version is 2.0
String outFile = DESTINATION_FOLDER + "pdfuaMultipleAnnotsTabAnnotationTest.pdf";
String cmpFile = SOURCE_FOLDER + "cmp_pdfuaMultipleAnnotsTabAnnotationTest.pdf";
using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFile, new WriterProperties().SetPdfVersion
(PdfVersion.PDF_2_0)))) {
CreateSimplePdfUA2Document(pdfDocument);
Expand All @@ -411,10 +409,9 @@ public virtual void PdfUA2TabAnnotationsTest() {
NUnit.Framework.Assert.AreEqual(PdfName.S, pageT);
}
}
new VeraPdfValidator().ValidateFailure(outFile);
CompareAndValidate(outFile, cmpFile);
}

// Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf\a validation on Android)
[NUnit.Framework.Test]
public virtual void AnnotationInvisibleButNoArtifactTest() {
String outFile = DESTINATION_FOLDER + "pdfuaInvisibleAnnotationTest.pdf";
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit e4517d0

Please sign in to comment.