usingSystem.IO;usingSystem.Text;usingaspose.pdf;namespacesystem.extensions{ Public Static classPdfconverter { Public Static stringRead (Stream stream,stringFullPath) { if(Directory.Exists (FullPath)) {Directory.delete (FullPath,true); } directory.createdirectory (FullPath); Try { varDoc =NewDocument (stream); varSaveOptions =Newhtmlsaveoptions () {fixedlayout=true, Splitintopages=false, Splitcssintopages=false, Rasterimagessavingmode=HtmlSaveOptions.RasterImagesSavingModes.AsEmbeddedPartsOfPngPageBackground, Specialfolderforallima GES=FullPath}; varPath = Path.Combine (FullPath,"i.html"); Doc. Save (path, saveoptions); stringhtml; using(varFileStream =NewFileStream (Path, FileMode.Open, FileAccess.Read, Fileshare.readwrite)) { varReader =NewStreamReader (FileStream, Encoding.UTF8); HTML=Reader. ReadToEnd (); Reader. Close (); } file.delete (path); returnhtml; } Catch(Exception e) {Console.WriteLine (e); Throw; } } }}
Aspose.pdf Pdf to HTML, and set save path, picture path