Hi,
We are using Aspose.Words for .NET for converting images (.jpg and .png) and word documents (.doc and .docx) to pdf.
The files are successfully converted to pdf, but upon opening and closing the converted files from .doc and .docx, Adobe Reader prompts to save the file. We also use a third party tool to check the converted pdf’s and upon checking, the error “Can’t find startxref” is returned.
Any help regarding this is highly appreciated.
Thanks.
Hi Mike,
Thanks for your inquiry.
Please note that Aspose.Words mimics the same behavior as MS Word do. If you convert your document to Pdf file by using MS Word, you will get the same output.
It would be great if you please share your input documents along with code here for testing. I will investigate the issue on my side and provide you more information.
We are using a simple test file, a .docx file containing a single word “test” as input document. The file is attached for your reference.
As for the code, please refer to the code snippet below:
private void ConvertWordDocument(bool withFilestamp, string filestamp, out MemoryStream stream)
{
Aspose.Words.License docLicense = new Aspose.Words.License();
docLicense.SetLicense(_license);
Aspose.Words.Document document = new Aspose.Words.Document(_sourceFile);
stream = new MemoryStream();
if (!string.IsNullOrEmpty(_targetFile))
document.Save(_targetFile);
else
document.Save(stream, Aspose.Words.SaveFormat.Pdf);
}
As you can see, it’s just a direct approach where in the document (_sourceFile) is opened using Aspose.Words, then saved either through a memory stream or a target file using document.Save though most of the time, the memory stream is used.
By the way, the version of Aspose.Words which we are using is 13.8.0.0.
Thanks and regards.
Hi Mike,
Thanks for sharing the detail.
I have tested the scenario and have not found any issue with output Pdf file. Adobe Reader does not prompt any issue/message at my side. I am using Adobe Acrobat Pro XI. I have attached the output Pdf file with this post for your kind reference. Please check this issue at different machine and share your finding with us. You can test this scenario by using MS Word. Please convert your document to Pdf by using MS Word and test the same scenario. You will get the same output.
Hi All,
One thing while going through the issue…I was also facing same issue while converting .docx to pdf.
What I identified that “document” class is also present in “Aspose.pdf”. I know it is a silly mistake which I made,but recommend you guys to check that you need to use “Aspose.Word.document” instead of “Aspose.Pdf.document”. That solved my problem.I hope it helps someone facing same issue.
Thanks,
Gaurav
Hi Gaurav,
Thanks for sharing the detail. We always appreciate positive feedback from our customers.
Yes, Document class exists in Aspose.Words and Aspose.Pdf APIs. If you are using both components in your application, please use Aspose.Words.Document and Aspose.Pdf.Document for Document class.
Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.