Convert HTML to PDF using C# and Aspose.PDF - Incompatible unit types

I am converting web page html file using Aspose.PDF. I am getting the error message “Incompatible unit types”.

var option = new HtmlLoadOptions() {};
var document = new Document(sourceFilename, new HtmlLoadOptions());
document.Save(targetFilename);

Aspose.PDF works fine on other html file but not on this file. I have attached the sample file.

Thanks[LD-7515] Cannot PDF HTML files - JIRA.zip (91.2 KB)

1 Like

@rainierpaul

We were able to reproduce the issue in our environment while testing the scenario with Aspose.PDF for .NET 20.10. Hence, have logged it as PDFNET-48966 in our issue management system. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

We’re seeing this same issue with Aspose Total 21.6. Is this still being worked or has it been fixed in a later version?

@amcalpine.gdit

You are seeing this issue because it has not been yet resolved. Please note that it is currently under the phase of investigation and as soon as it is fixed, we will update you in this forum thread. Please spare us some time.

We apologize for the inconvenience.

The issues you have found earlier (filed as PDFNET-48966) have been fixed in Aspose.PDF for .NET 21.10.

I’m getting the exact same error “Incompatible unit types” with the attached html file using Aspose.Pdf v22.1 using the exact same code listed above:

var option = new HtmlLoadOptions() {};
var document = new Document(sourceFilename, new HtmlLoadOptions());
document.Save(targetFilename);

Can you please reopen this issue.

ce4cc45e-b123-4902-bd80-87e8ec019950.zip (4.4 KB)

@ted-1

We tested the case using 22.3 version of the API and did not notice any exception. For your kind reference, an output PDF is also attached. Please use the latest version of the API and let us know in case you still notice any issue.
output.pdf (933.3 KB)

Yep, I confirmed this is working again in version 22.3. Unfortunately, we cannot use that version until this fix is in: Can't install Aspose.PDF v22.2 & v22.3 using NuGet for .NET Standard - #11 by tahir.manzoor

Question: Why do bugs like this reappear on newer versions after they have been fixed?

@ted-1

Aspose.PDF API has many internal components that depends upon each other. Sometimes, changes to one component can effect on dependent one. During resolving issues and implementing new features/enhancements, possibility of regression is there. If some regression is noticed, we fix it in the very next version.

Thank you, Asad!

1 Like

Hi,

I am facing same error in ASPOSE.PDF 23.1.0 and also in 23.1.1 version. Need to use this version as application is running on Linux OS.

can you please help here.

@hiteshdutt

Would you please try using Aspose.PDF.Drawing after uninstalling the Aspose.PDF? You can install it using NuGet Package Manager. It is released as beta version to work in Linux like application. Once we are sure that it is working fine in non-Windows environments, we will make it a permanent module in Aspose.PDF.

my bad, i am using Aspose.PDF.Drawing. I have tried both version 23.1.0 as well as 23.1.1.

@hiteshdutt

Can you please share your sample files along with sample code snippet so that we can further proceed yo assist you accordingly?

Hi @asad.ali,

I will provide some more information, I might not be able to provide code or even the output as it has proprietary information in it.

Application was previously using Aspose.PDF 19.XX version. the html templates were working fine. but after upgrading to Aspose.PDF.Drawing 23.1.0/23.1.1 we are getting Incompatible unit type.

we have narrowed down to item that is causing issue. using display:flex in css or inline style, we have issue. if this is removed, error is gone, but it impacts the formatting.

Surprisingly the HTML loads with no issues in Edge and Chrome browser.

Q: Is there any changes that we should be considering while making such update 19.XX -> 23.1.0? having html/css to adapt to some interpreter or complier(if any) changes?

@hiteshdutt

There is no such certain change that you may require to do in the HTML. However, please take your time to gather some details which can help us in proceeding the investigation further. We will open a ticket and share the ID with you.

@asad.ali,

I replaced display:flex from styling (css and inline).
This is working for now, so from my understanding aspose.PDF.Drawing is not processing display:flex correctly.

My issue is fixed, posting this, as this might help someone else and just for aspose team to identify are there any other items which are not acceptable by latest version of aspose.PDF (Drawing & normal)

@hiteshdutt

It is nice to hear that your issue has been sorted out. Please note that you can still share sample HTML with us so that we can try to investigate the issue and apply its fix in future versions of the API.