Hello, I’m getting crasy with Aspose.Words 6.0.1 for .NET. I have read almost all topic I could find on this forum but unfortunatly It was not of any help
Here is my problem: I am using Aspose.words on windows server 2008, ASP.NET 3.5. to create a PDF file from a .doc or .docx file to a predefined directory. That directory has all privileges. On my local computer, everything is working fine, but not on the final hosting environment ( also windows server 2008, ASP.NET 3.5, full trust configuration)
Result :
it does not work. I Get the infamous “System.Security.SecurityException: Request for the permission of type ‘System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed.”
A file is created into the directory, but it is just an empty one: Lenght = 0.
This error occurs when calling the "doc.Save(…) method.
BUT ! … When I change the SaveFormat parameter to SaveFormat.Rtf, it works fine. I mean a RTF file is successfuly writen to the directory and no errors at all are fired.
Strange, is n’t it ?
Hope somebody could help me with some advise because I really do not know what to do. Thanks a lot for your assistance.
You don’t need to specify ExportImagesFolder when you use SaveFormat.Pdf or SaveToPdf method. This option is needed when you use Aspose.Words+Aspose.Pdf to convert Word documents to PDF (SaveFormat.AsposePdf is used.). In your case you can use code like the following:
Document doc = new Document("in.doc");
doc.Save("out.pdf", SaveFormat.Pdf);
Have you tried to save the document into the MemoryStream? Does this work on server environment?
Also, you can try saving your document in the root folder of your application (just for testing)
I did not tryed to save the document to the Memory Stream. I am going to try.
Saving to the Server.MapPath will attempt to write in an unauthorized folder. So let me set the rights and have a try also.
Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side. I tested this on WinXP and on Win2003 and PDF document is generated without any issues. I hope you have some progress. Please let me know if you have any additional information.
as I cannot access any useful advanced tool on the server side, I made some investigation on my local computer.
it seems there is a main difference between saving with SaveFormat.Pdf and SaveFormat.Rtf option:
Saving with option SaveFormat.Rtf:
Aspose.word assembly does not scan disks for font files.
Saving with option SaveFormat.Pdf:
Aspose.word assembly scan disks for all registered font files and read them all, even if the file to be converted does not include any fonts.
So I suppose this can be the reason why I get that “ugly” permission error. The web hosting service I am currently using may not allow such scanning process on folder like /windows/fonts or others. But I cannot confirm it, as the administration consol provided by the web hosting service is rather “poor”…
If anyone as an opinion, it will be much appreciated
Thank you for additional information. Yes, you are right, Aspose.Word needs fonts to convert document to PDF. It reads installed fonts from registry. You can ask your hosting to allow you to read fonts.
I also created new issue #7283 in our defect database. We will further investigate the problem.
Unfortunatly, I fear that asking the web hosting service to do so will result in something like “shouting in the ear of a deaf”
They are not cooperative at all… But anyway, I will try.
It’s a pity, because Aspose.word is really a great tool : powerful, very easy to use, very easy to install, no need of registration process at server side, an so on… A nice piece of work.
Thanks again for your assistance. I really appreciated your reactivity.
As expected, the web hosting refuse to change anything related with files permissions. In addition of that, I have been informed that I dont have acces to the registry, and that I will never have.
All this because I am using a “mutualized hosting”…
I think that this kind of limitation can be common to most of mutualized hosting. So the Save() method to PDF format cannot work at all in such environment.
As you already created an issue (7283), I think that the alternative to this problem could be to implement a new option to force Aspose.word to get fonts from a given folder. Of course, that folder may be quite large (350Mo, may be more) but space is less a problem than permissions on hosting. At least, we could use aspose.word to convert documents to PDF format
Yes, that’s what we thought too. We were thinking exactly about adding an option to specify your own directory where to read true type fonts from. Will do asap.
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.