diff --git a/itext.tests/itext.layout.tests/resources/itext/layout/CanvasTest/cmp_canvasWithPageEnableTaggingTest01.pdf b/itext.tests/itext.layout.tests/resources/itext/layout/CanvasTest/cmp_canvasWithPageEnableTaggingTest01.pdf index 6502b796cd..5466863a98 100644 Binary files a/itext.tests/itext.layout.tests/resources/itext/layout/CanvasTest/cmp_canvasWithPageEnableTaggingTest01.pdf and b/itext.tests/itext.layout.tests/resources/itext/layout/CanvasTest/cmp_canvasWithPageEnableTaggingTest01.pdf differ diff --git a/itext.tests/itext.layout.tests/resources/itext/layout/LayoutTaggingPdf2Test/cmp_docWithSectInPdf2.pdf b/itext.tests/itext.layout.tests/resources/itext/layout/LayoutTaggingPdf2Test/cmp_docWithSectInPdf2.pdf index 5502c694d3..2ec2e61487 100644 Binary files a/itext.tests/itext.layout.tests/resources/itext/layout/LayoutTaggingPdf2Test/cmp_docWithSectInPdf2.pdf and b/itext.tests/itext.layout.tests/resources/itext/layout/LayoutTaggingPdf2Test/cmp_docWithSectInPdf2.pdf differ diff --git a/itext.tests/itext.layout.tests/resources/itext/layout/LayoutTaggingTest/cmp_linkTest01.pdf b/itext.tests/itext.layout.tests/resources/itext/layout/LayoutTaggingTest/cmp_linkTest01.pdf index 57a19fcf18..b4283165e3 100644 Binary files a/itext.tests/itext.layout.tests/resources/itext/layout/LayoutTaggingTest/cmp_linkTest01.pdf and b/itext.tests/itext.layout.tests/resources/itext/layout/LayoutTaggingTest/cmp_linkTest01.pdf differ diff --git a/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUALayoutTest.cs b/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUALayoutTest.cs index 5a6882dce7..2f3a7e495a 100644 --- a/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUALayoutTest.cs +++ b/itext.tests/itext.pdfua.tests/itext/pdfua/checkers/PdfUALayoutTest.cs @@ -69,6 +69,23 @@ public virtual void SimpleParagraphTest() { NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(outPdf)); } + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) + [NUnit.Framework.Test] + public virtual void SimpleParagraphWithUnderlineTest() { + String outPdf = DESTINATION_FOLDER + "simpleParagraphTest.pdf"; + String cmpPdf = SOURCE_FOLDER + "cmp_simpleParagraphWithUnderlineTest.pdf"; + PdfUATestPdfDocument pdfDoc = new PdfUATestPdfDocument(new PdfWriter(outPdf, PdfUATestPdfDocument.CreateWriterProperties + ())); + PdfFont font = PdfFontFactory.CreateFont(FONT, PdfEncodings.WINANSI, PdfFontFactory.EmbeddingStrategy.FORCE_EMBEDDED + ); + Document doc = new Document(pdfDoc); + doc.Add(new Paragraph("Simple layout PDF/UA-1 with underline test").SetFont(font).SetUnderline()); + doc.Close(); + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outPdf, cmpPdf, DESTINATION_FOLDER, "diff_" + )); + NUnit.Framework.Assert.IsNull(new VeraPdfValidator().Validate(outPdf)); + } + // Android-Conversion-Skip-Line (TODO DEVSIX-7377 introduce pdf/ua validation on Android) [NUnit.Framework.Test] public virtual void SimpleBorderTest() { diff --git a/itext.tests/itext.pdfua.tests/resources/itext/pdfua/PdfUALayoutTest/cmp_simpleParagraphWithUnderlineTest.pdf b/itext.tests/itext.pdfua.tests/resources/itext/pdfua/PdfUALayoutTest/cmp_simpleParagraphWithUnderlineTest.pdf new file mode 100644 index 0000000000..9ec7e263b7 Binary files /dev/null and b/itext.tests/itext.pdfua.tests/resources/itext/pdfua/PdfUALayoutTest/cmp_simpleParagraphWithUnderlineTest.pdf differ diff --git a/itext/itext.layout/itext/layout/renderer/TextRenderer.cs b/itext/itext.layout/itext/layout/renderer/TextRenderer.cs index 0cb4858b7d..3ac45e8222 100644 --- a/itext/itext.layout/itext/layout/renderer/TextRenderer.cs +++ b/itext/itext.layout/itext/layout/renderer/TextRenderer.cs @@ -911,24 +911,24 @@ public override void Draw(DrawContext drawContext) { } canvas.EndText().RestoreState(); EndElementOpacityApplying(drawContext); + if (isTagged) { + canvas.CloseTag(); + } Object underlines = this.GetProperty(Property.UNDERLINE); if (underlines is IList) { foreach (Object underline in (IList)underlines) { if (underline is Underline) { - DrawSingleUnderline((Underline)underline, fontColor, canvas, fontSize.GetValue(), italicSimulation ? ITALIC_ANGLE - : 0); + DrawAndTagSingleUnderline(drawContext.IsTaggingEnabled(), (Underline)underline, fontColor, canvas, fontSize + .GetValue(), italicSimulation ? ITALIC_ANGLE : 0); } } } else { if (underlines is Underline) { - DrawSingleUnderline((Underline)underlines, fontColor, canvas, fontSize.GetValue(), italicSimulation ? ITALIC_ANGLE - : 0); + DrawAndTagSingleUnderline(drawContext.IsTaggingEnabled(), (Underline)underlines, fontColor, canvas, fontSize + .GetValue(), italicSimulation ? ITALIC_ANGLE : 0); } } - if (isTagged) { - canvas.CloseTag(); - } } if (isRelativePosition) { ApplyRelativePositioningTranslation(false); @@ -1678,6 +1678,17 @@ internal virtual bool[] IsStartsWithSplitCharWhiteSpaceAndEndsWithSplitChar(ISpl } } + private void DrawAndTagSingleUnderline(bool isTagged, Underline underline, TransparentColor fontStrokeColor + , PdfCanvas canvas, float fontSize, float italicAngleTan) { + if (isTagged) { + canvas.OpenTag(new CanvasArtifact()); + } + DrawSingleUnderline(underline, fontStrokeColor, canvas, fontSize, italicAngleTan); + if (isTagged) { + canvas.CloseTag(); + } + } + private float GetCharWidth(Glyph g, float fontSize, float? hScale, float? characterSpacing, float? wordSpacing ) { if (hScale == null) { diff --git a/port-hash b/port-hash index 5592dbea14..de0a2f83f7 100644 --- a/port-hash +++ b/port-hash @@ -1 +1 @@ -16ce4653542fa02480dd15063f1dd5cc0c874f54 +38302fac797c3956c68cdfd02edba765ea311064