Hi,
I've to fill several PDF Forms with text values.
Some of them should be handled in the meaning of a URL and open another document clicking on that item.
After filling the formular field and Setting it to "read only" I cann see the text, but it never be handled as an URL.
How can I solve that?
Formular Fields as URL
Re: Formular Fields as URL
Support · Nov 14, 2014Hello,
It is not possible to add a link within a form field. However, you can replace the form field with a url as shown in the code below. First, you would retrieve the form field properties – location, dimensions & font size. Then use this information to create a link, flatten the form field and add the link in the location of the form field.
PdfDocument pdf = new PdfDocument("fw9AcroForm_11.pdf");
MergeDocument document = new MergeDocument(pdf);
Page page = document.Pages[pdf.Form.Fields["form field name"].GetOriginalPageNumber() - 1];
//retrieve the properties of the form field.
float x = pdf.Form.Fields["form field name"].GetX(page);
float y = pdf.Form.Fields["form field name"].GetY(page);
float height = pdf.Form.Fields["form field name"].Height;
float width = pdf.Form.Fields["form field name"].Width;
float fontsize = pdf.Form.Fields["form field name"].FontSize;
//flatten the form field.
document.Form.Fields["form field name"].Output = FormFieldOutput.Flatten;
//Create a label for the link
Label label = new Label("This is a link to www.dynamicpdf.com", x, y, width, height, Font.Helvetica, fontsize, RgbColor.Blue);
label.Underline = true;
// Set the action then create the link
UrlAction action = new UrlAction("http://www.dynamicpdf.com");
Link link = new Link(x, y, width, height, action);
// Add the label and the link to the page
page.Elements.Add(label);
page.Elements.Add(link);
document.Draw("final.pdf");
Thanks,
ceTe Software Support Team.