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

Free Support Forum - aspose.com

Saving a PDF file into HTML format with images turning gray


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;

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

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

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

String outHtmlFile = “SomeUnexistingFile.html”;
pageDoc.save(outHtmlFile, htmlSaveOps);
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”);<o:p></o:p>

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,


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.


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