From 508dfe64a23802f5cdc00407e9d4db9f596c2c35 Mon Sep 17 00:00:00 2001 From: Vitali Prudnikovich Date: Mon, 17 Feb 2025 12:24:04 +0000 Subject: [PATCH 1/2] Use neutral role for anonymous box DEVSIX-8869 Autoported commit. Original commit hash: [a37f11613] --- .../itext/layout/AnonymousBoxTest.cs | 20 ++++++++++++++++-- .../AnonymousBoxTest/cmp_defaultRole.pdf | Bin 0 -> 1759 bytes .../AnonymousBoxTest/cmp_relativeHeight.pdf | Bin 0 -> 13791 bytes .../itext/layout/element/AnonymousBox.cs | 9 ++++++++ .../itext/layout/element/Paragraph.cs | 1 + port-hash | 2 +- 6 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 itext.tests/itext.layout.tests/resources/itext/layout/AnonymousBoxTest/cmp_defaultRole.pdf create mode 100644 itext.tests/itext.layout.tests/resources/itext/layout/AnonymousBoxTest/cmp_relativeHeight.pdf diff --git a/itext.tests/itext.layout.tests/itext/layout/AnonymousBoxTest.cs b/itext.tests/itext.layout.tests/itext/layout/AnonymousBoxTest.cs index 41a4eb5ed..476f94747 100644 --- a/itext.tests/itext.layout.tests/itext/layout/AnonymousBoxTest.cs +++ b/itext.tests/itext.layout.tests/itext/layout/AnonymousBoxTest.cs @@ -45,8 +45,8 @@ public static void BeforeClass() { [NUnit.Framework.Test] public virtual void RelativeHeightTest() { - String outFileName = DESTINATION_FOLDER + "relativeHeightTest.pdf"; - String cmpFileName = SOURCE_FOLDER + "cmp_relativeHeightTest.pdf"; + String outFileName = DESTINATION_FOLDER + "relativeHeight.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_relativeHeight.pdf"; using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName))) { Document doc = new Document(pdfDocument); Div div = new Div(); @@ -63,5 +63,21 @@ public virtual void RelativeHeightTest() { NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, DESTINATION_FOLDER , "diff")); } + + [NUnit.Framework.Test] + public virtual void DefaultRoleTest() { + String outFileName = DESTINATION_FOLDER + "defaultRole.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_defaultRole.pdf"; + using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName))) { + pdfDocument.SetTagged(); + Document doc = new Document(pdfDocument); + AnonymousBox ab = new AnonymousBox(); + ab.Add(new Paragraph("Some text")); + doc.Add(ab); + doc.Close(); + } + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, DESTINATION_FOLDER + , "diff")); + } } } diff --git a/itext.tests/itext.layout.tests/resources/itext/layout/AnonymousBoxTest/cmp_defaultRole.pdf b/itext.tests/itext.layout.tests/resources/itext/layout/AnonymousBoxTest/cmp_defaultRole.pdf new file mode 100644 index 0000000000000000000000000000000000000000..b159e279dafe8c7314530996e3fd70814ed07e6c GIT binary patch literal 1759 zcmc&!-EQMV6h>TC76|bMa}#X}O6JG**hW#LG-NH@xya^XVjpJ>i5>V{|(=lq#ot8?F`~A`2lY0M$`r~(geJ0<% zHeSd-i0q5oBp01ITnj%3J@Th-!yXTYcEiWfA0Sp9~Q^7PAcdcr4@PE#~p%3Kabu+HEaU zi=$LA>BGd+l+%q}->N#EDAplz^}q3Oj&wRB6~SML1ec6!35N?ipkVaQXzCUOa%;&Xf|F4H2{d;xSK)iPwQF9#5%5|E{`JVB*ArNgem58oVHLtbgG zbR(!m@lRP}wcyGCx@CuO)zPsS1e(RE|i71x$CxX4f75>Y%#7cda3R!b>olVhIWd=fi-cO>mIzot4Lsf&yK4sMutSh|Xsd6bJbVV)}>3mCVZq;|ygy(UZ z^wa{>dmk~vY{IBTP1_^hhs3-?$en#WNW=dI3}qS?0mynhR+;{Yy1FS|lQl`hKkE$r z%a65t2I#I#ixoP%x4+d|j&W7$1CfCqaC{7l zhmgmCz=w%i+BlixPvfMMWbv!JU(9kn%DMt{U1{yQCDtvfc)Mw#mWkq%ILs#H>`vDn zdJnR#OWD@S=d4&}YA4Ix7)`gB3ki{-?53fTt3JeS+q6-HHa7057U&Np8yh8-nxmUG z;<#$ic5JryFE&$6%MOlmmEn$!(AzOAq8^$ZoN3+CM?70qW*0}*%H6b4;=P8;rHB_G z^;6sLp-IbO%yvUcsOP#7XHMu)BEX^!x=Js>| literal 0 HcmV?d00001 diff --git a/itext.tests/itext.layout.tests/resources/itext/layout/AnonymousBoxTest/cmp_relativeHeight.pdf b/itext.tests/itext.layout.tests/resources/itext/layout/AnonymousBoxTest/cmp_relativeHeight.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f71dc8fac05eca45f4a93b040479c77677c741e5 GIT binary patch literal 13791 zcmc(G2UL^W)?kn#f{1hhB`6>W(g_`+C?FuccOe7_F+_UANW3V$DMjw3#R5ja5Getr zMF{1JB2ptkN`i$VkSIbfgfQ{_?|<)~f7Y5c@6B2>C+mFc%jtWcea^S5ipxbCOAm!Z)S@sW!9CYF|Q@v+bl zgb=DiP!Ui|%U?_SwGdrykH16w zt0M02Q~a&vg^>7=tH_9dHrD@V;|pB)<6+3?i(K@mT{P9x(F5t|=@{wifs7468an!_ zIy$Onv>lOQ|N90mvB$JUL zVZW$KPv;+Gwf|v%0dUmb#?A)7!@~pk^#knB051Ic_kWds4f20Az^~5xuK;3#fEJ!} zyga7>2gG=I#d!An06+kMhyOpu2K+to9N^{S7dR+*NJyC5fOr&efQOg&03R4ZNLuEYtenbeRkbtf z1|UNtV-wR07p-kzkFqs(uduE?%2osXzsQ8xJuD`ikdGlc=YL|scEM=lsqWLLsrd^ersn#+ z>VRdrc)!Hop1eUIlj@_&NSPo_CF^lb{@Jz4ypH*(qZaEAlMs;bqK`vIQHYzGyBZt{ z=>#csB(p4|A9*Y2>^NG3j&LU%b&FDtbUawDQekX0(`HuRXkPjdMRlrgnsaViDMO^! z;AX93;0dtnR}JmAe$4s@#6qe-A-bZP`Eov=9ryf<2i=S#+#S^46>OLwFzLe`r|Auo z z#o~r_SGm(U>z^+Ev8N#!y{Pg; z-j!$Jw&;6LyA{~-V=Zf*Y*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/element/AnonymousBox.cs b/itext/itext.layout/itext/layout/element/AnonymousBox.cs index 3e03f3c36..6ce096ff5 100644 --- a/itext/itext.layout/itext/layout/element/AnonymousBox.cs +++ b/itext/itext.layout/itext/layout/element/AnonymousBox.cs @@ -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 . */ +using iText.Kernel.Pdf.Tagutils; using iText.Layout.Renderer; namespace iText.Layout.Element { @@ -36,6 +37,14 @@ public AnonymousBox() : base() { } + /// + public override AccessibilityProperties GetAccessibilityProperties() { + if (tagProperties == null) { + tagProperties = new DefaultAccessibilityProperties(null); + } + return tagProperties; + } + /// protected internal override IRenderer MakeNewRenderer() { return new AnonymousBoxRenderer(this); diff --git a/itext/itext.layout/itext/layout/element/Paragraph.cs b/itext/itext.layout/itext/layout/element/Paragraph.cs index 5fe5f8e6e..b1b174d41 100644 --- a/itext/itext.layout/itext/layout/element/Paragraph.cs +++ b/itext/itext.layout/itext/layout/element/Paragraph.cs @@ -305,6 +305,7 @@ public virtual iText.Layout.Element.Paragraph SetMultipliedLeading(float leading return this; } + /// public override AccessibilityProperties GetAccessibilityProperties() { if (tagProperties == null) { tagProperties = new DefaultAccessibilityProperties(StandardRoles.P); diff --git a/port-hash b/port-hash index 173eb052a..cc97c5fa1 100644 --- a/port-hash +++ b/port-hash @@ -1 +1 @@ -9e804bacc19abcaa5c8554951f2049701e28002c +a37f11613bdb93aa13ff0f3a95e362d5bfb29e66 From 856819ee33898d699cce0e9a95fd7aea3307fcda Mon Sep 17 00:00:00 2001 From: Dmitry Chubrick Date: Mon, 17 Feb 2025 17:30:46 +0000 Subject: [PATCH 2/2] Set LINE_HEIGHT instead of LEADING for parapgraphs in HTML rendering mode Autoported commit. Original commit hash: [538e56033] --- .../itext/layout/ParagraphTest.cs | 67 +++++++++++++----- .../cmp_leadingInHtmlModeTest.pdf | Bin 0 -> 1635 bytes .../itext/layout/element/Paragraph.cs | 40 ++++++++++- port-hash | 2 +- 4 files changed, 88 insertions(+), 21 deletions(-) create mode 100644 itext.tests/itext.layout.tests/resources/itext/layout/ParagraphTest/cmp_leadingInHtmlModeTest.pdf diff --git a/itext.tests/itext.layout.tests/itext/layout/ParagraphTest.cs b/itext.tests/itext.layout.tests/itext/layout/ParagraphTest.cs index 4b2256155..cac7eb9bf 100644 --- a/itext.tests/itext.layout.tests/itext/layout/ParagraphTest.cs +++ b/itext.tests/itext.layout.tests/itext/layout/ParagraphTest.cs @@ -33,21 +33,21 @@ You should have received a copy of the GNU Affero General Public License namespace iText.Layout { [NUnit.Framework.Category("IntegrationTest")] public class ParagraphTest : ExtendedITextTest { - public static readonly String destinationFolder = NUnit.Framework.TestContext.CurrentContext.TestDirectory + private static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory + "/test/itext/layout/ParagraphTest/"; - public static readonly String sourceFolder = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext + private static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext .CurrentContext.TestDirectory) + "/resources/itext/layout/ParagraphTest/"; [NUnit.Framework.OneTimeSetUp] public static void BeforeClass() { - CreateDestinationFolder(destinationFolder); + CreateDestinationFolder(DESTINATION_FOLDER); } [NUnit.Framework.Test] public virtual void CannotPlaceABigChunkOnALineTest01() { - String outFileName = destinationFolder + "cannotPlaceABigChunkOnALineTest01.pdf"; - String cmpFileName = sourceFolder + "cmp_cannotPlaceABigChunkOnALineTest01.pdf"; + String outFileName = DESTINATION_FOLDER + "cannotPlaceABigChunkOnALineTest01.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_cannotPlaceABigChunkOnALineTest01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDocument); Paragraph p = new Paragraph().SetBorder(new SolidBorder(ColorConstants.YELLOW, 0)); @@ -56,14 +56,14 @@ public virtual void CannotPlaceABigChunkOnALineTest01() { p.Add(new Text("b").SetFontSize(100).SetBorder(new SolidBorder(ColorConstants.BLUE, 0))); doc.Add(p); doc.Close(); - NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, DESTINATION_FOLDER , "diff")); } [NUnit.Framework.Test] public virtual void CannotPlaceABigChunkOnALineTest02() { - String outFileName = destinationFolder + "cannotPlaceABigChunkOnALineTest02.pdf"; - String cmpFileName = sourceFolder + "cmp_cannotPlaceABigChunkOnALineTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "cannotPlaceABigChunkOnALineTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_cannotPlaceABigChunkOnALineTest02.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDocument); Paragraph p = new Paragraph().SetBorder(new SolidBorder(ColorConstants.YELLOW, 0)); @@ -73,14 +73,14 @@ public virtual void CannotPlaceABigChunkOnALineTest02() { ).SetFontSize(20).SetBorder(new SolidBorder(ColorConstants.BLUE, 0))); doc.Add(p); doc.Close(); - NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, DESTINATION_FOLDER , "diff")); } [NUnit.Framework.Test] public virtual void ForceOverflowForTextRendererPartialResult01() { - String outFileName = destinationFolder + "forceOverflowForTextRendererPartialResult01.pdf"; - String cmpFileName = sourceFolder + "cmp_forceOverflowForTextRendererPartialResult01.pdf"; + String outFileName = DESTINATION_FOLDER + "forceOverflowForTextRendererPartialResult01.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_forceOverflowForTextRendererPartialResult01.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document doc = new Document(pdfDocument); Paragraph p = new Paragraph().SetBorder(new SolidBorder(ColorConstants.YELLOW, 0)).SetTextAlignment(TextAlignment @@ -90,7 +90,7 @@ public virtual void ForceOverflowForTextRendererPartialResult01() { } doc.Add(p); doc.Close(); - NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, DESTINATION_FOLDER , "diff")); } @@ -99,8 +99,8 @@ public virtual void ForceOverflowForTextRendererPartialResult01() { .INFO)] public virtual void WordWasSplitAndItWillFitOntoNextLineTest02() { // TODO DEVSIX-4622 - String outFileName = destinationFolder + "wordWasSplitAndItWillFitOntoNextLineTest02.pdf"; - String cmpFileName = sourceFolder + "cmp_wordWasSplitAndItWillFitOntoNextLineTest02.pdf"; + String outFileName = DESTINATION_FOLDER + "wordWasSplitAndItWillFitOntoNextLineTest02.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_wordWasSplitAndItWillFitOntoNextLineTest02.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName)); Document document = new Document(pdfDocument); Paragraph paragraph = new Paragraph().Add(new Text("Short").SetBackgroundColor(ColorConstants.YELLOW)).Add @@ -108,14 +108,14 @@ public virtual void WordWasSplitAndItWillFitOntoNextLineTest02() { SolidBorder(1)); document.Add(paragraph); document.Close(); - NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, DESTINATION_FOLDER , "diff")); } [NUnit.Framework.Test] public virtual void ParagraphUsingSvgRenderingModeTest() { - String outFileName = destinationFolder + "paragraphUsingSvgRenderingMode.pdf"; - String cmpFileName = sourceFolder + "cmp_paragraphUsingSvgRenderingMode.pdf"; + String outFileName = DESTINATION_FOLDER + "paragraphUsingSvgRenderingMode.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_paragraphUsingSvgRenderingMode.pdf"; using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName))) { using (Document document = new Document(pdfDocument)) { Paragraph paragraph1 = new Paragraph().SetBorder(new SolidBorder(ColorConstants.YELLOW, 1)); @@ -135,7 +135,38 @@ public virtual void ParagraphUsingSvgRenderingModeTest() { document.Add(paragraph2); } } - NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, destinationFolder + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, DESTINATION_FOLDER + , "diff")); + } + + [NUnit.Framework.Test] + public virtual void LeadingInHtmlModeTest() { + String outFileName = DESTINATION_FOLDER + "leadingInHtmlModeTest.pdf"; + String cmpFileName = SOURCE_FOLDER + "cmp_leadingInHtmlModeTest.pdf"; + using (PdfDocument pdfDocument = new PdfDocument(new PdfWriter(outFileName))) { + using (Document document = new Document(pdfDocument)) { + String longText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. " + "Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa."; + Paragraph paragraph1 = new Paragraph(longText).SetBorder(new SolidBorder(ColorConstants.GREEN, 1)); + paragraph1.SetFixedLeading(40); + Paragraph paragraph2 = new Paragraph(longText).SetBorder(new SolidBorder(ColorConstants.BLUE, 1)); + paragraph2.SetProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE); + paragraph2.SetFixedLeading(40); + document.Add(new Paragraph("Default rendering mode:")); + document.Add(paragraph1); + document.Add(new Paragraph("HTML rendering mode:")); + document.Add(paragraph2); + Paragraph paragraph3 = new Paragraph(longText).SetBorder(new SolidBorder(ColorConstants.GREEN, 1)); + paragraph3.SetMultipliedLeading(5); + Paragraph paragraph4 = new Paragraph(longText).SetBorder(new SolidBorder(ColorConstants.BLUE, 1)); + paragraph4.SetProperty(Property.RENDERING_MODE, RenderingMode.HTML_MODE); + paragraph4.SetMultipliedLeading(5); + document.Add(new Paragraph("Default rendering mode:")); + document.Add(paragraph3); + document.Add(new Paragraph("HTML rendering mode:")); + document.Add(paragraph4); + } + } + NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(outFileName, cmpFileName, DESTINATION_FOLDER , "diff")); } } diff --git a/itext.tests/itext.layout.tests/resources/itext/layout/ParagraphTest/cmp_leadingInHtmlModeTest.pdf b/itext.tests/itext.layout.tests/resources/itext/layout/ParagraphTest/cmp_leadingInHtmlModeTest.pdf new file mode 100644 index 0000000000000000000000000000000000000000..dcad0b101fb12b317c6e0f553d07970da8108e7d GIT binary patch literal 1635 zcmc&!Yitx%7=?%kD@qHb1Vp@6TPSszJC8dL*w!q&EUk3gb-M@_2+Zu<*^VhQWp)as z!31IeTU#_zfnqTb9;HEA9x9O*KhxV2; zL0`waPf_PK8yR1tKLXyXd%j2*5eOwtbSr|`uYxN3ZGAf82KH-8zd5sM=-EB3SI-Ul zblvgsH!_-hgQPXEHE|i(0GNgBfaKlf%@yBOm;)dEes%lo`d`F8TTh%EcH(61BVWCz zF4+0Z+5M+36lDy5tgl?Kx?n$ybf6`loi6tLo~I=yr&c!R{dKy3)5F)9W6tVVTl&LQ zeM6h;b{1dS{o;(&jH3^2I_avpw*82gQ<8sfac!P6eC?!?x<2!Vwf5Qg+BXYUt=T@; z7pU5GtgN89t4HDMb%r!~>4)z}{O6Z!>3M@+*l@E~RsB!CGm!ap*@-~^jx*J7Ty|}m zq0~1{YTI;hhQITAmT%=0|DL3C!*ADYYroXBWU#RI*76E}=emiPQj{ldjt8ns+*sJ;Epw&$Ns4R3K^O^!Rqn%Pccx*g}y zH4|%Q6xc2d5`HYJ;yAr@DzuhJK!9hc=|n&@EDWGxkRXogB}N!WZNFOC_KO6py_abX zB4ntu9$*N~E5;U01ZQU2<=91#Rz}?R_C_>LA47UXQ!LUW-C(*K?6K~Esp^{7x+5dK zV<<==NRc$jFf?M*Aw2@Z5ov^9m;W0OFm$;jjE#|M2$z}-z@r-&2&1Xd(3zj>4&-O$ zg}}6t?g@b$Fb5k^>%eJgpq_#dI_)EYyV#f)#bAP=mlT8Cm(sdxwWWxE*f=qYZHxpYFH%3Yu2?^wFog;)!bTC{b!wDBAK>Iwg6=88I!l0*Ooud>(NWBevrgORgO-z zyBVB*CnKh0cS@;&6$b>I!zw#I0E-ZffCBEuIL;!l2hi@uNXQBI#~@EW7-Jc$i}&V2 zNLp69FD3~8!kLDs7GcBw-(`EjRF}+9q9lYBjAWkSDOsdwmK6}g(-2Ey7%9Ah1WI5y z83{7WQ?x`;GDn6nEkZ$5NK)iQ9zl`}BauQpq_{AHS!mI*G%Jt{tMG^-B@%PANGUum z$qdI!m_#I!krYOm|9=J3iEK^Lf$j1j5!7|7x3OuyT805<^)n^rQm1WF=e;I%L`~5! RV~r+B8ah%^#^?DQe*+LSJV*cl literal 0 HcmV?d00001 diff --git a/itext/itext.layout/itext/layout/element/Paragraph.cs b/itext/itext.layout/itext/layout/element/Paragraph.cs index b1b174d41..c0bdb92a3 100644 --- a/itext/itext.layout/itext/layout/element/Paragraph.cs +++ b/itext/itext.layout/itext/layout/element/Paragraph.cs @@ -284,11 +284,29 @@ public virtual iText.Layout.Element.Paragraph SetWidowsControl(ParagraphWidowsCo /// /// strategy. /// + /// + /// Sets the leading value, using the + /// + /// strategy. + /// + /// If for the element + /// + /// is enabled, than + /// + /// property will be set instead of default layout + /// . + /// /// the new leading value /// this Paragraph /// + /// public virtual iText.Layout.Element.Paragraph SetFixedLeading(float leading) { - SetProperty(Property.LEADING, new Leading(Leading.FIXED, leading)); + if (RenderingMode.HTML_MODE.Equals(this.GetProperty(Property.RENDERING_MODE))) { + SetProperty(Property.LINE_HEIGHT, LineHeight.CreateFixedValue(leading)); + } + else { + SetProperty(Property.LEADING, new Leading(Leading.FIXED, leading)); + } return this; } @@ -297,11 +315,29 @@ public virtual iText.Layout.Element.Paragraph SetFixedLeading(float leading) { /// /// strategy. /// + /// + /// Sets the leading value, using the + /// + /// strategy. + /// + /// If for the element + /// + /// is enabled, than + /// + /// property will be set instead of default layout + /// . + /// /// the new leading value /// this Paragraph /// + /// public virtual iText.Layout.Element.Paragraph SetMultipliedLeading(float leading) { - SetProperty(Property.LEADING, new Leading(Leading.MULTIPLIED, leading)); + if (RenderingMode.HTML_MODE.Equals(this.GetProperty(Property.RENDERING_MODE))) { + SetProperty(Property.LINE_HEIGHT, LineHeight.CreateMultipliedValue(leading)); + } + else { + SetProperty(Property.LEADING, new Leading(Leading.MULTIPLIED, leading)); + } return this; } diff --git a/port-hash b/port-hash index cc97c5fa1..6cdb38aca 100644 --- a/port-hash +++ b/port-hash @@ -1 +1 @@ -a37f11613bdb93aa13ff0f3a95e362d5bfb29e66 +538e56033260bba62141e3be28b2aec1a482ba49