Hello,
I’m writing a simple program that iterates over every page in a PDF and modifies any form PushButtons on the page. I need to modify the PushButton’s Action attributes. Basically, the buttons on these PDFs that I am looping over attempt to open a file on the system at a certain location, and we are needing to modify the path. I’m able to locate all of the PushButtons in a PDF, but I can’t seem to figure out how to modify this Action attributes. Is this possible with Aspose? I can’t even seem to be able to display the tooltip or label of the PushButton. All that I can seem to get is the name of it.
Here is my code, at the moment. It displays the name of all of the PushButtons in the PDF:
using System;
using System.IO;
using System.Text;
using System.Collections;
using Aspose.Pdf.Kit;
namespace UpdatePdfLinks
{
class Program
{
static void Main(string[] args)
{
// set aspose license
License l = new License();
l.SetLicense(@“Aspose.Total.lic”);
if (args.Length != 1)
{
Console.WriteLine(“Usage: UpdatePdfLinks.exe <input_file>”);
return;
}
// store the input file
string input_file = args[0];
if (!File.Exists(input_file))
{
Console.WriteLine(“The specified input file does not exist.”);
return;
}
// open the pdf form editor
Form f = new Form(input_file, input_file + “.foo.pdf”);
// loop over all the form field names
foreach (string field_name in f.FieldNames)
{
// we’re looking for only pushbuttons
if (field_name.Length > 0 && f.GetFieldType(field_name) == FieldType.PushButton)
{
// get the page number of this button
int page_number = f.GetFieldFacade(field_name).PageNumber;
Console.WriteLine(f.GetFullFieldName(field_name));
}
}
Console.ReadKey();
}
}
}