-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompletingAcroForm.php
More file actions
59 lines (53 loc) · 2.8 KB
/
Copy pathCompletingAcroForm.php
File metadata and controls
59 lines (53 loc) · 2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
// ========================================================================
// Author: DynamicPDF.COM CETE www.dynamicpdf.com
// Copyright: (c) 2021 DynamicPDF Cloud API
// License: MIT - for additional information see ./LICENSE in this project.
// Errors: Please report any errors in software to support@dynamicpdf.com
// ========================================================================
require __DIR__ . '/vendor/autoload.php';
use DynamicPDF\Api\Pdf;
use DynamicPDF\Api\FormField;
include_once("constants.php");
class CompletingAcroForm
{
public static function Run(string $apikey, string $path, string $output_path)
{
$pdf = new Pdf();
$pdf->ApiKey = $apikey;
//load the PDF from the cloud
$pdf->AddPdf("samples/fill-acro-form-pdf-endpoint/fw9AcroForm_18.pdf");
//complete the values from the pdf
$formField = new FormField("topmostSubform[0].Page1[0].f1_1[0]", "Any Company, Inc.");
$formField2 = new FormField("topmostSubform[0].Page1[0].f1_2[0]", "Any Company");
$formField3 = new FormField("topmostSubform[0].Page1[0].FederalClassification[0].c1_1[0]", "1");
$formField4 = new FormField("topmostSubform[0].Page1[0].Address[0].f1_7[0]", "123 Main Street");
$formField5 = new FormField("topmostSubform[0].Page1[0].Address[0].f1_8[0]", "Washington, DC 22222");
$formField6 = new FormField("topmostSubform[0].Page1[0].f1_9[0]", "Any Requester");
$formField7 = new FormField("topmostSubform[0].Page1[0].f1_10[0]", "17288825617");
$formField8 = new FormField("topmostSubform[0].Page1[0].EmployerID[0].f1_14[0]", "1234567");
$formField9 = new FormField("topmostSubform[0].Page1[0].EmployerID[0].f1_15[0]", "1234567");
array_push($pdf->FormFields, $formField);
array_push($pdf->FormFields, $formField2);
array_push($pdf->FormFields, $formField3);
array_push($pdf->FormFields, $formField4);
array_push($pdf->FormFields, $formField5);
array_push($pdf->FormFields, $formField6);
array_push($pdf->FormFields, $formField7);
array_push($pdf->FormFields, $formField8);
array_push($pdf->FormFields, $formField9);
//call the pdf endpoint and return response
$response = $pdf->Process();
//if response is successful the save the PDF returned from endpoint
if($response->IsSuccessful)
{
file_put_contents($output_path . "fill-acro-form-php-output.pdf", $response->Content);
} else {
echo("Error: ");
echo($response->StatusCode);
echo($response->ErrorId);
echo($response->ErrorMessage);
}
}
}
CompletingAcroForm::Run(CLIENT_EXAMPLES_API_KEY, CLIENT_EXAMPLES_BASE_PATH . "/fill-acro-form-pdf-endpoint/", CLIENT_EXAMPLES_OUTPUT_PATH);