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

Free Support Forum - aspose.com

Convert PDF to HTML using memory stream

Hey guys, very simply put I’m trying to use your software to convert a pdf to html using memory stream. I’m well aware of how to use the save method to save to file, what’s confusing to me is I can do this using the Aspose.Words but not Aspose.Pdf. Here’s what I’ve got:

Document pdfDocument = new Document(file.InputStream); // file comes from an upload control

MemoryStream ms = new MemoryStream();

pdfDocument.Save(ms, SaveFormat.Html);

sr = new StreamReader(ms);

Label1.Text = sr.ReadToEnd();

As you can see I’m looking to display the converted HTML pretty immediately. Let me know if this approach is flawed or if there’s some work around I could use. As stated I’m doing the same thing with word docs and its working out just fine.

Thanks.





This message was posted using Page2Forum from Document.Save Method (Stream, SaveFormat) - Aspose.Pdf for .NET

Hi Faraji,

Thank you for considering Aspose.Pdf.

I am very sorry to share with you that conversion from Streams to HTML format feature is not supported at the moment using Aspose.Pdf. You can achieve this functionality to convert the stream into PDF format and then PDF to HTML conversion is possible using below code.

[C#]

Aspose.Pdf.Document document = new Aspose.Pdf.Document(@"d:\pdffiles\adobe.pdf");
// Save to the html
document.Save(@"d:\pdffiles\myFile.html", SaveFormat.Html);
// or
document.Save(@"d:\pdffiles\myFile.html", new HtmlSaveOptions());

We apologize for the inconvenience. Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

Yea that’s what the error was saying, that saving to a memory stream isn’t supported. I’ll just have to work with the actual file.

Follow up question - when the actual html document is created the CSS styling gets placed in a separate folder. As stated above I’m looking to display this markup immediately. How do I have the document either export the CSS file or reference it in the right directory?

What’s the most confusing is that I’m saving a Word doc the exact same way but yet the CSS styling is inline vs a stylesheet being placed in a separate folder. I’m going for the same effect.