Enter text into PDF field

Good Morning,

I found the below example on your website and I am trying to implement it into my asp.net / C# project. I have a PDF of a form but I do not know how to locate the field names on the PDF so that I can input the data into specific fields. A few questions:

1. Where does the original PDF have to sit in order for the program to find it? / Can I enter a full path location for the document (for load and save)?

2. Do I have to create an interactive form and give the form a textbox name?

I can create the form from scratch if I have to.

Thanks for your assistance,

Rob C.

//open document

Document pdfDocument = new Document("input.pdf");

//get a field

TextBoxField textBoxField = pdfDocument.Form["textbox1"] as TextBoxField;

//modify field value

textBoxField.Value = "Value to be filled in the field";

//save updated document

pdfDocument.Save("output.pdf");v


This message was posted using Page2Forum from Fill Form Field in a PDF Document - Aspose.Pdf for .NET

Hi Rob,

Thanks for your interest in our products.

Yes you can use full path for input and output files as mentioned below

Document pdfDocument = new Document(@"C:\input.pdf");

Kindly check the following documentation links for details and code snippets as per your requirement.

Working with Forms

Working with Forms (Facades)

Please do let us know if you need any further assistance.

Thanks & Regards,

Hi,

I am getting the following error while trying to run the below code:

Could not load file or assembly 'Aspose.Pdf, Version=6.4.0.0, Culture=neutral, PublicKeyToken=47b2d0fcacdd3eb6' or one of its dependencies. The system cannot find the file specified.

using Aspose.Pdf;

using Aspose.Pdf.InteractiveFeatures.Forms;

protected void lb1099_Click(object sender, EventArgs e)

{

//open document

Document pdfDocument = new Document(@"C:\Apose\test.pdf");

//get a field

TextBoxField textBoxField = pdfDocument.Form["TextField1"] as TextBoxField;

//modify field value

textBoxField.Value = "Value to be filled in the field";

        </p><p>//save updated document            
        </p><p>pdfDocument.Save(@"C:\Apose\testresult.pdf");

   </p><p>}</p>

Hi Rob,

Thank you for the sample code, please share the source PDF document with us. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

I was attempting to add an interactive field to an existing document. If there is a problem with this one, do you have a sample interactive pdf that I could use for testing?

Thanks,

Rob

Here is the original doc.

Hi Rob,

Thanks for the template file, I have tested the scenario with your provided source code and original PDF document using Aspose.Pdf for .NET version 6.4.2.0.

First of all, I have to add a TextBox in the PDF document with name "Text1" and execute the same code provided by you except replacing "TextField1" with "Text1" (name of the textbox), everything is working fine and value is set in the resultant PDF. Source and resultant PDF documents are attached for your reference.

Please try to use Aspose.Pdf for .NET version 6.4.2.0 and in case the problem still persists, please feel free to contact. We apologize for your inconvenience.

Thanks & Regards,

I receive the following error while trying to download the files:

Unexpected Error

An unexpected error has occurred while we were trying to fetch your desired resource. We apologize for the inconvenience. An email has been sent to the webmaster with the error details.

Hi Rob,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please try downloading the files shared by Rashid again as I just checked and I am able to download the files successfully.

If you still face the issue, please let us know.

Thank You & Best Regards,

Greetings:I was able to download the files. I also changed the text box field value to "Text1" and I am receiving the following error:

Could not load file or assembly 'Aspose.Pdf, Version=6.4.2.0, Culture=neutral, PublicKeyToken=47b2d0fcacdd3eb6' or one of its dependencies. The system cannot find the file specified.

Description:

An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Could not load file or assembly 'Aspose.Pdf, Version=6.4.2.0, Culture=neutral, PublicKeyToken=47b2d0fcacdd3eb6' or one of its dependencies. The system cannot find the file specified.

Just to let you know:

Aspose.Pdf (Reference)

C:\Program Files\Aspose\Aspose.Pdf for .NET\\bin\net3.5\Aspose.Pdf.dll

runtime version: v2.0.50727v2.0.50727

For Project as a whole:

Target Framework: .NET Framework 3.5

Hi Rob,

Thank you for the information, I tried using your provided information to test your issue but I am unable to replicate the scenario at my end, every thing is working fine. Please create a sample application to show the issue. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

I was able to figure out this issue. Thanks for all of your help!

One additional question, instead of saving the pdf to a specfic location on the pc, how can I instead prompt the user to enter the save location? This way when they go to the site and click on the doc link, they can either save or print the doc.

Thanks,

Rob

Hi,

Also, I was able to input text into the text field on your example no problem, but when I tried to create my own, I get the following error:

Form field not found : Text1

Do you have instructions on how to create the text fields (I am using adobe pro 7.0)

Hi Rob,

Thanks for your feedback.

You may check the following documentation links for details and code snippets as per your requirement.

Add Form Field in a PDF Document

Moreover, Kindly use the below mentioned code to open the saved file automatically and can be saved in any location.

[C#]

string file = @"d:\pdffiles\testresult.pdf";
pdfDocument.Save(file);
(new System.Diagnostics.Process { StartInfo = { FileName = file } }).Start();

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

Good Morning,

I do not get a save dialog box when running this code that you have provided. Any ideas?

Thanks,

Rob

//open document

Document pdfDocument = new Document(@"C:\FTP\Apose\1099INT.pdf");

//get a field

TextBoxField textBoxField = pdfDocument.Form["Text1"] as TextBoxField;

//modify field value

textBoxField.Value = "Test1";//get a field

TextBoxField textBoxField1 = pdfDocument.Form["Text2"] as TextBoxField;

//modify field value

textBoxField1.Value = "Test2";//save updated document

string file = @"C:\FTP\Apose\1099INTresult.pdf";

pdfDocument.Save(file); (new System.Diagnostics.Process { StartInfo = { FileName = file } }).Start();

I am getting the error:

At most 4 elements (for any collection) can be viewed in evaluation mode.

I think this is due to me having an evaluation version. Can you please send me a temp license key? I never received mine:

Order ID: 111207110243

Order Date: 12/7/2011

Hi Rob,

I am very sorry for the inconvenience caused due to this issue. However, I have requested the sale team to provide you temporary license as soon as possible.

Please do let us know if you need any further assistance.

Thanks & Regards,

Thank you! I did receive the temp license key. Also two posts ago, I mentioned that I was having difficulty getting a save dialog box to appear for the user. You responded with a code snippet and I tried it out but had no luck. Any other ideas?

Thanks,

Rob

Being able to save the PDF from the web browser would be the most ideal.