I put a published example of a WORD to PDF doc code snippet in a button click event to test it. It does not work. The error message is included as comments. Also the example produces a warning message...
Could you please take a look at what is published is correct or requires updating. If not, do you have an example that simply takes an existing Word document and converts it to a PDF format.
.... using Aspose.PDF; using Aspose.Word; ..... private void Button1_Click(object sender, System.EventArgs e)
{
Word word = new Word(); Document doc = word.Open(@"C:\Temp\WordOutput.doc"); //<-- warning message states that this is obsolete doc.Save("C:/temp/WordOutput.xml",SaveFormat.FormatAsposePdf);
Pdf pdf = new Pdf(); pdf.BindXML("C:/temp/WordOutput.xml",null); pdf.Save("C:/temp/WordOutput.pdf");
//Produces the following error... // C:\Temp\WordOutput.doc already exists //Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. // //Exception Details: System.Exception: C:\Temp\WordOutput.doc already exists // //Source Error: // // //Line 54: { //Line 55: Word word = new Word(); //Line 56: Document doc = word.Open(@"C:\Temp\WordOutput.doc"); //Line 57: doc.Save("C:/temp/WordOutput.xml",SaveFormat.FormatAsposePdf); //Line 58: Pdf pdf = new Pdf(); //
Document doc = word.Open(fileName) still works, it is marked as obsolete (it also says what to do instead) because you can do just this:
Document doc = new Document(fileName);
The error message is strange indeed, but I think it is caused by the fact that your WordOutput.doc file is not a DOC binary file, but an RTF file probably.
By the way, where did you see this example? I think we’ve updated all the examples to show the use of new Document ctor.