Free Support Forum - aspose.com

How to recognize Form Fields in PDF File?

Hi,

I need to replace a Form field's value with some other value.

How to do this? Can i use ASPOSE.Pdf.Kit for the same?

I also need to fill existing image field with actual image.

Please reply asap.

Thanks & Regards,

Harshada

Dear Harshada,

Thanks for considering Aspose.Pdf.Kit.

Filling Form Field is one of the main functions of Kit. It fully satisfied your requirements. Please refer to our wiki or demo for detail.

Best regards.

Hi,

Can u please tell me how exactly to find out form fields?

I tried two things,

1.

Aspose.Pdf.Kit.Form objForm = new Aspose.Pdf.Kit.Form(@"D:\Sample.pdf");

for (int i = 0; i < objForm.FieldsNames.Length; i++)

{

string str = objForm.FieldsNames[i];

}

But this returns an array(FieldsNames) with 0 length and i get no form fields.

Other way was to simply search for the string in entire pdf for which i followd following approach

2. I simply coded for searching a text in the .Pdf file and replaced it with some other string.

Aspose.Pdf.Kit.PdfContentEditor objContentEditor = new PdfContentEditor();

objContentEditor.BindPdf(@"D:\Sample.pdf");

objContentEditor.ReplaceText("[insert name]", "abcdefgh");

objContentEditor.Save(@"D:\Sample_Modified.pdf");

Problem with this is, it gives me error when i try to open "Sample_Modified.pdf". Error is "Invalid Color Specs"

Please help asap.

Thanking u in anticipation.

Regards,

harshada.

Hi,

Can you please send us your Pdf document and let us test this issue.

Thanks.

Hi,

Thanks for the quick response.

I want to replace text which is enclosed in "[]" (brackets) as well as images(for which the empty placeholders are provided)from the existing pdf which is enclosed in an attachment, I tried two things,

1.

Aspose.Pdf.Kit.

Form objForm = new Aspose.Pdf.Kit.Form (@"D:\Sample.pdf");

for (int i = 0; i < objForm.FieldsNames.Length; i++)

{

string str = objForm.FieldsNames[i];

}

But this returns an array(FieldsNames) with 0 length and i get no form fields.

Other way was to simply search for the string in entire pdf for which i followd following approach

2. I simply coded for searching a text in the .Pdf file and replaced it with some other string.

Aspose.Pdf.Kit.

PdfContentEditor objContentEditor = new PdfContentEditor();

objContentEditor.BindPdf(@"D:\Sample.pdf");

objContentEditor.ReplaceText("[insert plan name]", "abcdefgh");

objContentEditor.Save(@"D:\Sample_Modified.pdf");

Problem with this is, it gives me error when i try to open "Sample_Modified.pdf". Error is "Invalid Color Spacs"

I could not send u the exact pdf file i have removed few things outof it using editing tool.So kindly ignore the watermarks which are present in the pdf attached.

Please reply asap.

Thanks & Regards,

Harshada.

Hi,

I have logged this issue as PDFKITNET-3685. I will discuss this with the developers and we will let you know as soon as solution is found.

Thanks.

Dear Harshada,

Thanks for considering Aspose.Pdf.Kit.

As for your Issue 1 about Form.FieldNames, after investigation into the document you provided, I found that it has NONE field in it. So Form.FieldName returning an empty array is correct.

Issue 2 will be handled by my colleagues, I believe it will be solved soon. And please feel free to let us know any question you meet.

Best regards.

Hi Luke,

Thanks for the coordination.

The rpoblem with the sample.pdf (the file which i have send earlier) is,

1. If the fields which are in [] "brackets" are not the form fields then what they are? So how to search for those fields and replace them??

2. Since this particular file is the input to my application, i dont have ne idea how it was generated.

Wil aspose.Pdf.Kit b able to solve my problem? As the input file is pdf document it should be able to identfy atleast the string values which are present in the document and replace them as it does with other "normal" pdf files.

I highly appreacite the support that ur team is giving.

Regards,

Harshada.

Dear Harshada,

Yes, when this bug will be fixed then hopefully you can be able to replace the text as per your code to replace text.

Thanks.

Hi,

Can you tell me the time when will it be fixed? and when i'll be able to replec the text?

and wht about the image replacement?? can i use aspose for both the issues(text and image replacement)??

Thanks & Regards,

Harshada

Dear Harshada,

I will ask the developer to give you an ETA soon. About the other, I am afraid that Image replacement is not supported by Aspose.Pdf.kit.

Thanks.

Hi, We will fix this bug whthin a week, but now Aspose.kit only supports to replace the text.

Hi,

Thanks for the response. So text replacement issue will be solved in a weeks time... thts gr8 :)

But how about image?? I need both the functionalities..

If u look @ sample.pdf (which i hav send earlier) its not exactly replacement.. but its filling an empty image object with some image. If aspose.pdf.kit is not supporting such feature then, is thr ne other aspose tool which does this job??

Waiting for a reply....

Regards,

Harshada.

Hi,

We will investigate the requirement of image replace in aspose.pdf.kit, but i think it can not be supported in a short time.

Dear Haeshada,

There is no other Aspose tool support this feature.

Hi,

So by no means I can fill those image placeholders with the actual images???

And ne updates on text replacement issue?

Thanks & Regards,

Harshada.

Hi,

We have fixed the bug of text replacement, it will be supported in the next fix version. As to image replacement, we are investigating, but it can not be supported in a short time.

Hi,

How and when will I get that version??

Thanks & regards,

Harshada.