Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -637,14 +637,14 @@ For security reasons you may wish to confirm the installer's authenticity. To do
1. After downloading the package zip, run following command

```
pip hash <download_dir>/pdfservices-sdk-4.1.1.tar.gz
pip hash <download_dir>/pdfservices-sdk-4.2.0.tar.gz
```

1. Above command will return the hash of downloaded package.
2. Verify the hash matches the value published here.

```
a7592acd8c93eac52e0d8eae24cf2b8eee331f8704172a7b91ab7891fac5585d
378afa7d3b22683264a1817393932a649b98e4d4b3913816f839de240f7132d5
```

###### To generate tagged PDF from the sample file
Expand Down
4 changes: 2 additions & 2 deletions src/pages/overview/pdf-extract-api/gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -637,14 +637,14 @@ For security reasons you may wish to confirm the installer's authenticity. To do
1. After downloading the package zip, run following command

```
pip hash <download_dir>/pdfservices-sdk-4.1.1.tar.gz
pip hash <download_dir>/pdfservices-sdk-4.2.0.tar.gz
```

1. Above command will return the hash of downloaded package.
2. Verify the hash matches the value published here.

```
a7592acd8c93eac52e0d8eae24cf2b8eee331f8704172a7b91ab7891fac5585d
378afa7d3b22683264a1817393932a649b98e4d4b3913816f839de240f7132d5
```

###### To extract data from the sample PDF file
Expand Down
4 changes: 2 additions & 2 deletions src/pages/overview/pdf-services-api/gettingstarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,14 @@ For security reasons you may wish to confirm the installer's authenticity. To do
1. After downloading the package zip, run following command

```
pip hash <download_dir>/pdfservices-sdk-4.1.1.tar.gz
pip hash <download_dir>/pdfservices-sdk-4.2.0.tar.gz
```

2. Above command will return the hash of downloaded package.
3. Verify the hash matches the value published here.

```
a7592acd8c93eac52e0d8eae24cf2b8eee331f8704172a7b91ab7891fac5585d
378afa7d3b22683264a1817393932a649b98e4d4b3913816f839de240f7132d5
```

## Public API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The sample below exports PDF form data and returns it as a JSON file.

Please refer to the [API usage guide](../api-usage.md) to understand how to use our APIs.

<CodeBlock slots="heading, code" repeat="2" languages="Java, REST API" />
<CodeBlock slots="heading, code" repeat="3" languages="Java, Python, REST API" />

#### Java

Expand Down Expand Up @@ -80,6 +80,68 @@ public class ExportPDFFormData {
}
```

#### Python

```python
# Get the samples https://github.com/adobe/pdfservices-python-sdk-samples
# Run the sample:
# python src/exportpdfformdata/export_pdf_form_data.py

# Initialize the logger
logging.basicConfig(level=logging.INFO)

class ExportPDFFormData:
def __init__(self):
try:
file = open('../resources/exportPdfFormDataInput.pdf', 'rb')
input_stream = file.read()
file.close()

# Initial setup, create credentials instance
credentials = ServicePrincipalCredentials(
client_id=os.getenv('PDF_SERVICES_CLIENT_ID'),
client_secret=os.getenv('PDF_SERVICES_CLIENT_SECRET')
)

# Creates a PDF Services instance
pdf_services = PDFServices(credentials=credentials)

# Creates an asset(s) from source file(s) and upload
input_asset = pdf_services.upload(input_stream=input_stream,
mime_type=PDFServicesMediaType.PDF)

# Creates a new job instance
export_pdf_form_data_job = ExportPDFFormDataJob(input_asset=input_asset)

# Submit the job and gets the job result
location = pdf_services.submit(export_pdf_form_data_job)
pdf_services_response = pdf_services.get_job_result(location, ExportPDFFormDataResult)

# Get content from the resulting asset(s)
result_asset = pdf_services_response.get_result().get_asset()
stream_asset = pdf_services.get_content(result_asset)

# Creates an output stream and copy stream asset's content to it
output_file_path = self.create_output_file_path()
with open(output_file_path, "wb") as file:
file.write(stream_asset.get_input_stream())

except (ServiceApiException, ServiceUsageException, SdkException) as e:
logging.exception(f'Exception encountered while executing operation: {e}')

