Adding text to a PDF document with itextsharp - itext

Is it possible to add text to end of a PDF document created by a software other that itextsharp by using itextsharp? I need to add signatures to hundreds of PDF documents so I am looking for a way to do this automatically.
Thanks.

Yes you can! Provided you have access rights to modify the PDFs. If they are password protected and you have the password you can use itextsharp to open them with the password to be able to edit them.
You can then use the itextsharp PdfStamper class in combination with the PdfContentByte class to add content to any position on the PDF.

Related

Is iText or iTextSharp capable of setting the edit password on a PDF

Is iText or iTextSharp capable of setting the edit password on a PDF?
I know when we use itextsharp to create a PDF, it can set a password to open the PDF. But I have not found a way to set up a password for editing PDF.

How to restrict your content in only one page in pdf using itext?

I'm trying to generate pdf using itext libs and I want to prevent page break. I want all my content in single page pdf only. How to achieve this?

IText Pdf - RadioBox(On/Off) not appearing for some pdf

In our application we are using Itext Pdf 5.5.3 library.
We have checked with some of the pdfs in which Checkboxes displayed correctly(check/uncheck) .
However there are some pdf with RadioBoxes and do not display radiobutton(on/off) correctly.
I also use this link to validate pdfs and java code
String[] values = form.getAppearanceStates("Checkbox");
return null values.
Also tried Itext RUPS and found that pdf which are working shows Form Field Names in RUPS Form Tab. And PDfs which are not working do not display form fields.
I tried generating pdf from word document and it doesn't display form fields in RUP , neither I can check/uncheck checkbox in Adobe Acrobat Reader.
What could be the solution to display radiobutton with check on / off ?
Edit -
I had created sample web application to reproduce the issue.
Please setup attached web application and let me know the fix for the issue.
Please download from this link
You have successfully discovered the difference between interactive PDF forms and "flat" PDF documents that look like a form to the human eye, but that aren't interactive forms.
To make the "flat" forms interactive, you need to open those flat documents in PDF editing software (e.g. Adobe Acrobat) and you need to add a form field manually.
You can ask Acrobat to guess where it should add fields, but Acrobat will be wrong in many cases for obvious reasons. You always need a human if you want it to be done correctly.
As for creating an interactive PDF from Word... Forget about it. Use OpenOffice or LibreOffice.

Creating a fillable PDF form with ITextSharp

I have created a PDF file using Acrobat Adobe 8 that contains fillable fields.
Can that be programmed with ITextSharp instead of Adobe?
Note: I am not referring to filling out the PDF with ITextSharp, instead I would like to create the fillable fields on the PDF file using ITextSharp.
Any code would be appreciated.
thank you for your time!
You can create PDFs that contain fillable fields with iText[Sharp], but they won't look as nice as Adobe Acrobat, which is a much better design tool.
By fillable fields, I'm guessing you mean a TextField. Here's a link with some simple example code from the book to get you started. Specifically, take a look at the CreatePdf() and CellLayout() methods, and the iText API if you need more information.

Modifying the text in a PDF document

I am putting a single line of info to the end of first page of a PDF document by using PdfStamper class. Now I need to update that info periodically. How can I modify the text I stamped previously, is there a way for it?
Thanks.
See this post from Bruno Lowagie (the creator of iText) about PDF not being a word processor. In that post he talks about using forms instead to accomplish what you are looking for which is one route you can go down.
The second route, which I'd recommend, is just having two PDFs. Have your base PDF that you open, write to and save to your output PDF. When you need to update the PDF, delete the output PDF, re-open the base PDF, write your new text and save it to the output PDF again. This accomplishes your goals without having to edit anything.