Can I get an example of how I would add a footer to a pdf stream I have. The stream is the concatenation of two pdf documents. Please refer to Concatenate Issue for an open issue I have with that.
Hi Robert,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for sharing the details.
Please see the following documentation links as per your requirement:
Add Page Number in a PDF File (Facades)
Add Footer in a PDF File (Facades)
Add Text Stamp on All Pages in a PDF File (Facades)
Also, as per your scenario, please refer to the following code sample regarding concatenation of PDF files and then adding page stamp and date in the footer.
//create PdfFileEditor object
PdfFileEditor pdfEditor = new PdfFileEditor();
//output stream
FileStream outputStream = new FileStream("D:/AP Data/Dec2011/footer.pdf", FileMode.Create);
//input streams
FileStream inputStream1 = new FileStream("D:/AP Data/Dec2011/input1.pdf", FileMode.Open);
FileStream inputStream2 = new FileStream("D:/AP Data/Dec2011/input2.pdf", FileMode.Open);
//concatenate file
pdfEditor.Concatenate(inputStream1, inputStream2, outputStream);
//open document
PdfFileStamp fileStamp = new PdfFileStamp(outputStream, outputStream);
//get total number of pages
int totalPages = new PdfFileInfo(outputStream).NumberOfPages;
//create formatted text for page number
FormattedText formattedText = new FormattedText("Page # Of " + totalPages, System.Drawing.Color.Black, System.Drawing.Color.White, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 10);
//set starting number for first page; you might want to start from 2 or more
fileStamp.StartingNumber = 1;
//add page number
fileStamp.AddPageNumber(formattedText, 1);
//create formatted text for page number
FormattedText formattedText2 = new FormattedText(DateTime.Now.ToShortDateString(), System.Drawing.Color.Black, System.Drawing.Color.White, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 10);
//add footer
fileStamp.AddFooter(formattedText2, 5);
//save updated PDF
fileStamp.Close();
outputStream.Close();
inputStream1.Close();
inputStream2.Close();
Please feel free to contact support in case you need any further assistance.
Thank You & Best Regards,
Thanks for your response. Looks like the bug identified in my previous post (PDFNEWNET-32674 ) is allows hitting me on this one as well. I can get this to work fine using the example provided but when I use the memory streams it fails with the same error. Looks like I really need the above bug fixed
The bug I had reported in (PDFNEWNET-32674) and post Aspose.Pdf for .NET 6.6.0.
Problem is if I try to add a footer using the methods above I am getting an error "File does not begin '%PDF-'."
Attached is a sample project showing the issue
Hi Robert,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thank you for sharing the demo application.
I am able to generate your mentioned issue after an initial test. Your issue has been registered in our issue tracking system with issue id: PDFNEWNET-33153. You will be notified via this forum thread regarding any update against your issue.
Sorry for the inconvenience,
The issues you have found earlier (filed as PDFNEWNET-33153) have been fixed in this update.
This message was posted using Notification2Forum from Downloads module by aspose.notifier.
This is still not fixed
Please see attached demo project
Hi Robert,
I tested the scenario and able to notice the same problem. For rectification, I have reopened this issue in our Issue Tracking System. We will further look into the details of this issue and will keep you updated via this forum thread on the status of correction.
We apologize for your inconvenience.
Thanks & Regards,
Hi Robert,
Thanks for your patience.
I am very glad to inform that, your issue is resolved by the development team. Kindly add one line of code in page load method highlighted bold as mentioned below. After changing the code please check first 4 bytes of buffer. It should be 37 80 68 70 - it is %PDF
buffer = new byte[_ReportStream.Length];
_ReportStream.Position = 0;
_ReportStream.Read(buffer, 0, buffer.Length);
Please feel free to contact support in case you need any further assistance.
Thanks & Regards,
Yes, that does reslove my issue
Thanks
Hi Robert,
We appreciate your time and effort in providing feedback to us. This will help us to close the issue from our issue tracking system. Please feel free to contact support in case you required any assistance in future.
Thanks & Regards,