Skip to content

Commit

Permalink
Merge pull request #798 from AdobeDocs/python_release_2.3.1
Browse files Browse the repository at this point in the history
Python release 2.3.1
  • Loading branch information
paras-n authored Mar 8, 2024
2 parents 2ed4415 + 1b4622a commit e1db27e
Show file tree
Hide file tree
Showing 18 changed files with 21,625 additions and 15,807 deletions.
2 changes: 1 addition & 1 deletion src/pages/apis/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Adobe PDF Services Open API spec
description: The OpenAPI spec for Adobe PDF Services API endpoints, parameters, and responses.
openAPISpec: https://raw.githubusercontent.com/AdobeDocs/pdfservices-api-documentation/develop/src/pages/resources/openapi.json
openAPISpec: https://raw.githubusercontent.com/AdobeDocs/pdfservices-api-documentation/main/src/pages/resources/openapi.json
---
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,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-2.0.0.tar.gz
pip hash <download_dir>/pdfservices-sdk-2.3.1.tar.gz
```

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

```
606f08f0e525a1e0ae79567c077c29dee66971d46415dbc693b95f31597690c0
08d1c40995658e380c7e5d2fec4cebfbfc22b246582719c5451ae708a28b6a09
```

###### To generate tagged PDF from the sample file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ try:
base_path = str(Path(__file__).parents[2])

# Initial setup, create credentials instance.
credentials = Credentials.service_principal_credentials_builder()
.with_client_id('PDF_SERVICES_CLIENT_ID')
.with_client_secret('PDF_SERVICES_CLIENT_SECRET')
credentials = Credentials.service_principal_credentials_builder() \
.with_client_id('PDF_SERVICES_CLIENT_ID') \
.with_client_secret('PDF_SERVICES_CLIENT_SECRET') \
.build()

# Create an ExecutionContext using credentials and create a new operation instance.
Expand Down Expand Up @@ -707,9 +707,9 @@ class AutotagPDFParameterised:
def autotag_pdf(self):
try:
# Initial setup, create credentials instance.
credentials = Credentials.service_principal_credentials_builder()
.with_client_id('PDF_SERVICES_CLIENT_ID')
.with_client_secret('PDF_SERVICES_CLIENT_SECRET')
credentials = Credentials.service_principal_credentials_builder() \
.with_client_id('PDF_SERVICES_CLIENT_ID') \
.with_client_secret('PDF_SERVICES_CLIENT_SECRET') \
.build()

# Create an ExecutionContext using credentials and create a new operation instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ const clientConfig = PDFServicesSdk.ClientConfig

Available properties:

- **connectTimeout**: Default: 4000. The number of milliseconds
- **connectTimeout**: Default: 4000. The number of milliseconds
Requests will wait for the client to establish a connection to
Server.
- **readTimeout**: Default: 10000. The number of milliseconds the
- **readTimeout**: Default: 10000. The number of milliseconds the
client will wait for the server to send a response.
- **processingTimeout**: Default: 600000. The maximum allowed time
in milliseconds for processing the documents. Any operation taking more time than the specified `processingTimeout` will result in an operation timeout exception.
- **Note :** It is advisable to set the `processingTimeout` to higher values for processing large files.

Override the timeout properties via a custom `ClientConfig` class:

Expand All @@ -129,5 +132,6 @@ Override the timeout properties via a custom `ClientConfig` class:
client_config = ClientConfig.builder()
.with_connect_timeout(10000)
.with_read_timeout(40000)
.with_processing_timeout(900000)
.build()
```
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ This defines what our output directory will be and optionally deletes it if it a

```python
# Initial setup, create credentials instance.
credentials = Credentials.service_principal_credentials_builder()
.with_client_id(os.getenv('PDF_SERVICES_CLIENT_ID'))
.with_client_secret(os.getenv('PDF_SERVICES_CLIENT_SECRET'))
.build();
credentials = Credentials.service_principal_credentials_builder() \
.with_client_id(os.getenv('PDF_SERVICES_CLIENT_ID')) \
.with_client_secret(os.getenv('PDF_SERVICES_CLIENT_SECRET')) \
.build()

# Create an ExecutionContext using credentials and create a new operation instance.
execution_context = ExecutionContext.create(credentials)
Expand Down Expand Up @@ -143,11 +143,13 @@ from adobe.pdfservices.operation.execution_context import ExecutionContext
from adobe.pdfservices.operation.io.file_ref import FileRef
from adobe.pdfservices.operation.pdfops.autotag_pdf_operation import AutotagPDFOperation
from adobe.pdfservices.operation.internal.api.dto.request.autotagpdf.autotag_pdf_output import AutotagPDFOutput
from adobe.pdfservices.operation.pdfops.options.autotagpdf.autotag_pdf_options import AutotagPDFOptions

import logging
import os.path
from pathlib import Path


input_pdf = "./Adobe Accessibility Auto-Tag API Sample.pdf"

output_path = "./output/AutotagPDF/"
Expand All @@ -157,38 +159,37 @@ tagged_pdf_path = f'{output_path}{input_pdf}-tagged.pdf'
report_path = f'{output_path}{input_pdf}-report.xlsx'

try:

# Initial setup, create credentials instance.
credentials = Credentials.service_principal_credentials_builder()
.with_client_id(os.getenv('PDF_SERVICES_CLIENT_ID'))
.with_client_secret(os.getenv('PDF_SERVICES_CLIENT_SECRET'))
.build();

# Create an ExecutionContext using credentials and create a new operation instance.
execution_context = ExecutionContext.create(credentials)
autotag_pdf_operation = AutotagPDFOperation.create_new()

# Set operation input from a source file.
source = FileRef.create_from_local_file(input_pdf)
# Initial setup, create credentials instance.
credentials = Credentials.service_principal_credentials_builder() \
.with_client_id(os.getenv('PDF_SERVICES_CLIENT_ID')) \
.with_client_secret(os.getenv('PDF_SERVICES_CLIENT_SECRET')) \
.build()

# Create an ExecutionContext using credentials and create a new operation instance.
execution_context = ExecutionContext.create(credentials)
autotag_pdf_operation = AutotagPDFOperation.create_new()

# Set operation input from a source file.
source = FileRef.create_from_local_file(input_pdf)
autotag_pdf_operation.set_input(source)

# Build AutotagPDF options and set them into the operation
# Build AutotagPDF options and set them into the operation
autotag_pdf_options: AutotagPDFOptions = AutotagPDFOptions.builder() \
.with_generate_report() \
.build()
.with_generate_report() \
.build()
autotag_pdf_operation.set_options(autotag_pdf_options)

# Execute the operation.
autotag_pdf_output: AutotagPDFOutput = autotag_pdf_operation.execute(execution_context)
# Execute the operation.
autotag_pdf_output: AutotagPDFOutput = autotag_pdf_operation.execute(execution_context)

# Save the result to the specified location.
# Save the result to the specified location.
autotag_pdf_output.get_tagged_pdf().save_as(tagged_pdf_path)
autotag_pdf_output.get_report().save_as(report_path)

print("Successfully tagged information in PDF.")
print("Successfully tagged information in PDF.")

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

## Next Steps
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 @@ -623,14 +623,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-2.0.0.tar.gz
pip hash <download_dir>/pdfservices-sdk-2.3.1.tar.gz
```

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

```
606f08f0e525a1e0ae79567c077c29dee66971d46415dbc693b95f31597690c0
08d1c40995658e380c7e5d2fec4cebfbfc22b246582719c5451ae708a28b6a09
```

###### To generate tagged PDF from the sample file
Expand Down
Loading

0 comments on commit e1db27e

Please sign in to comment.