We have recently upgraded to Aspose.Words version 9.2.0.0 and are having difficulty obtaining functionlity we had previously. We don’t want to have to also use Aspose.Pdf.Kit
Previous code converted our Word Document to PDF,
Called BindXML on a new Aspose.Pdf.Pdf object, then added a footer before saving:
dstDoc.Save(memStream, SaveFormat.AsposePdf)
Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()
pdf.BindXML(memStream, Nothing)
AddFooterToPDF(pdf)
Current code converts our Word Document directly to (Word) PDF
dstDoc.Save(memStream, SaveFormat.Pdf)
Binding to a pdf object is apparently no longer required. An attempt to do so raises an error.
In order to perform further manipulation, creating a pdf object using the memStream in the constructor is possible:
Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf(memStream)
And we seem to be able to add a footer to the pdf object.
HOWEVER, the problem is that the pdf object is in Direct-To-File mode and therefore we can’t call pdf.Save(outStream). If we call pdf.Close() then display the pdf, added sections are not visible. I’m not sure if they are even persisted.
Without using BindXML, there appears no other way to load the content into the pdf object. Direct-To-Stream mode is only available with an empty pdf object:
Dim pdf As Aspose.Pdf.Pdf = New Aspose.Pdf.Pdf()
I have even tried creating an xmlDocument to pass to BindXML, but this fails also.
Since the pdf currently exists in a MemoryStream, it seems reasonable that it should be able to be manipulated prior to displaying or actually saving to a FileStream. However this does not seem to be the case. I have spent several hours trying to find an answer without success. We should not have to use Aspose.pdf.kit which is designed to manipulate existing pdf files.
To summarise, I want to:
- Convert a Word document to PDF and hold in a MemoryStream object
- Add Footer content
- Write to the Response to enable open/save
Any comments or assistance appreciated!
CMH