Pdf Component - HttpMethod

18 Nov 20261 minute to read

Public enum to define the HTTP method used when submitting PDF form data through a PdfSubmitFormAction.

// Create a new PDF document
let document: PdfDocument = new PdfDocument();
let page: PdfPage = document.addPage();
// Create a text box field
let textField: PdfTextBoxField = new PdfTextBoxField(
    page, 'Name', { x: 20, y: 20, width: 150, height: 30 }
);
document.form.add(textField);
// Create a submit-form action
let action: PdfSubmitFormAction = new PdfSubmitFormAction('https://submit.example.com');
action.fields = [textField];
action.include = true;
action.httpMethod = HttpMethod.Post;
// Create a button and assign the action
let button: PdfButtonField = new PdfButtonField(
    page, 'SubmitForm', { x: 20, y: 70, width: 120, height: 30 }
);
button.text = 'Submit form';
button.actions.mouseUp = action;
document.form.add(button);
// Save and destroy the document
document.save('output.pdf');
document.destroy();
  • Get - Specifies that form data is submitted using the GET method.
  • Post - Specifies that form data is submitted using the POST method.