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

Free Support Forum - aspose.com

Html to Pdf - need to preserve whitespace and word-wrap appropriately

Trying to have a section in my HTML that preserves existing whitespace (particularly carriage returns) but also maintains appropriate width via normal word-wrap. Found that CSS class below seems to work fine in both Chrome and IE10, but when rendered through Aspose, the white-space setting gets ignored, so words and paragraphs are collapsed. Any workaround that doesn’t involve changing the content of the tag? Full sample HTML attached.


.pre {
word-break: break-all; /* webkit */
word-wrap: normal;
white-space: pre-wrap;
}



Hi Andrew,


Thanks for contacting support.

I have tested the scenario using latest release of Aspose.Pdf for .NET 10.2.0 and I am unable to notice any issue. For your reference, I have also attached the resultant file generated over my end.

[C#]

//
load HTML and render output as PDF
<o:p></o:p>

Aspose.Pdf.Document doc = new Aspose.Pdf.Document("c:/pdftest/AsposeTest8-whitespace.html", new HtmlLoadOptions());

// save resultant document

doc.Save(“c:/pdftest/AsposeTest8-whitespace.pdf”);

Look a little harder at the Html. The document renders, true, but note that none of the extra whitespace in the second section (spaces and newlines) are present in the PDF. I’ve attached another HTML with a more obvious paragraph. Change the extension to HTML and open in a browser to see the difference with the PDF.

Hi Andrew,

Thanks for sharing additional information. I have tested your scenario with the shared HTML using Aspose.Pdf for .NET 10.2.0 and managed to observe the reported issue. For further investigation, I have logged an issue in our issue tracking system as PDFNEWNET-38352 and also linked your request to it. We will keep you update via this thread regarding the issue status.

Please feel free to contact us for any further assistance.

Best Regards

The issues you have found earlier (filed as PDFNEWNET-38352) have been fixed in Aspose.Pdf for .NET 10.6.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hello,



I’ve also had this issue and have been waiting for the fix. We’ve downloaded the latest updates and see some things have been fixed but the word-wrap issue has not. I have a class:

.paragraphWrap{

white-space: pre-wrap !important;

}

that I am applying to a label…when the html is generated in a browser, the white space is visible. When I generate the HTML in PDF, the whitespace is not preserved. Please advice.



Thank you.

areynolds:
Hello,

I’ve also had this issue and have been waiting for the fix. We’ve downloaded the latest updates and see some things have been fixed but the word-wrap issue has not. I have a class:
.paragraphWrap{
white-space: pre-wrap !important;
}
that I am applying to a label…when the html is generated in a browser, the white space is visible. When I generate the HTML in PDF, the whitespace is not preserved. Please advice.

Thank you.

Hi Andrew,

Thanks for using our API’s.

Can you please share the sample HTML file which you are using, so that we can test the conversion in our environment. We are sorry for this inconvenience.

Hi,



I’ve attached a zip file containing the HTML and CSS samples. Thank you in advance.

Hi Andrew,


Thanks for sharing sample HTML. We have tested the scenario and managed to notice the reported word-wrap issue. So we have logged a ticket PDFNEWNET-39120 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

We are sorry for the inconvenience caused.

Best Regards,

We just received the latest version of Aspose and see that the issue has no bee resolved. Would you please provide update on the wrapping issue. I haven’t been able to find any information on the new ticket you opened.

Thank You.

Hi Andrew,


Thanks for your patience.

I am afraid the recently reported PDFNEWNET-39120 is still pending for review and is not yet resolved. However as soon as we have some definite updates regarding its resolution, we will let you know.