Skip to content

Commit cdbc3db

Browse files
vitali.prudnikovichiText-CI
authored andcommitted
Apply object tag height and width during conversion
Autoported commit. Original commit hash: [90e9e37ac]
1 parent 0ff18b6 commit cdbc3db

File tree

6 files changed

+49
-3
lines changed

6 files changed

+49
-3
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using iText.Html2pdf;
3+
4+
namespace iText.Html2pdf.Css.Resolve {
5+
[NUnit.Framework.Category("Integration test")]
6+
public class HtmlStylesToCssConverterIntegrationTest : ExtendedHtmlConversionITextTest {
7+
public static readonly String SOURCE_FOLDER = iText.Test.TestUtil.GetParentProjectDirectory(NUnit.Framework.TestContext
8+
.CurrentContext.TestDirectory) + "/resources/itext/html2pdf/css" + "/HtmlStylesToCssConverterIntegrationTest/";
9+
10+
public static readonly String DESTINATION_FOLDER = NUnit.Framework.TestContext.CurrentContext.TestDirectory
11+
+ "/test/itext/html2pdf/css" + "/HtmlStylesToCssConverterIntegrationTest/";
12+
13+
[NUnit.Framework.OneTimeSetUp]
14+
public static void BeforeClass() {
15+
CreateOrClearDestinationFolder(DESTINATION_FOLDER);
16+
}
17+
18+
[NUnit.Framework.Test]
19+
public virtual void ObjectTagWidthAndHeightTest() {
20+
ConvertToPdfAndCompare("objectTagWidthAndHeightTest", SOURCE_FOLDER, DESTINATION_FOLDER);
21+
}
22+
}
23+
}
Lines changed: 10 additions & 0 deletions
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE HTML>
2+
<html>
3+
<body>
4+
<p>External SVG image</p>
5+
<img lang="fr" src="external.svg" alt="extérieur svg image" width="400" height="180"/>
6+
7+
<p>
8+
<object type="image/svg+xml" data="external.svg" lang="ru" width="400" height="180"></object>
9+
</p>
10+
</body>
11+
</html>

itext/itext.html2pdf/itext/html2pdf/css/resolve/HtmlStylesToCssConverter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@ private class WidthAttributeConverter : HtmlStylesToCssConverter.IAttributeConve
478478
public virtual bool IsSupportedForElement(String elementName) {
479479
return TagConstants.HR.Equals(elementName) || TagConstants.IMG.Equals(elementName) || TagConstants.TABLE.Equals
480480
(elementName) || TagConstants.TD.Equals(elementName) || TagConstants.TH.Equals(elementName) || TagConstants
481-
.COLGROUP.Equals(elementName) || TagConstants.COL.Equals(elementName);
481+
.COLGROUP.Equals(elementName) || TagConstants.COL.Equals(elementName) || TagConstants.OBJECT.Equals(elementName
482+
);
482483
}
483484

484485
/* (non-Javadoc)
@@ -504,7 +505,8 @@ private class HeightAttributeConverter : HtmlStylesToCssConverter.IAttributeConv
504505
* @see com.itextpdf.html2pdf.css.resolve.HtmlStylesToCssConverter.IAttributeConverter#isSupportedForElement(java.lang.String)
505506
*/
506507
public virtual bool IsSupportedForElement(String elementName) {
507-
return TagConstants.IMG.Equals(elementName) || TagConstants.TD.Equals(elementName);
508+
return TagConstants.IMG.Equals(elementName) || TagConstants.TD.Equals(elementName) || TagConstants.OBJECT.
509+
Equals(elementName);
508510
}
509511

510512
/* (non-Javadoc)

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ab7a8863cd8565ef062705686e241e6505c211d3
1+
90e9e37ac75e0238781460fd39807e4f1ac46cf8

0 commit comments

Comments
 (0)