# Generates a string containing a directory structure and file name for the output file
@staticmethod
def create_output_file_path() -> str:
now = datetime.now()
time_stamp = now.strftime("%Y-%m-%dT%H-%M-%S")
os.makedirs("../../output/ExportPDFFormData", exist_ok=True)
return f"../../output/ExportPDFFormData/export{time_stamp}.json"


if __name__ == "__main__":
ExportPDFFormData()
```

#### REST API

```javascript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The sample below demonstrates how to import form data from a JSON into PDF and g

Please refer to the [API usage guide](../api-usage.md) to understand how to use our APIs.

<CodeBlock slots="heading, code" repeat="2" languages="Java, REST API" />
<CodeBlock slots="heading, code" repeat="3" languages="Java, Python, REST API" />

#### Java

Expand Down Expand Up @@ -95,6 +95,84 @@ public class ImportPdfFormData {
}
```

#### Python

```python
# Get the samples https://github.com/adobe/pdfservices-python-sdk-samples
# Run the sample:
# python src/exportpdfformdata/export_pdf_form_data.py

# Initialize the logger
logging.basicConfig(level=logging.INFO)

class ImportPDFFormData:
def __init__(self):
try:
file = open('../resources/importPdfFormDataInput.pdf', 'rb')
input_stream = file.read()
file.close()

# Initial setup, create credentials instance
credentials = ServicePrincipalCredentials(
client_id=os.getenv('PDF_SERVICES_CLIENT_ID'),
client_secret=os.getenv('PDF_SERVICES_CLIENT_SECRET')
)

# Creates a PDF Services instance
pdf_services = PDFServices(credentials=credentials)

# Creates an asset(s) from source file(s) and upload
input_asset = pdf_services.upload(input_stream=input_stream,
mime_type=PDFServicesMediaType.PDF)

# Form data to be imported
form_data = {
"option_two": "Yes",
"option_one": "Yes",
"name": "garvit",
"option_three": "Off",
"age": "24",
"favorite_movie": "Star Wars Again",
}

# Create parameters for the job
import_pdf_form_data_params = ImportPDFFormDataParams(json_form_fields_data=form_data)

# Creates a new job instance
import_pdf_form_data_job = ImportPDFFormDataJob(input_asset=input_asset)

# Set the parameters for the job
import_pdf_form_data_job.set_params(import_pdf_form_data_params)

# Submit the job and gets the job result
location = pdf_services.submit(import_pdf_form_data_job)
pdf_services_response = pdf_services.get_job_result(location, ImportPDFFormDataResult)

# Get content from the resulting asset(s)
result_asset = pdf_services_response.get_result().get_asset()
stream_asset = pdf_services.get_content(result_asset)

# Creates an output stream and copy stream asset's content to it
output_file_path = self.create_output_file_path()
with open(output_file_path, "wb") as file:
file.write(stream_asset.get_input_stream())

except (ServiceApiException, ServiceUsageException, SdkException) as e:
logging.exception(f'Exception encountered while executing operation: {e}')

# Generates a string containing a directory structure and file name for the output file
@staticmethod
def create_output_file_path() -> str:
now = datetime.now()
time_stamp = now.strftime("%Y-%m-%dT%H-%M-%S")
os.makedirs("../../output/ImportPDFFormData", exist_ok=True)
return f"../../output/ImportPDFFormData/import{time_stamp}.pdf"


if __name__ == "__main__":
ImportPDFFormData()
```

#### REST API

```javascript
Expand Down
4 changes: 4 additions & 0 deletions src/pages/overview/releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ Upgrading to the latest SDK should not break existing applications.

## Change history

### July 10, 2025; Python SDK 4.2.0 Release

- Added support for [Export PDF Form Data](../pdf-services-api/howtos/export-pdf-form-data/) and [Import PDF Form Data](../pdf-services-api/howtos/import-pdf-form-data/) operations in PDF Services Python SDK, enabling users to extract and populate form Data.

### May 22, 2025; .NET SDK 4.3.0 Release

- Added support for [Export PDF Form Data](../pdf-services-api/howtos/export-pdf-form-data/) and [Import PDF Form Data](../pdf-services-api/howtos/import-pdf-form-data/) operations in PDF Services .NET SDK, enabling users to extract and populate form Data.
Expand Down
Loading