Free Support Forum - aspose.com

Adding a TextBoxField to PDF - Documentation Seems Different Then Current API

Hi, I downloaded your Aspose.PDF product today. I am trying to insert a text box field into an existing PDF. The API Documentation says that the constructor for TextBoxField accepts four integers. The Constructor from the DLL i downloaded from your website is expecting a PDF Page and a Rectangle. When I try to add the field to the form using .Form.Add(TextBoxField), the server just hangs, and no file is generated. Thanks for your help.

Hi Mike,

The API was changed slightly, so please try the following code snippet to add text box in the PDF:


//open document

Document pdfDocument = new Document(“input.pdf”);


//create a field

TextBoxField textBoxField = new TextBoxField(pdfDocument.Pages[0], new Aspose.Pdf.Rectangle(100, 200, 300, 300));

textBoxField.PartialName = “textbox1”;

textBoxField.Value = “Text Box”;

textBoxField.Color = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);


//add field to the document

pdfDocument.Form.Add(textBoxField, 1);


//save modified PDF

pdfDocument.Save(“output.pdf”);


If you still find any problem then please share the input PDF file with us, so we could investigate the issue at our end. You’ll be updated with the results accordingly.

We’re sorry for the inconvenience.
Regards,