We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Html to PDF: CSS width property

Hi, I’m trying to convert an HTML string to Pdf, and I’m facing the following issue: the CSS width property is apparentely ignored, at least on divs and tables.
I tried using both px values and percent values, but to no avail.

Here some simple examples I tried that work on an HTML page and don’t when converted to PDF (omitting the html and body tags):

<div>
    <div style=display: inline-block; width: 250px;>aa</div>
<div style=display: inline-block; width: 250px;>bb</div>
</div>
<div>
<div style=display: inline-block; width: 33%;>aa</div>
<div style=display: inline-block; width: 33%;>bb</div>
</div>
<div style=width: 100%> 
<div style=display: inline-block; width: 33%;>aa</div>
<div style=display: inline-block; width: 33%;>bb</div>
</div>
As I already said, same goes for tables.
I’m doing something wrong?
Thanks.

Dear leonardo,


Thanks for using our API’s.

I have tested your html string and have managed to generate output file, which looks correct to me. Please check the attached input html file and also the pdf file generated by the Java API. Below is the code snippet for conversion

HtmlLoadOptions htmloptions = new HtmlLoadOptions();
// Load HTML file
Document doc = new Document("/Users/fahadadeel/Downloads/resources/input.html", htmloptions);
// Save HTML file
doc.save("/Users/fahadadeel/Downloads/resources/output.pdf");

If you still face any issue then please share your sample code, so we will test it further.

Best Regards,

Hi,

I’ve got the same problem, i try with the input file attached, but in the output.pdf the margin are not setted.
Which versione did you use for the test?
I use aspose.words for java version 16.8.0.

Thanks.

Hello riccardo,


Thanks for using our API’s.

I used Aspose.Pdf for Java version 16.8.0. If you are facing issue in Aspose.Words for Java, you can log it in Aspose.Words Product Family to assist help. My colleagues in Aspose.Words team will assist you.

Best Regards,

Hello Riccardo,


Thanks for contacting support.

Adding more to Fahad’s comments, It appears that you are trying to perform HTML to PDF conversion using Aspose.Words for Java, so for your convenience, I am moving this thread to respective forum and my fellow workers from respective team will further look into this matter and will reply accordingly.
Hi,

Thanks for your inquiry.

While using the latest version of Aspose.Words i.e. 17.1.0, we managed to reproduce this issue on our end. We have logged this issue in our bug tracking system. The ID of this issue is WORDSNET-14834. Your request has also been linked to the appropriate issue and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,