Friend, we will better understand the application of your system... I could not understand what you need, so we can give a better answer.
Will you have a Form, or contract, or something like that that needs to be filled out by multiple customers or employees? Through the right system?
Does the content of this PDF constantly change? Are there several types of forms? (If both are negative you canif you put its contents fixed in your code or save the text in a table from a screen where the user who mounts the form type and click on a button that adds a gap and so on and when it comes to generating the PDF within the application you replace these Tags by fields.)
UPDATE:
I found an example that might help you!
//Read all 'Form values/keys' from an existing multi-page PDF document
public void ReadPDFformDataPageWise()
{
PdfReader reader = new PdfReader(Server.MapPath(P_InputStream3));
AcroFields form = reader.AcroFields;
try
{
for (int page = 1; page <= reader.NumberOfPages; page++)
{
foreach (KeyValuePair<string, AcroFields.Item> kvp in form.Fields)
{
switch (form.GetFieldType(kvp.Key))
{
case AcroFields.FIELD_TYPE_CHECKBOX:
case AcroFields.FIELD_TYPE_COMBO:
case AcroFields.FIELD_TYPE_LIST:
case AcroFields.FIELD_TYPE_RADIOBUTTON:
case AcroFields.FIELD_TYPE_NONE:
case AcroFields.FIELD_TYPE_PUSHBUTTON:
case AcroFields.FIELD_TYPE_SIGNATURE:
case AcroFields.FIELD_TYPE_TEXT:
int fileType = form.GetFieldType(kvp.Key);
string fieldValue = form.GetField(kvp.Key);
string translatedFileName = form.GetTranslatedFieldName(kvp.Key);
break;
}
}
}
}
catch
{
}
finally
{
reader.Close();
}
}
This and other examples of how to use iTextSharp
you find at this link
that
camposDict
is being received in the function. What value do I pass there? It is the absolute filename (path + filename) ??– CesarMiguel
No, it’s a dictionary, use as
Hashtable
where the key is the PDF field name!– Tiago César Oliveira
Yeah, there’s a problem. The client gave me the PDF without details. How do I know the name of the fields? I’m here looking in Foxit and I can’t find anything that tells me the name of the fields
– CesarMiguel
I filled in the form and exported the data to a
.txt
. Will the output displayed be the name of the fields in the PDF? Result:empresa de origem 1 empresa de origem 2 empresa de origem 3 empresa de origem 4 empresa de origem 5 empresa de origem 6 LocalData Assinatura Na qualidade de tradutor públ
11 22 33 44 55 66
– CesarMiguel
If you open a PDF with titles in Adobe PDF Reader, it displays! But to edit them you would need adobe Creator or equivalent.
– Tiago César Oliveira
Man, I don’t know... maybe they are! It’s worth the test!
– Tiago César Oliveira
By creating the
string urlPasta
get the errorLength cannot be less than zero.
. That’s because?– CesarMiguel
Its variable
path
should end with backslash (you can change according to your need). For me it was so because it used a network path. The purpose of this is to sanitize the bars, I would have solved it differently than we did when this code was created.– Tiago César Oliveira
Yes, I’m done correcting. It’s not writing in the headlines. I’m doing something like:
Hashtable campos = new Hashtable(); campos[1] = "empresa de origem 1"; campos[2] = "empresa de origem 2";

 foreach (DictionaryEntry de in (Hashtable)campos)
 {
 string Key = de.Key.ToString(); string value = "teste 1 !!!"; fields.SetField(Key, value);
 }
– CesarMiguel
Well, as I said, I suspect the camps should be named
– Tiago César Oliveira
I don’t think I know the name of the fields. I will draw the pdf :|
– CesarMiguel