Hello, Aspose.Words support suggested I need to contact a Pdf group with the issue described below. We have a process in place, which does the following:
1. Load a Word doc with a text and image in the page footer into Aspose.Words document
2. Do some in-memory manipulations with Aspose.Words without saning to disk
3. Save Aspose.Words doc to Aspose.Pdf.Pdf (in memory, without saving image or doc to disk)
4. Do something with pdf (also in memory, without saving anything to file system)
5. Display the resulting pdf in browser.
This way worked with Aspose.Words 5.1 + Aspose.Pdf 3.6. Now we upgraded to Aspose.Words 7, and Aspose.Pdf 4.1, and the same all-in-memory way doesn't seem to work. Here is a piece of code I'm using, and getting an error "You are in direct-to-file mode,please use Close() instead of Save()."
Can you, please, let me know, how to show in browser a pdf file created in memory out of Aspose.Words doc. Is it possible at all with the latest Aspose.Pdf? If it is - how to change the code below to make it work?
// Doc template has text and image in the footer Document doc = new Aspose.Words.Document("C:\\Temp\\AlertPrintTemplate.doc"); // .... Do something with Aspose.Words doc MemoryStream stream = new MemoryStream(); int pagecount = doc.PageCount; doc.SaveToPdf(0, pagecount, stream, null); stream.Seek(0, SeekOrigin.Begin); pdf = new Aspose.Pdf.Pdf(stream); // ... Do something more with pdf // show pdf in browser pdf.Save("Alert.pdf", Aspose.Pdf.SaveType.OpenInBrowser, Response);
I'm not sure what changes in the latest version of Aspose.Words and Aspose.Pdf are causing the problem. And in order for us to investigate the issue, we need to test the scenario at our end. For that reason we would be requiring the documents that are causing issue at your end.
FYI, In recent versions of Aspose.Words for .NET a new method of saving Word file directly into PDF format has been introduced. You can try using that to accomplish your requirement. Please try using the following code snippet and see if it can resolve your problem or not
Hello, Thank you for yout suggestion, I can't simply use your code to convert a doc tos pdf and display it in the browser, because we are using Aspose.Pdf.Pdf to add a table of contents, and also do some formatting. I'm attaching a Word doc saved right before conversion to pdf (AlertPrint.doc), the resulting pdf (AlertPrint.pdf), and a source code file.
There are 2 problems so far: 1. Page footer image which exists in a word before conversion is lost when converted to pdf. 2. Table of contents, generated using Aspose.Pdf.Pdf, has all page numbers set to 0.
After thorough investigation, I’ve figured out the reason regarding both the issues that you have specified in your previous post.
1) The image is not appearing in the footer section due to the SaveOptions_PdfExportImageSaving() method. As a workaround, you can temporarily save the image to a location on your system. After the conversion process is completed, you can delete the image files.
To specify the location where the intermediate image should be saved, use:
To delete the contents of the folder saved during the conversion process, use the following code:
// retrieve all the files and put them into a string array
String[] names = Directory.GetFiles(@"D:/pdftest/AlertPrint/temp");
// now loop through all the files and delete them
foreach (String file in names)
System.IO.File.Delete(file);
2) For the second issue, where TOC items are pointing to page 0, this is a defect in our latest version of Aspose.Pdf for .NET 4.1.0.0. It has been logged as PDFNET-10969 in our issue tracking system. We will investigate it and keep you updated on the status of the fix.
Additionally, I noticed that the width of the table in the “Geographic Regions” section is not being correctly specified in the PDF document. According to my investigation, this issue originates from Aspose.Words, as incorrect table width information is being exported to an intermediate XML file. We are coordinating with the Aspose.Words team to resolve this.
I’ve manually corrected some information, and the resultant PDF that I generated using Aspose.Pdf for .NET 4.0.0.0 is attached. Please take a look.
I like your pdf, but it looks differently from AlertPrint.pdf I included in the previous post.
In AlertPrint.pdf some spaces are mising in the page headers, and they are displayed in the word doc before conversion:
http://www.ecri.org/Printed from Health Devices Alerts onMonday, October 05, 2009Page 2
In your pdf headers are displayed correctly. Was this issue fixed?
Other spacing issues - there is more spacing in AlertPrint.pdf (using 4.1) than it was in 3.6 version between bulleted list items, between segments “Source”, “Comment”, “Verification History”, etc than when we are using 3.6 version. Are you planning to do anything about it?Thank you.
The resultant PDF that I shared in my previous post seems to be more appropriate because I’ve made some changes in the Intermediate XML before its converted into PDF format.
The spacing issue seems to be resolved in the latest version of Aspose.Pdf 4.1.0.0 and also the second issue that you’ve mentioned seems to have been corrected in this release. I’ve attached the resultant PDF that I’ve generated when using Aspose.Pdf for .NET 4.1.0.0. (you would notice that page number information over TOC is not correct, as I’ve mentioned in my previous post that issue has been logged and is under investigation).
In case of any further query, please feel free to contact.
The issue has been communicated to Aspose.Words team and I hope they will shortly be updating you with the ETA regarding the resolution of this problem.
Once the issue at Aspose.Words is resolved, Aspose.Pdf will be working over this issue to get it resolved. Your patience and understanding is greatly appreciated in this regard.
I have tested the issue and I’m able to reproduce the same problem. I have logged it in our issue tracking system as PDFNET-12951. We will investigate this issue in detail and will keep you updated on the status of a correction. We apologize for your inconvenience.
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.