Skip to content

Commit 5154fbc

Browse files
ars18wrwiText-CI
authored andcommitted
Do not reset the alignment for RTL elements if it's present.
DEVSIX-2806 Autoported commit. Original commit hash: [65e93d89]
1 parent 7b53a50 commit 5154fbc

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

itext.tests/itext.html2pdf.tests/itext/html2pdf/element/ParagraphTest.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,5 +261,16 @@ public virtual void ParagraphWithImageTest01() {
261261
, sourceFolder + "cmp_paragraphWithImageTest01.pdf", destinationFolder, "diff_paragraphWithImageTest01_"
262262
));
263263
}
264+
265+
/// <exception cref="System.IO.IOException"/>
266+
/// <exception cref="System.Exception"/>
267+
[NUnit.Framework.Test]
268+
public virtual void ParagraphWithImageTest01RTL() {
269+
HtmlConverter.ConvertToPdf(new FileInfo(sourceFolder + "paragraphWithImageTest01RTL.html"), new FileInfo(destinationFolder
270+
+ "paragraphWithImageTest01RTL.pdf"));
271+
NUnit.Framework.Assert.IsNull(new CompareTool().CompareByContent(destinationFolder + "paragraphWithImageTest01RTL.pdf"
272+
, sourceFolder + "cmp_paragraphWithImageTest01RTL.pdf", destinationFolder, "diff_paragraphWithImageTest01_"
273+
));
274+
}
264275
}
265276
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<body dir="rtl">
2+
<p><img
3+
style='display: block; margin-left: auto; margin-right: auto;' title='placeholder-170x70.jpg'
4+
src='image.png' width='170'
5+
height='70'/></p>
6+
</body>

itext/itext.html2pdf/itext/html2pdf/css/apply/util/FontStyleApplierUtil.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public static void ApplyFontStyles(IDictionary<String, String> cssProps, Process
121121
}
122122
if (stylesContainer is IElementNode && ((IElementNode)stylesContainer).ParentNode() is IElementNode && CssConstants
123123
.RTL.Equals(((IElementNode)((IElementNode)stylesContainer).ParentNode()).GetStyles().Get(CssConstants.
124-
DIRECTION))) {
124+
DIRECTION)) && !element.HasProperty(Property.HORIZONTAL_ALIGNMENT)) {
125125
// We should only apply horizontal alignment if parent has dir attribute or direction property
126126
element.SetProperty(Property.HORIZONTAL_ALIGNMENT, HorizontalAlignment.RIGHT);
127127
}

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
55c40116085862a958782d9d94e070c88e27f2f6
1+
65e93d8901d6c0d24ee8f9992d1a71ceaf706946

0 commit comments

Comments
 (0)