I have a problem, I want to convert a document to pdf but I get the following error: Invalid image file type: ashx?id=RgAAAAD7rzqLiGbbQIa7mRBBn1nmBwA%2fBsH51w6dRKYjV4TXlE47AAAAAIjAAAA%2fBsH51w6dRKYjV4TXlE47AAf9WgxmAAAJ&attcnt=1&attid0=EACUWC4FuC0MT48fqF8k7xbr
This is (part of) my code:
// New a Doc object.
Document doc = new Document(OriginalDocument);
// Save the doc in a xml fille that can be handled by Aspose.Pdf.
doc.Save(tempfile, Aspose.Words.SaveFormat.AsposePdf);
// New a pdf object.
Aspose.Pdf.Pdf pdfResult = new Aspose.Pdf.Pdf();
Aspose.Pdf.License license = new Aspose.Pdf.License();
FileStream stream = new FileStream(SPUtility.GetGenericSetupPath("Template\\LAYOUTS\\ShareOne") + "\\Aspose.Pdf.lic", FileMode.Open);
license.SetLicense(stream);
stream.Close();
// Bind content from the named xml file.
pdfResult.BindXML(tempfile, null);
At this point the error comes up.
Can you help me please?
PS I have added the corresponding document
Hi
Thanks for your inquiry. As I can see, you are using old legacy method of PDF conversion (using Aspose.Words+Aspose.Pdf). Currently this old method of PDF conversion is excluded from Aspose.Words. You should use direct-to-PDF method. Please see the following link for more information: https://docs.aspose.com/words/net/convert-a-document-to-pdf/
You can download the latest version of Aspose.Words from here: https://releases.aspose.com/words/net
Best regards,
Thank you, but we bought Aspose.Pdf. So my question is what is the use of that if you can do it with Aspose.Words also (Which we have also)?
And another question, The documents are converted to PDF the font is nof converted. This only happens when I use a document with A font that is not on my machine:
I attached an example document.
Thank you for additional information.
The old version of Aspose.Words was no direct conversion to pdf format. To save to the pdf AW generated intermediate xml document, which passed to the Aspose.Pdf. Now it is not necessary, you can easily convert documents into pdf with the aid of Aspose.Words.
Regarding your second question.
Please describe the problem in more details, and attach the original document you are trying to convert. I also try to reproduce the problem on my side.
I attached the document in my previous post.
When I convert this document the font, which is not installed on my computer, is not in the pdf file. The pdf file has now a standard font (I think Times New Roman).
So my question is, is there a way to convert the document including the font, even though the font is not installed on my computer.
Hi
Thanks for your request. Yes, you are right, To convert document to PDF fonts used in the document should be installed. If font is installed Aspose.Words reads it, creates a font subset and embeds it into the final PDF file.
If the font used in the source document is not installed, Aspose.Words uses an alternative fonts instead. That is why if font is not installed you can see a different font in the final PDF.
Best regards,
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.