Converting PDF with watermark to HTML hides content

Library used: com.aspose:aspose-pdf:17.1.0

Conversion of PDF file with watermarks on some pages results with HTML consists of:
- pages with no watermark - looks fine
- pages with watermark - have visible only the watermark but when looking into source there are HTML markups with <style="visibility:hidden></div><div><br></div><div>Is this aspose bug?</div><div><br></div><div>Thanks,</div><div>Chris.</div>

Hi Chris,


Thanks for contacting support.

I will appreciate if you please share sample code along with sample input PDF file. It will help us to understand your issue exactly and address it accordingly.


We are sorry for the inconvenience.


Best Regards,

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000; min-height: 14.0px} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000; min-height: 14.0px} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}
Hi again,

Here's code and input file:

Document document = new Document(in);
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
saveOptions.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;
saveOptions.LettersPositioningMethod = LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
File file = tempFiles.newTempFile();
document.save(file.getAbsolutePath(), saveOptions);

Hi Chris,


Thanks for sharing further details.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Arial; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}

I have tested the scenario and have managed to reproduce the problem that conversion from PDF to HTML having watermark hides content. For the sake of correction, I have logged it as PDFJAVA-36626 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time.


As a workaround you can use following simple code snippet


JAVA

Document document = new Document(dataDir + "in.pdf");
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
document.save(dataDir + "output_f.html", saveOptions);
We are sorry for this inconvenience.

Best Regards,

We actually cannot workaround it because we need to produce HTML in single file.


We will wait for a fix patiently.

Thank you.
We will notify you within this forum thread as soon as it is resolved.

Hi Chris,


Please use following code snippet to fix the issue

JAVA

Document document = new Document(dataDir + “in.pdf”);
HtmlSaveOptions saveOptions = new HtmlSaveOptions();
saveOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
saveOptions.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;
saveOptions.LettersPositioningMethod = LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
saveOptions.setUseZOrder(true);
document.save(dataDir + “output_fahad.html”, saveOptions);

If you need further assistance, please feel free to contact us.

Best Regards,