I have a situation where the user uploads a pdf file (template) and it is
stored in the SQL Server Table in a field which has an image datatype.
Everything worked well so far. Now the user wants some data written onto the
pdf dynamically over the template. I used pdfstamper to write the text over
the data retrieved from the table.
Steps Taken:
1) Saved the file to the local harddrive and i was able to bring the pdf up
without any issues.
2) Saved it back to the table and while retrieving the pdf via the web app.
I get the error message "File does not start with %PDF-"
3) I opened the file via notepad. Before overwriting with data and the file
starts with "%PDF-1.4
%âãÏÓ
1 0 obj<</Subtype...."
4) File after overwriting with data : the file looks like this "1 0
obj<</Subtype/Type1/" and it's clearly missing the PDF related information.
Is there any properties i could use to set the PDF information?
Has anyone encountered a similar situation? Please help!!
Thanks in advance,
-Matt
Below is the sample code snippet:
PdfReader pdfReader = new PdfReader(d.DisclosurePdf);
//PdfReader pdfReader = new PdfReader(@"d:\test\xyz.pdf");
PdfStamper ps = new PdfStamper(pdfReader, mStream,'\0');
PdfContentByte under = ps.GetUnderContent(1);
PdfContentByte over = ps.GetOverContent(1);
BaseFont bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI,
BaseFont.EMBEDDED);
// text over the existing page
over.BeginText();
over.SetFontAndSize(bf, 10);
over.SetTextMatrix(95, 650);
over.ShowText(DateTime.Now.ToShortDateString());
over.EndText();
over.BeginText();
over.SetFontAndSize(bf, 10);
over.SetTextMatrix(250, 650);
over.ShowText("5000.00");
over.EndText();
mStream.Seek(0, SeekOrigin.Begin);
ps.Close();
result = mStream.ToArray();
--
View this message in context:
http://www.nabble.com/File-does-not-start-with--PDF--%28-after-using-pdfstamper-%29-tp24149110p24149110.html
Sent from the iText - General mailing list archive at Nabble.com.
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php
Check the site with examples before you ask questions:
http://www.1t3xt.info/examples/
You can also search the keywords list: http://1t3xt.info/tutorials/keywords/