Mixed content in final PDF when using HTML to PDF

@jrb-ngs,
Old thread: ("[[BL]]https://forum.aspose.com/t/mixed-content-in-final-pdf-when-using-html-pdf/118137/1[[/BL]]


This Topic is created by imran.rafique using the Email to Topic plugin.

Hi Imran,

Sorry for the delayed response. Unfortunately, there was a typo in my email address when I signed up for the forums and my password does not work, so I have been unable to log back in to continue our conversation. I had to create a new account to be able to reply so I am unable to make this chat private. Are you able to help me recover the account or help me make this chat private somehow?

However, our web-forms based website is a large code-base (hundreds of megs in size without including shared DLLs), so it would be very difficult to share that. The code that I posted in the original thread was from 2 pages/areas of our website. The only thing I changes was class / function names and excluded the content that generates the HTML. For example, if you see the following

"reportHTML.Clear();

//add html to section"

then you could replace “//add html to section” with code that writes the html to the variable (based on values from a database).

For example (had to remove open tag (less than sign) as this editor was removing my content):

reportHTML.Append("!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'+'[http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd](http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)'");
reportHTML.Append("html xmlns='[http://www.w3.org/1999/xhtml](http://www.w3.org/1999/xhtml)'><head><title></title");
reportHTML.Append("/head><body");

As far as reproducing the issue, we run hundreds, if not thousands of these reports per day, and it happens very rarely (we get a report from our customers once every few days), so it is not something that can be reproduced on demand. The only common thing between the two reports/pages is the fact that they are using the PDF class. I was wondering if something was not thread-safe and if the right conditions were hit, 2 threads could end up incorrectly flushing their data to the same temporary location and causing the mixed content?

I know that you mentioned we are using an old mechanism to create our pdf documents. Do you think that re-writing the code to use the DOM approach would alleviate this problem? Thank you for your continued support. If there is anything I can do to help provide more info, please let me know. We are in serious need of fixing this issue.

Please note that it is quite difficult to investigate and fix an issue without replicating in our environment. We would suggest you please track the problematic use case, create a small application project, which reproduces this problem in your environment, and share its Zip file with us. It may be a bug in the old version of Aspose.Pdf for .NET API and do not provide fixes in the old code base.

Kindly let us know which Aspose.Pdf for .NET API version you are using, we will try to convert your code in the new DOM approach with the same old version.

Do you think that re-writing the code to use the DOM approach would alleviate this problem?

Yes, we think so because it is the latest way of manipulating the PDF documents. You can get a 30 day temporary license from the purchase portal. In this way, you can evaluate the latest version 17.7 of Aspose.Pdf for .NET API in your environment.

We have marked the old thread as private. The old thread with your incorrect email will only be accessible by the Aspose staff (if the email id is invalid).

Best Regards,

Imran Rafique