Free Support Forum - aspose.com

Adding a stamp and text to the same document

Hello,

I need to be able to add a stamp and text to the same document.

To place the stamp, I need to instantiate a PdfFileStamp object and to add the text, I need to instantiate a PdfFileMend object. Neither of the objects actually change the document until they are closed and they write out a new document.

Is there a way to do both of these things at the same time, i.e. write one new document with both the stamp and text on it? Or will I need to create an intermediate document that contains the stamp and then add the text to it to get the final document?

I know I can put text on a document with the PdfFileStamp class, using the BindLogo method of the Stamp class, but I am hoping to be able to use the addText method of the PdfFileMend class and take advantage of its word wrap capabilities.

Thanks,

Steve

Hi Steve,

I’m afraid that you can’t do both of these things at the same time. As you know, these two features reside in two different classes, and each class opens and closes file for its use. However, if you want to avoid the disk read and write operations, you can use MemoryStreams for input and output files. You can save the output from the first file in a memory stream and then use that memory stream as an input for the next operation.

I hope this helps. If you have any further questions, please do let us know.
Regards,

Yes, that helps a lot. I knew I was going to have to create an intermediate file and was really looking for a better way than writing to disk and having to deal with the overhead and all the duplicate file/cleanup issues. Memory streams are a great idea.

Thanks.