Saving a PDF file into HTML format with images turning gray

Hi


I use Aspose PDF 17.5 to save a PDF file into HTML format.
I found that some of images turned gray instead origin color in the result
Please check this issue, and the attachment.

P.S. my testing code:
public void asposeConvert() throws Exception {

String fileName = “testPDF2.pdf”;

Document pdf = new Document(“input/”+fileName);

HtmlSaveOptions htmlSaveOps = new HtmlSaveOptions();
htmlSaveOps.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
htmlSaveOps.FontSavingMode = HtmlSaveOptions.FontSavingModes.AlwaysSaveAsWOFF;
htmlSaveOps.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;
htmlSaveOps.LettersPositioningMethod = LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
htmlSaveOps.setSplitIntoPages(false);

File f = new File(fileName + “/”);
f.mkdirs();

for (int p = 1; p <= pdf.getPages().size(); p++) {
Document pageDoc = new Document();
pageDoc.getPages().add(pdf.getPages().get_Item§);

final ByteArrayOutputStream stream = new ByteArrayOutputStream();
htmlSaveOps.CustomHtmlSavingStrategy = new HtmlSaveOptions.HtmlPageMarkupSavingStrategy() {
@Override
public void invoke(com.aspose.pdf.HtmlSaveOptions.HtmlPageMarkupSavingInfo htmlSavingInfo) {
try {
byte[] resultHtmlAsBytes = IOUtils.toByteArray(htmlSavingInfo.ContentStream);
htmlSavingInfo.ContentStream.read(resultHtmlAsBytes, 0, resultHtmlAsBytes.length);
stream.write(resultHtmlAsBytes);
stream.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
} finally {
IOUtils.closeQuietly(htmlSavingInfo.ContentStream);
}
}
};

String outHtmlFile = “SomeUnexistingFile.html”;
pageDoc.save(outHtmlFile, htmlSaveOps);
IOUtils.write(stream.toByteArray(),
new FileOutputStream(fileName + “/” + p + “.html”));
}
}

Hello Cheng,

Thanks for contacting support.

I have tried to run your code with Aspose.Pdf for .NET 17.6, as it is recommended to use latest version, and I was unable to execute it. It seemed that there was some JAVA code mixed in the code snippet. However, I have converted your PDF file into HTML with same HtmlSaveOptions settings and was unable to notice the issue which you have mentioned.

Please check the following code snippet which I have used to convert PDF into HTML. For your reference, I have also attached an output file, generated by below code snippet.

Document pdfDocument = new Document(dataDir + @“testPDF2.pdf”);

string outHtmlFile = dataDir + @"testPDF2.html";

HtmlSaveOptions saveOptions = new HtmlSaveOptions();

saveOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;

saveOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.AlwaysSaveAsWOFF;

saveOptions.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;

saveOptions.LettersPositioningMethod = HtmlSaveOptions.LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;

saveOptions.SplitIntoPages = (false);

pdfDocument.Save(outHtmlFile, saveOptions);

Please try using above approach for conversion process, and in case if you still face any issue, please feel free to let us know.

Best Regards,

Hi Asad.Ali

Sorry about using the wrong tag, it should be JAVA, and I corrected it.
However 17.6 for JAVA seems be not yet released.

Hello Cheng,


Thanks for writing back.

I have tested the scenario again with Aspose.Pdf for Java 17.5 and observed that after conversion process, image colors were lost in the resultant file. Hence, I have logged an issue as PDFJAVA-36826 in our issue tracking system, for the sake of investigation. We will further look into this and keep you updated on the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.


Best Regards,

@ChengHuang,

Thanks for your patience.

We are pleased to share that the issue reported earlier as PDFJAVA-36826, is resolved in latest release of Aspose.Pdf for Java 17.7. Please try using the latest release version and in case you encounter any issue or you have any further query, please feel free to contact.

Hi
@codewarior

I tried this release.
This issue seems to fixed.
Thank you