1

I have one pdf file and in that I have editable text boxes. It has around 20 textboxes.. Now I need to update values in that using some variables..

Like in textbox1 value sholuld come from Var1 etc..

I am using .Net-C# aspose PDF library..

So my concern is how can I access that textbox in my code, I have tried with TextFragmentAbsorber but not getting that.

Check below image you will see 3 textboxes so I want to fetch that and want to set some values in that.

enter image description here

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
Nic
  • 439
  • 4
  • 14
  • We believe that the links and information shared in the below answer contains all the details required to meet your needs. However, if you still face any issues, please share your sample PDF after creating a post in Aspose.PDF forum (https://forum.aspose.com/c/pdf) so that we can further proceed to assist you accordingly. This is Asad Ali and I am Developer Evangelist at Aspose. – Asad Ali Jun 27 '23 at 19:53

1 Answers1

1

I would suggest looking at the documentation. A quick search found me this to access the form fields:

// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

// Open document
Document pdfDocument = new Document(dataDir + "GetValuesFromAllFields.pdf");

// Get values from all fields
foreach (Field formField in pdfDocument.Form)
{
    Console.WriteLine("Field Name : {0} ", formField.PartialName);
    Console.WriteLine("Value : {0} ", formField.Value);
}

Source where I found it: https://docs.aspose.com/pdf/net/extract-form/

this is from the example on how to populate form fields:

// For complete examples and data files, please go to https://github.com/aspose-pdf/Aspose.PDF-for-.NET
// The path to the documents directory.
string dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

// Open document
Document pdfDocument = new Document(dataDir + "FillFormField.pdf");

// Get a field
TextBoxField textBoxField = pdfDocument.Form["textbox1"] as TextBoxField;

// Modify field value
textBoxField.Value = "Value to be filled in the field";
dataDir = dataDir + "FillFormField_out.pdf";
// Save updated document
pdfDocument.Save(dataDir);

Source: https://docs.aspose.com/pdf/net/fill-form/

silverfighter
  • 6,762
  • 10
  • 46
  • 73