When using Aspose.PDF for .NET to convert an HTML document to a PDF document we’ve recently encountered the following issue. If the HTML document contains a span tag with a div tag as a child element then we get an “Incompatible unit types” exception from Aspose. We know that technically div tags within span tags are not “valid” HTML, however most web-browsers display these without a problem and hence end users expect to be able to view these documents as testing with a browser is a logical step for an end user.
Are there any plans for addressing this in any upcoming version? I’ve tested this with 24.11.0.
@DocSquad
Could you please provide more details about the specific HTML structure you are using and the exact error message you are encountering?
As I stated in the original post this issue applies to any nested div tags inside a span tag in any HTML page.
@DocSquad
We used below code sample with 24.11 version of the API in our environment and could not replicate the issue that you mentioned.
string html = File.ReadAllText(dataDir + "DivInsideSpan.html");
var byteArray = Encoding.UTF8.GetBytes(html);
using (var inStream = new MemoryStream(byteArray))
{
var options = new HtmlLoadOptions
{
// set Print or Screen mode
HtmlMediaType = HtmlMediaType.Print,
IsEmbedFonts = true,
IsRenderToSinglePage = true,
PageInfo = new PageInfo() { Margin = new MarginInfo(0, 0, 0, 0), Width = PageSize.A4.Height, Height = PageSize.A4.Width }
};
using (var document = new Document(inStream, options))
{
//document.Flatten();
document.Save(dataDir + "DivInsideSpan.pdf");
}
}
DivInsideSpan.zip (77.9 KB)
A very basic HTML has been used where a div
tag was used inside span
tag. Both input and output files are attached for your kind reference. If possible, could you please share your sample HTML in .zip format with us that can be used to replicate the issue?
Here is a sample file which triggers the error. I tested this now with the latest version 24.12.0 and still am able to reproduce the error.
testing.zip (968 Bytes)
I know the above html file has a nested html tag as well but even removing that (see attached) still reproduces the error.
testing.zip (964 Bytes)
@DocSquad
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-58908
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.