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

Free Support Forum - aspose.com

Save HTML with inline css

Hi guys!

Is there any possibility to save document to HTML format with inline style for elements (without css classes, files, etc.)

Best regards,


Thanks for your inquiry.

As per our understandings, you want to generate single HTML file from PDF document. In order to achieve that please use following code snippet:

Document doc = new Document(dataDir + "3820-UG Rev E.pdf");
HtmlSaveOptions newOptions = new HtmlSaveOptions();
// this is usage of tested feature
newOptions.PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml;
// this is just optimozation for IE and can be omitted
newOptions.LettersPositioningMethod = HtmlSaveOptions.LettersPositioningMethods.UseEmUnitsAndCompensationOfRoundingErrorsInCss;
newOptions.RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground;
newOptions.FontSavingMode = HtmlSaveOptions.FontSavingModes.SaveInAllFormats;
newOptions.RemoveEmptyAreasOnTopAndBottom = true;
string outHtmlFile = dataDir + @"output.html";
doc.Save(outHtmlFile, newOptions); 

In case you face any issue or your requirements are different than our understandings, please feel free to let us know.

We used this and we are able to generate html. but the html style elements are not getting applied properly. for example, a table has only ‘<?div>’ tags and not <?‘tr><?td>’. which options should we change to make it happen?


Could you please share your sample PDF with us so that we can test the scenario in our environment and address it accordingly.

1 Like