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

Free Support Forum - aspose.com

PDF to HTML Conversion throwing error

Hi,

I’ve downloaded the .Net samples I was able to build PDF to HTML sample. But when I run it it throws an exception :

“An unhandled exception of type ‘System.InvalidCastException’ occurred in Aspose.Pdf.dll
Additional information: Unable to cast object of type ‘System.Byte[]’ to type ‘System.String’.“

below is the code in Program.cs. The pdfDocument.Save works without the SaveFormat parameter. But anytime I specify SaveFormat e.g Html or Doc etc it throws the same error.

// The path to the documents directory.
string dataDir = Path.GetFullPath(”…/…/…/Data/”);

//open the source PDF document
Document pdfDocument = new Document(dataDir + “input.pdf”);

// save the file into MS document format
pdfDocument.Save(dataDir + “output.html”, SaveFormat.Html);

Hi Wasif,


Thanks for your inquiry. Please share your source PDF file here, we will test the scenario and will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,


Its the PDF file that comes with the .NET demo solution “input.pdf” I’ve attached it.

Hi Wasif,


Thank you for sharing source document. I am afraid I am unable to replicate the issue while testing with Aspose.Pdf for .NET 9.6.0. Please download and try latest version of Aspose.Pdf for .NET, it will help.

We are sorry for the inconvenience caused.

Best Regards,