diff --git a/gatsby-config.js b/gatsby-config.js
index 5efdd2ba3..08dda7360 100644
--- a/gatsby-config.js
+++ b/gatsby-config.js
@@ -202,88 +202,88 @@ module.exports = {
path: 'overview/pdf-services-api/howtos/webhook-notification.md'
},
{
- title: 'SDK Utilities',
- path: 'overview/pdf-services-api/howtos/sdk-utilities.md'
+ title: 'Combine PDF Files',
+ path: 'overview/pdf-services-api/howtos/combine-pdf.md'
+ },
+ {
+ title: 'Compress PDFs',
+ path: 'overview/pdf-services-api/howtos/compress-pdf.md'
},
{
title: 'Create PDF',
path: 'overview/pdf-services-api/howtos/create-pdf.md'
},
+ {
+ title: 'Delete Pages',
+ path: 'overview/pdf-services-api/howtos/delete-pages.md'
+ },
{
title: 'Export PDF',
path: 'overview/pdf-services-api/howtos/export-pdf.md'
},
{
- title: 'Combine PDF Files',
- path: 'overview/pdf-services-api/howtos/combine-pdf.md'
+ title: 'Extract PDF',
+ path: 'overview/pdf-services-api/howtos/extract-pdf.md'
},
{
- title: 'OCR PDF',
- path: 'overview/pdf-services-api/howtos/ocr-pdf.md'
+ title: 'Get PDF Properties',
+ path: 'overview/pdf-services-api/howtos/pdf-properties.md'
},
{
- title: 'Compress PDFs',
- path: 'overview/pdf-services-api/howtos/compress-pdf.md'
+ title: 'Insert Pages',
+ path: 'overview/pdf-services-api/howtos/insert-pages.md'
},
{
title: 'Linearize PDF',
path: 'overview/pdf-services-api/howtos/linearize-pdf.md'
},
{
- title: 'Protect PDF',
- path: 'overview/pdf-services-api/howtos/protect-pdf.md'
- },
- {
- title: 'Remove Protection',
- path: 'overview/pdf-services-api/howtos/remove-protection.md'
- },
- {
- title: 'Insert Pages',
- path: 'overview/pdf-services-api/howtos/insert-pages.md'
+ title: 'OCR PDF',
+ path: 'overview/pdf-services-api/howtos/ocr-pdf.md'
},
{
- title: 'Replace Pages',
- path: 'overview/pdf-services-api/howtos/replace-pages.md'
+ title: 'PDF Accessibility Auto-Tag',
+ path: 'overview/pdf-services-api/howtos/pdf-accessibility-auto-tag-pdf.md'
},
{
- title: 'Delete Pages',
- path: 'overview/pdf-services-api/howtos/delete-pages.md'
+ title: 'PDF Accessibility Checker',
+ path: 'overview/pdf-services-api/howtos/pdf-accessibility-checker-api.md'
},
{
- title: 'Reorder Pages',
- path: 'overview/pdf-services-api/howtos/reorder-pages.md'
+ title: 'PDF Electronic Seal',
+ path: 'overview/pdf-services-api/howtos/electronic-seal-api.md'
},
{
- title: 'Rotate Pages',
- path: 'overview/pdf-services-api/howtos/rotate-pages.md'
+ title: 'PDF Watermark',
+ path: 'overview/pdf-services-api/howtos/pdf-watermark-api.md'
},
{
- title: 'Split PDF',
- path: 'overview/pdf-services-api/howtos/split-pdf.md'
+ title: 'Protect PDF',
+ path: 'overview/pdf-services-api/howtos/protect-pdf.md'
},
{
- title: 'Extract PDF',
- path: 'overview/pdf-services-api/howtos/extract-pdf.md'
+ title: 'Remove Protection',
+ path: 'overview/pdf-services-api/howtos/remove-protection.md'
},
{
- title: 'Get PDF Properties',
- path: 'overview/pdf-services-api/howtos/pdf-properties.md'
+ title: 'Reorder Pages',
+ path: 'overview/pdf-services-api/howtos/reorder-pages.md'
},
{
- title: 'PDF Accessibility Auto-Tag',
- path: 'overview/pdf-services-api/howtos/pdf-accessibility-auto-tag-pdf.md'
+ title: 'Replace Pages',
+ path: 'overview/pdf-services-api/howtos/replace-pages.md'
},
{
- title: 'PDF Electronic Seal',
- path: 'overview/pdf-services-api/howtos/electronic-seal-api.md'
+ title: 'Rotate Pages',
+ path: 'overview/pdf-services-api/howtos/rotate-pages.md'
},
{
- title: 'PDF Watermark',
- path: 'overview/pdf-services-api/howtos/pdf-watermark-api.md'
+ title: 'Split PDF',
+ path: 'overview/pdf-services-api/howtos/split-pdf.md'
},
{
- title: 'PDF Accessibility Checker',
- path: 'overview/pdf-services-api/howtos/pdf-accessibility-checker-api.md'
+ title: 'SDK Utilities',
+ path: 'overview/pdf-services-api/howtos/sdk-utilities.md'
}
]
}
diff --git a/src/pages/overview/document-generation-api/quickstarts/dotnet/index.md b/src/pages/overview/document-generation-api/quickstarts/dotnet/index.md
index 7c9995a88..a18223e5b 100644
--- a/src/pages/overview/document-generation-api/quickstarts/dotnet/index.md
+++ b/src/pages/overview/document-generation-api/quickstarts/dotnet/index.md
@@ -55,7 +55,7 @@ To complete this guide, you will need:
-
+
diff --git a/src/pages/overview/document-generation-api/quickstarts/java/index.md b/src/pages/overview/document-generation-api/quickstarts/java/index.md
index d3c110f98..7cb5eaac0 100644
--- a/src/pages/overview/document-generation-api/quickstarts/java/index.md
+++ b/src/pages/overview/document-generation-api/quickstarts/java/index.md
@@ -63,7 +63,7 @@ To complete this guide, you will need:
UTF-8
11
11
- 4.1.0
+ 4.2.0
diff --git a/src/pages/overview/document-generation-api/quickstarts/python/index.md b/src/pages/overview/document-generation-api/quickstarts/python/index.md
index 9cc6f0460..19b59d21f 100644
--- a/src/pages/overview/document-generation-api/quickstarts/python/index.md
+++ b/src/pages/overview/document-generation-api/quickstarts/python/index.md
@@ -204,9 +204,30 @@ with open(output_file_path, "wb") as file:
Here's the complete application (`src/documentmerge/merge_document_to_pdf.py`):
```python
+import json
+import logging
+import os
+from datetime import datetime
+
+from adobe.pdfservices.operation.auth.service_principal_credentials import ServicePrincipalCredentials
+from adobe.pdfservices.operation.exception.exceptions import ServiceApiException, ServiceUsageException, SdkException
+from adobe.pdfservices.operation.io.cloud_asset import CloudAsset
+from adobe.pdfservices.operation.io.stream_asset import StreamAsset
+from adobe.pdfservices.operation.pdf_services import PDFServices
+from adobe.pdfservices.operation.pdf_services_media_type import PDFServicesMediaType
+from adobe.pdfservices.operation.pdfjobs.jobs.document_merge_job import DocumentMergeJob
+from adobe.pdfservices.operation.pdfjobs.params.documentmerge.document_merge_params import DocumentMergeParams
+from adobe.pdfservices.operation.pdfjobs.params.documentmerge.output_format import OutputFormat
+from adobe.pdfservices.operation.pdfjobs.result.document_merge_result import DocumentMergePDFResult
+
# Initialize the logger
logging.basicConfig(level=logging.INFO)
+# This sample illustrates how to merge the Word based document template with the input JSON data to generate
+# the output document in the PDF format.
+#
+# Refer to README.md for instructions on how to run the samples.
+
class MergeDocumentToPDF:
def __init__(self):
try:
diff --git a/src/pages/overview/document-generation-api/stylingformattingtags.md b/src/pages/overview/document-generation-api/stylingformattingtags.md
index ed0460d8c..95d2ef04d 100644
--- a/src/pages/overview/document-generation-api/stylingformattingtags.md
+++ b/src/pages/overview/document-generation-api/stylingformattingtags.md
@@ -78,9 +78,9 @@ JSON representation of the input data:
## Inline images supported attributes
-[Click here](../document-generation-api/inlineimages.md) to refer documentation on how to add Inline Images.
+You may find documentation for using inline images [here](../document-generation-api/inlineimages.md).
-Formatting for image can be provided using the attributes of the img tag.
+Formatting for images can be provided using the attributes of the img tag.
- The img tag supports the height and width attributes.
diff --git a/src/pages/overview/document-generation-api/templatetags.md b/src/pages/overview/document-generation-api/templatetags.md
index 2cef92de2..ce1e0f5b5 100644
--- a/src/pages/overview/document-generation-api/templatetags.md
+++ b/src/pages/overview/document-generation-api/templatetags.md
@@ -26,10 +26,9 @@ A placeholder(text tags) gets replaced by the actual input data.
A placeholder variable can only be applied to an input field of type
-string, number or boolean.
Formatting applied to the placeholder
-variable in the document template will be retained in the output
-document.
-For more simplified styling and formatting for the placeholder tag from the input json data, please refer [styling and formatting](../document-generation-api/stylingformattingtags.md) section:
+string, number or boolean.
Please refer to the **Arrays** section to use array as a placeholder variable.
Formatting applied to the placeholder
+variable in the document template will be retained in the output document.
+For more simplified styling and formatting for the placeholder tag from the input json data, please refer [styling and formatting](../document-generation-api/stylingformattingtags.md) section.
JSON representation of the input data:
@@ -74,6 +73,22 @@ A prefix value can be specified for the placeholder variable. Doing so will appe
this value before the result of the tag.

+
+**Arrays**
+
+To work with arrays, please refer to the [JSONata Functions](#jsonata-functions) section.
+
+JSON representation of the input data:
+
+```json
+{
+ "companyName": "Tech Corp",
+ "discountCoupons": ["SummerSale", "BlackFriday", "NewYearSpecial"]
+}
+```
+
+
+
## Images
To dynamically insert an image in the document, add any image as
@@ -447,6 +462,20 @@ Here is the list of [supported aggregation functions](https://docs.jsonata.org/a
aggregate numerical calculation can only be applied to a list of
numbers.
+## JSONata Functions
+The Document Generation API supports various JSONata functions, including:
+
+- [String Functions](https://docs.jsonata.org/string-functions)
+- [Numeric Functions](https://docs.jsonata.org/numeric-functions)
+- [Aggregation Functions](https://docs.jsonata.org/aggregation-functions)
+- [Boolean Functions](https://docs.jsonata.org/boolean-functions)
+- [Array Functions](https://docs.jsonata.org/array-functions)
+- [Date/Time Functions](https://docs.jsonata.org/date-time-functions)
+- [Higher Order Functions](https://docs.jsonata.org/higher-order-functions)
+
+
+It is recommended to test these functions before incorporating them into your template.
+
## Adobe Sign
Adobe Sign text tags can be placed anywhere within the contents of the document template.
diff --git a/src/pages/overview/images/working_with_array.png b/src/pages/overview/images/working_with_array.png
new file mode 100644
index 000000000..b86f61e7b
Binary files /dev/null and b/src/pages/overview/images/working_with_array.png differ
diff --git a/src/pages/overview/pdf-accessibility-auto-tag-api/gettingstarted.md b/src/pages/overview/pdf-accessibility-auto-tag-api/gettingstarted.md
index 06810c00a..2fcb376d4 100644
--- a/src/pages/overview/pdf-accessibility-auto-tag-api/gettingstarted.md
+++ b/src/pages/overview/pdf-accessibility-auto-tag-api/gettingstarted.md
@@ -637,7 +637,7 @@ 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 /pdfservices-sdk-4.0.0.tar.gz
+pip hash /pdfservices-sdk-4.1.0.tar.gz
```
1. Above command will return the hash of downloaded package.
diff --git a/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/dotnet/index.md b/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/dotnet/index.md
index 1350902cd..44ae89c41 100644
--- a/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/dotnet/index.md
+++ b/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/dotnet/index.md
@@ -56,7 +56,7 @@ To complete this guide, you will need:
-
+
diff --git a/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/java/index.md b/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/java/index.md
index 4f2e02813..993aa9821 100644
--- a/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/java/index.md
+++ b/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/java/index.md
@@ -63,7 +63,7 @@ To complete this guide, you will need:
UTF-8
11
11
- 4.1.0
+ 4.2.0
diff --git a/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/python/index.md b/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/python/index.md
index f679d0e77..496e6254a 100644
--- a/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/python/index.md
+++ b/src/pages/overview/pdf-accessibility-auto-tag-api/quickstarts/python/index.md
@@ -102,7 +102,7 @@ This defines what our output directory will be and optionally deletes it if it a
4) Now, let's create an asset from source file and upload.
```python
-file = open('src/resources/autotagPDFInput.pdf', 'rb')
+file = open('./autotagPDFInput.pdf', 'rb')
input_stream = file.read()
file.close()
@@ -140,19 +140,30 @@ with open(output_file_path, "wb") as file:
Here's the complete application (`autotag.py`):
```python
+import logging
+import os
+from datetime import datetime
+
+from adobe.pdfservices.operation.auth.service_principal_credentials import ServicePrincipalCredentials
+from adobe.pdfservices.operation.exception.exceptions import ServiceApiException, ServiceUsageException, SdkException
+from adobe.pdfservices.operation.io.cloud_asset import CloudAsset
+from adobe.pdfservices.operation.io.stream_asset import StreamAsset
+from adobe.pdfservices.operation.pdf_services import PDFServices
+from adobe.pdfservices.operation.pdf_services_media_type import PDFServicesMediaType
+from adobe.pdfservices.operation.pdfjobs.jobs.autotag_pdf_job import AutotagPDFJob
+from adobe.pdfservices.operation.pdfjobs.result.autotag_pdf_result import AutotagPDFResult
+
# Initialize the logger
logging.basicConfig(level=logging.INFO)
-
-#
# This sample illustrates how to generate a tagged PDF.
#
# Refer to README.md for instructions on how to run the samples.
-#
+
class AutoTagPDF:
def __init__(self):
try:
- file = open('src/resources/autotagPDFInput.pdf', 'rb')
+ file = open('./autotagPDFInput.pdf', 'rb')
input_stream = file.read()
file.close()
diff --git a/src/pages/overview/pdf-electronic-seal-api/gettingstarted.md b/src/pages/overview/pdf-electronic-seal-api/gettingstarted.md
index de1ece2fe..7784e08cb 100644
--- a/src/pages/overview/pdf-electronic-seal-api/gettingstarted.md
+++ b/src/pages/overview/pdf-electronic-seal-api/gettingstarted.md
@@ -686,7 +686,7 @@ 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 /pdfservices-sdk-4.0.0.tar.gz
+pip hash /pdfservices-sdk-4.1.0.tar.gz
```
2. Above command will return the hash of downloaded package.
diff --git a/src/pages/overview/pdf-electronic-seal-api/quickstarts/java/index.md b/src/pages/overview/pdf-electronic-seal-api/quickstarts/java/index.md
index 521585266..c2674528f 100644
--- a/src/pages/overview/pdf-electronic-seal-api/quickstarts/java/index.md
+++ b/src/pages/overview/pdf-electronic-seal-api/quickstarts/java/index.md
@@ -63,7 +63,7 @@ To complete this guide, you will need:
UTF-8
11
11
- 4.1.0
+ 4.2.0
diff --git a/src/pages/overview/pdf-electronic-seal-api/quickstarts/python/index.md b/src/pages/overview/pdf-electronic-seal-api/quickstarts/python/index.md
index 614c93cbc..01808fc16 100644
--- a/src/pages/overview/pdf-electronic-seal-api/quickstarts/python/index.md
+++ b/src/pages/overview/pdf-electronic-seal-api/quickstarts/python/index.md
@@ -205,9 +205,32 @@ with open(output_file_path, "wb") as file:
Here's the complete application (`src/electronicseal/electronic_seal.py`):
```python
+import logging
+import os
+from datetime import datetime
+
+from adobe.pdfservices.operation.auth.service_principal_credentials import ServicePrincipalCredentials
+from adobe.pdfservices.operation.exception.exceptions import ServiceApiException, ServiceUsageException, SdkException
+from adobe.pdfservices.operation.io.cloud_asset import CloudAsset
+from adobe.pdfservices.operation.io.stream_asset import StreamAsset
+from adobe.pdfservices.operation.pdf_services import PDFServices
+from adobe.pdfservices.operation.pdf_services_media_type import PDFServicesMediaType
+from adobe.pdfservices.operation.pdfjobs.jobs.eseal_job import PDFElectronicSealJob
+from adobe.pdfservices.operation.pdfjobs.params.eseal.csc_auth_context import CSCAuthContext
+from adobe.pdfservices.operation.pdfjobs.params.eseal.csc_credentials import CSCCredentials
+from adobe.pdfservices.operation.pdfjobs.params.eseal.document_level_permission import DocumentLevelPermission
+from adobe.pdfservices.operation.pdfjobs.params.eseal.electronic_seal_params import PDFElectronicSealParams
+from adobe.pdfservices.operation.pdfjobs.params.eseal.field_location import FieldLocation
+from adobe.pdfservices.operation.pdfjobs.params.eseal.field_options import FieldOptions
+from adobe.pdfservices.operation.pdfjobs.result.eseal_pdf_result import ESealPDFResult
+
# Initialize the logger
logging.basicConfig(level=logging.INFO)
+# This sample illustrates how to apply electronic seal over the PDF document using default appearance options.
+#
+# Refer to README.md for instructions on how to run the samples.
+
class ElectronicSeal:
def __init__(self):
try:
diff --git a/src/pages/overview/pdf-embed-api/howtos.md b/src/pages/overview/pdf-embed-api/howtos.md
index 21662ffec..6a1d2f38e 100644
--- a/src/pages/overview/pdf-embed-api/howtos.md
+++ b/src/pages/overview/pdf-embed-api/howtos.md
@@ -70,7 +70,7 @@ viewer.
-The timeout for file rendering is 60 seconds. If the file exceeds this limit there will be a `Preview Rendering Failed` error.
+The timeout for file rendering is 5 minutes. If the file exceeds this limit there will be a `Preview Rendering Failed` error.
## Passing file content
diff --git a/src/pages/overview/pdf-embed-api/releasenotes.md b/src/pages/overview/pdf-embed-api/releasenotes.md
index d452d8d9e..2dbe23e1a 100644
--- a/src/pages/overview/pdf-embed-api/releasenotes.md
+++ b/src/pages/overview/pdf-embed-api/releasenotes.md
@@ -8,6 +8,11 @@ the changes below for each release.
## Change history
+### August 14, 2024
+| Change | Description |
+|---------|----------------------------------------------------------------------|
+| Changed | Updated rendering timeout to five minutes to preview complex pdf files. |
+
### June 27, 2024
| Change | Description |
| ------ | ---------------------------------------------------------------------- |
diff --git a/src/pages/overview/pdf-extract-api/gettingstarted.md b/src/pages/overview/pdf-extract-api/gettingstarted.md
index 0c75aa6bb..74645d487 100644
--- a/src/pages/overview/pdf-extract-api/gettingstarted.md
+++ b/src/pages/overview/pdf-extract-api/gettingstarted.md
@@ -637,7 +637,7 @@ 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 /pdfservices-sdk-4.0.0.tar.gz
+pip hash /pdfservices-sdk-4.1.0.tar.gz
```
1. Above command will return the hash of downloaded package.
diff --git a/src/pages/overview/pdf-extract-api/quickstarts/dotnet/index.md b/src/pages/overview/pdf-extract-api/quickstarts/dotnet/index.md
index e1524fe38..ff658c9c6 100644
--- a/src/pages/overview/pdf-extract-api/quickstarts/dotnet/index.md
+++ b/src/pages/overview/pdf-extract-api/quickstarts/dotnet/index.md
@@ -55,7 +55,7 @@ To complete this guide, you will need:
-
+
diff --git a/src/pages/overview/pdf-extract-api/quickstarts/java/index.md b/src/pages/overview/pdf-extract-api/quickstarts/java/index.md
index 799228e51..7dc0398e8 100644
--- a/src/pages/overview/pdf-extract-api/quickstarts/java/index.md
+++ b/src/pages/overview/pdf-extract-api/quickstarts/java/index.md
@@ -63,7 +63,7 @@ To complete this guide, you will need:
UTF-8
11
11
- 4.1.0
+ 4.2.0
diff --git a/src/pages/overview/pdf-extract-api/quickstarts/python/index.md b/src/pages/overview/pdf-extract-api/quickstarts/python/index.md
index 7cc402dfb..f8d2f93a3 100644
--- a/src/pages/overview/pdf-extract-api/quickstarts/python/index.md
+++ b/src/pages/overview/pdf-extract-api/quickstarts/python/index.md
@@ -85,7 +85,7 @@ zip_file = "./ExtractTextInfoFromPDF.zip"
if os.path.isfile(zip_file):
os.remove(zip_file)
-input_pdf = "./Adobe Extract API Sample.pdf"
+input_pdf = "./extractPdfInput.pdf"
```
This defines what our output ZIP will be and optionally deletes it if it already exists. Then we define what PDF will be extracted. (You can download the source we used [here](/Adobe%20Extract%20API%20Sample.pdf).) In a real application, these values would be typically be dynamic.
@@ -163,19 +163,32 @@ for element in data["elements"]:
Here's the complete application (`extract.py`):
```python
+import logging
+import os
+from datetime import datetime
+
+from adobe.pdfservices.operation.auth.service_principal_credentials import ServicePrincipalCredentials
+from adobe.pdfservices.operation.exception.exceptions import ServiceApiException, ServiceUsageException, SdkException
+from adobe.pdfservices.operation.pdf_services_media_type import PDFServicesMediaType
+from adobe.pdfservices.operation.io.cloud_asset import CloudAsset
+from adobe.pdfservices.operation.io.stream_asset import StreamAsset
+from adobe.pdfservices.operation.pdf_services import PDFServices
+from adobe.pdfservices.operation.pdfjobs.jobs.extract_pdf_job import ExtractPDFJob
+from adobe.pdfservices.operation.pdfjobs.params.extract_pdf.extract_element_type import ExtractElementType
+from adobe.pdfservices.operation.pdfjobs.params.extract_pdf.extract_pdf_params import ExtractPDFParams
+from adobe.pdfservices.operation.pdfjobs.result.extract_pdf_result import ExtractPDFResult
+
# Initialize the logger
logging.basicConfig(level=logging.INFO)
-
-#
# This sample illustrates how to extract Text Information from PDF.
#
# Refer to README.md for instructions on how to run the samples & understand output zip file.
-#
+
class ExtractTextInfoFromPDF:
def __init__(self):
try:
- file = open('src/resources/extractPdfInput.pdf', 'rb')
+ file = open('./extractPdfInput.pdf', 'rb')
input_stream = file.read()
file.close()
diff --git a/src/pages/overview/pdf-services-api/gettingstarted.md b/src/pages/overview/pdf-services-api/gettingstarted.md
index 77cabc795..31b6ad519 100644
--- a/src/pages/overview/pdf-services-api/gettingstarted.md
+++ b/src/pages/overview/pdf-services-api/gettingstarted.md
@@ -636,7 +636,7 @@ 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 /pdfservices-sdk-4.0.0.tar.gz
+pip hash /pdfservices-sdk-4.1.0.tar.gz
```
2. Above command will return the hash of downloaded package.
diff --git a/src/pages/overview/pdf-services-api/howtos/index.md b/src/pages/overview/pdf-services-api/howtos/index.md
index 6a3079982..0f979b6b6 100644
--- a/src/pages/overview/pdf-services-api/howtos/index.md
+++ b/src/pages/overview/pdf-services-api/howtos/index.md
@@ -43,7 +43,7 @@ the details below, you can refer to working code samples:
- [Java](https://github.com/adobe/pdfservices-java-sdk-samples/blob/master/src/main/java/com/adobe/pdfservices/operation/samples/customconfigurations/ExportPDFWithSpecifiedRegion.java)
- [.NET](https://github.com/adobe/PDFServices.NET.SDK.Samples/blob/master/ExportPDFWithSpecifiedRegion/Program.cs)
- [Node.js](https://github.com/adobe/pdfservices-node-sdk-samples/blob/master/src/customconfigurations/export-pdf-with-specified-region.js)
-- [Python](https://github.com/adobe/pdfservices-python-sdk-samples/blob/master/src/extractpdf/extract_txt_from_pdf_with_specified_region.py)
+- [Python](https://github.com/adobe/pdfservices-python-sdk-samples/blob/main/src/customconfigurations/export_pdf_with_specified_region.py)
Available properties:
diff --git a/src/pages/overview/pdf-services-api/howtos/pdf-accessibility-checker-api.md b/src/pages/overview/pdf-services-api/howtos/pdf-accessibility-checker-api.md
index 44f64c7a5..a9fca7714 100644
--- a/src/pages/overview/pdf-services-api/howtos/pdf-accessibility-checker-api.md
+++ b/src/pages/overview/pdf-services-api/howtos/pdf-accessibility-checker-api.md
@@ -1,10 +1,6 @@
---
title: PDF Accessibility Checker | How Tos | PDF Services API | Adobe PDF Services
---
-
-
-PDF Accessibility Checker is currently accessible through the REST API only.
-
# PDF Accessibility Checker
The Accessibility Checker API verifies if PDF files meet the machine-verifiable requirements of PDF/UA and WCAG 2.0. It generates a report summarizing the findings of the accessibility checks. Additional human remediation may be required to ensure the reading order of elements is correct and that alternative text tags properly convey the meaning of images. The report contains links to documentation that assists in manually fixing problems using Adobe Acrobat Pro.
@@ -22,17 +18,605 @@ This parameter specifies the starting page for the accessibility check. If "page
### Page end (_pageEnd_)
This parameter specifies the ending page for the accessibility check. If "pageEnd" is not provided, the last page is considered the default end page. It should be greater than or equal to 1.
+
## REST API
See our public API Reference for the [PDF Accessibility Checker API](../../../apis/#tag/PDF-Accessibility-Checker).
+## Check accessibility for input PDF
+
+The sample below performs an accessibility check operation on a given PDF.
+
+Please refer to the [API usage guide](../gettingstarted.md) to understand how to use our APIs.
+
+
+
+#### Java
+
+```javascript
+// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
+// Run the sample:
+// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.pdfaccessibilitychecker.PDFAccessibilityChecker
+public class PDFAccessibilityChecker {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PDFAccessibilityChecker.class);
+
+ public static void main(String[] args) {
+
+ try (
+ InputStream inputStream = Files
+ .newInputStream(new File("src/main/resources/accessibilityCheckerInput.pdf")
+ .toPath())) {
+ // Initial setup, create credentials instance
+ Credentials credentials = new ServicePrincipalCredentials(System.getenv("PDF_SERVICES_CLIENT_ID"),
+ System.getenv("PDF_SERVICES_CLIENT_SECRET"));
+
+ // Creates a PDF Services instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Creates an asset(s) from source file(s) and upload
+ Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
+
+ // Creates a new job instance
+ PDFAccessibilityCheckerJob pdfAccessibilityCheckerJob = new PDFAccessibilityCheckerJob(asset);
+
+ // Submit the job and gets the job result
+ String location = pdfServices.submit(PDFAccessibilityCheckerJob);
+ PDFServicesResponse pdfServicesResponse = pdfServices
+ .getJobResult(location, PDFAccessibilityCheckerResult.class);
+
+ // Get content from the resulting asset(s)
+ Asset resultAsset = pdfServicesResponse.getResult().getAsset();
+ StreamAsset streamAsset = pdfServices.getContent(resultAsset);
+
+ Asset report = pdfServicesResponse.getResult().getReport();
+ StreamAsset streamAssetReport = pdfServices.getContent(report);
+
+ String outputFilePath = "/output/pdfAccessibilityCheckerOutput.pdf";
+ String outputFilePathReport = "/output/pdfAccessibilityCheckerReport.json";
+
+ LOGGER.info(String.format("Saving asset at %s", outputFilePath));
+ LOGGER.info(String.format("Saving report at %s", outputFilePathReport));
+
+ new FileInfo(Directory.GetCurrentDirectory() + outputFilePath).Directory.Create();
+ new FileInfo(Directory.GetCurrentDirectory() + outputFilePathReport).Directory.Create();
+
+ OutputStream outputStreamReport = Files.newOutputStream(new File(outputFilePath).toPath());
+ OutputStream outputStreamReport = Files.newOutputStream(new File(outputFilePathReport).toPath());
+
+ IOUtils.copy(streamAsset.getInputStream(), outputStream);
+ IOUtils.copy(streamAssetReport.getInputStream(), outputStreamReport);
+
+ outputStream.close();
+ outputStreamReport.close();
+ } catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
+ System.out.println("Exception encountered while executing operation: "+ ex);
+ }
+ }
+}
+```
+
+#### .NET
+
+```javascript
+// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples
+// Run the sample:
+// cd PDFAccessibilityChecker/
+// dotnet run PDFAccessibilityChecker.csproj
+namespace PDFAccessibilityChecker
+{
+ public class Program {
+ private static readonly ILog log = LogManager.GetLogger(typeof (Program));
+
+ static void Main() {
+ //Configure the logging
+ ConfigureLogging();
+ try {
+ // Initial setup, create credentials instance
+ ICredentials credentials = new ServicePrincipalCredentials(
+ Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_ID"),
+ Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_SECRET"));
+
+ // Creates a PDF Services instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Creates an asset(s) from source file(s) and upload
+ using Stream inputStream = File.OpenRead(@"checkerPDFInput.pdf");
+ IAsset inputDocumentAsset = pdfServices.Upload(inputStream, PDFServicesMediaType.PDF.GetMIMETypeValue());
+
+ // Create the PDF Accessibility Checker job instance
+ PDFAccessibilityCheckerJob pdfAccessibilityCheckerJob = new PDFAccessibilityCheckerJob(inputDocumentAsset);
+
+ // Submits the job and gets the job result
+ String location = pdfServices.Submit(pdfAccessibilityCheckerJob);
+ PDFServicesResponse pdfServicesResponse =
+ pdfServices.GetJobResult (location, typeof (PDFAccessibilityCheckerResult));
+
+ // Get content from the resulting asset(s)
+ IAsset outputAsset = pdfServicesResponse.Result.Asset;
+ StreamAsset streamAsset = pdfServices.GetContent(outputAsset);
+
+ IAsset outputReportAsset = pdfServicesResponse.Result.Report;
+ StreamAsset streamReportAsset = pdfServices.GetContent(outputReportAsset);
+
+ // Creating output streams and copying stream asset's content to it
+ String outputPdfPath = '/output/accessibilityChecker.pdf';
+ new FileInfo(Directory.GetCurrentDirectory() + outputPdfPath).Directory.Create();
+ Stream outputStream = File.OpenWrite(Directory.GetCurrentDirectory() + outputPdfPath);
+ streamAsset.Stream.CopyTo(outputStream);
+ outputStream.Close();
+
+ String outputJSONPath = '/output/accessibilityChecker.json';
+ new FileInfo(Directory.GetCurrentDirectory() + outputJSONPath).Directory.Create();
+ Stream outputJSONStream = File.OpenWrite(Directory.GetCurrentDirectory() + outputJSONPath);
+ streamReportAsset.Stream.CopyTo(outputJSONStream);
+ outputStream.Close();
+ } catch (ServiceUsageException ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ } catch (ServiceApiException ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ } catch (SDKException ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ } catch (IOException ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ } catch (Exception ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ }
+
+ static void ConfigureLogging() {
+ ILoggerRepository
+ logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
+ XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
+ }
+ }
+}
+```
+
+#### Node JS
+
+```javascript
+// Get the samples from https://github.com/adobe/pdfservices-node-sdk-samples
+// Run the sample:
+// node src/pdfaccessibilitychecker/pdf-accessibility-checker.js
+const {
+ ServicePrincipalCredentials,
+ PDFServices,
+ MimeType,
+ SDKError,
+ ServiceUsageError,
+ ServiceApiError,
+ PDFAccessibilityCheckerJob,
+ PDFAccessibilityCheckerResult
+} = require("@adobe/pdfservices-node-sdk");
+const fs = require("fs");
+
+(async () => {
+ let readStream;
+ try {
+ // Initial setup, create credentials instance
+ const credentials = new ServicePrincipalCredentials({
+ clientId: process.env.PDF_SERVICES_CLIENT_ID,
+ clientSecret: process.env.PDF_SERVICES_CLIENT_SECRET
+ });
+
+ // Creates a PDF Services instance
+ const pdfServices = new PDFServices({credentials});
+
+ // Creates an asset(s) from source file(s) and upload
+ readStream = fs.createReadStream("resources/accessibilityCheckerInput.pdf");
+ const inputAsset = await pdfServices.upload({
+ readStream,
+ mimeType: MimeType.PDF
+ });
+
+ // Create a new job instance
+ const job = new PDFAccessibilityCheckerJob({inputAsset});
+
+ // Submit the job and get the job result
+ const pollingURL = await pdfServices.submit({job});
+ const pdfServicesResponse = await pdfServices.getJobResult({
+ pollingURL,
+ resultType: PDFAccessibilityCheckerResult
+ });
+
+ // Get content from the resulting asset(s)
+ const resultAsset = pdfServicesResponse.result.asset;
+ const streamAsset = await pdfServices.getContent({asset: resultAsset});
+
+ const resultAssetReport = pdfServicesResponse.result.report;
+ const streamAssetReport = await pdfServices.getContent({asset: resultAssetReport});
+
+ // Creates an output stream and copy result asset's content to it
+ const outputFilePath = "output/PDFAccessibilityChecker.pdf"
+ const outputFilePathReport = "output/PDFAccessibilityChecker.json"
+ console.log(`Saving asset at ${outputFilePath}`);
+ console.log(`Saving asset at ${outputFilePathReport}`);
+
+ let writeStream = fs.createWriteStream(outputFilePath);
+ streamAsset.readStream.pipe(writeStream);
+ writeStream = fs.createWriteStream(outputFilePathReport);
+ streamAssetReport.readStream.pipe(writeStream);
+ } catch (err) {
+ if (err instanceof SDKError || err instanceof ServiceUsageError || err instanceof ServiceApiError) {
+ console.log("Exception encountered while executing operation", err);
+ } else {
+ console.log("Exception encountered while executing operation", err);
+ }
+ } finally {
+ readStream?.destroy();
+ }
+})();
+```
+
+#### Python
+
+```javascript
+# Get the samples from https://github.com/adobe/pdfservices-python-sdk-samples
+# Run the sample:
+# python src/PDFAccessibilityChecker/pdf_accessibility_checker.py
+
+class PDFAccessibilityChecker:
+ def __init__(self):
+ try:
+ pdf_file = open("src/resources/CheckerPDFInput.pdf", 'rb')
+ input_stream = pdf_file.read()
+ pdf_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
+ pdf_accessibility_checker_job = PDFAccessibilityCheckerJob(input_asset=input_asset)
+
+ # Submit the job and gets the job result
+ location = pdf_services.submit(pdf_accessibility_checker_job)
+ pdf_services_response = pdf_services.get_job_result(location, PDFAccessibilityCheckerResult)
+
+ # Get content from the resulting asset(s)
+ result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
+ stream_asset: StreamAsset = pdf_services.get_content(result_asset)
+
+ report_asset: CloudAsset = pdf_services_response.get_result().get_report()
+ stream_report: StreamAsset = pdf_services.get_content(report_asset)
+
+ output_file_path = 'output/accessibilitychecker.pdf'
+ with open(output_file_path, "wb") as file:
+ file.write(stream_asset.get_input_stream())
+
+ output_file_path_json = 'output/accessibilitychecker.json'
+ with open(output_file_path_json, "wb") as file:
+ file.write(stream_report.get_input_stream())
+
+ except (ServiceApiException, ServiceUsageException, SdkException) as e:
+ logging.exception(f'Exception encountered while executing operation: {e}')
+
+
+ if __name__ == "__main__":
+ PDFAccessibilityChecker()
+```
+
+#### REST API
+
+```javascript
+curl --location --request POST 'https://pdf-services.adobe.io/operation/accessibilitychecker' \
+--header 'x-api-key: {{Placeholder for client_id}}' \
+--header 'Content-Type: application/json' \
+--header 'Authorization: Bearer {{Placeholder for token}}' \
+--data-raw '{
+ "assetID": "urn:aaid:AS:UE1:54cbf87f-d7f5-4918-8e4b-9f1878678e68"
+}'
+```
+
+
## Check accessibility for specified pages
The sample below performs an accessibility check operation for specified pages of a given PDF.
Please refer to the [API usage guide](../gettingstarted.md) to understand how to use our APIs.
-
+
+
+#### Java
+
+```javascript
+// Get the samples from https://www.adobe.com/go/pdftoolsapi_java_samples
+// Run the sample:
+// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.pdfaccessibilitychecker.PDFAccessibilityCheckerWithOptions
+public class PDFAccessibilityCheckerWithOptions {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PDFAccessibilityCheckerWithOptions.class);
+
+ public static void main(String[] args) {
+
+ try (
+ InputStream inputStream = Files
+ .newInputStream(new File("src/main/resources/accessibilityCheckerInput.pdf")
+ .toPath())) {
+ // Initial setup, create credentials instance
+ Credentials credentials = new ServicePrincipalCredentials(System.getenv("PDF_SERVICES_CLIENT_ID"),
+ System.getenv("PDF_SERVICES_CLIENT_SECRET"));
+
+ // Creates a PDF Services instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Creates an asset(s) from source file(s) and upload
+ Asset asset = pdfServices.upload(inputStream, PDFServicesMediaType.PDF.getMediaType());
+
+ // Creates parameters for the job
+ PDFAccessibilityCheckerParams pdfAccessibilityCheckerParams = PDFAccessibilityCheckerParams
+ .pdfAccessibilityCheckerParamsBuilder().withPageStart(1).withPageEnd(5).build();
+
+ // Creates a new job instance
+ PDFAccessibilityCheckerJob pdfAccessibilityCheckerJob = new PDFAccessibilityCheckerJob(asset)
+ .setParams(pdfAccessibilityCheckerParams);
+
+ // Submit the job and gets the job result
+ String location = pdfServices.submit(PDFAccessibilityCheckerJob);
+ PDFServicesResponse pdfServicesResponse = pdfServices
+ .getJobResult(location, PDFAccessibilityCheckerResult.class);
+
+ // Get content from the resulting asset(s)
+ Asset resultAsset = pdfServicesResponse.getResult().getAsset();
+ StreamAsset streamAsset = pdfServices.getContent(resultAsset);
+
+ Asset report = pdfServicesResponse.getResult().getReport();
+ StreamAsset streamAssetReport = pdfServices.getContent(report);
+
+ String outputFilePath = "/output/pdfAccessibilityCheckerOutput.pdf";
+ String outputFilePathReport = "/output/pdfAccessibilityCheckerReport.json";
+
+ LOGGER.info(String.format("Saving asset at %s", outputFilePath));
+ LOGGER.info(String.format("Saving report at %s", outputFilePathReport));
+
+ new FileInfo(Directory.GetCurrentDirectory() + outputFilePath).Directory.Create();
+ new FileInfo(Directory.GetCurrentDirectory() + outputFilePathReport).Directory.Create();
+
+ OutputStream outputStreamReport = Files.newOutputStream(new File(outputFilePath).toPath());
+ OutputStream outputStreamReport = Files.newOutputStream(new File(outputFilePathReport).toPath());
+
+ IOUtils.copy(streamAsset.getInputStream(), outputStream);
+ IOUtils.copy(streamAssetReport.getInputStream(), outputStreamReport);
+
+ outputStream.close();
+ outputStreamReport.close();
+ } catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
+ System.out.println("Exception encountered while executing operation: "+ ex);
+ }
+ }
+}
+```
+
+#### .NET
+
+```javascript
+// Get the samples from https://www.adobe.com/go/pdftoolsapi_net_samples
+// Run the sample:
+// cd PDFAccessibilityCheckerWithOptions/
+// dotnet run PDFAccessibilityCheckerWithOptions.csproj
+namespace PDFAccessibilityCheckerWithOptions
+{
+ public class Program {
+ private static readonly ILog log = LogManager.GetLogger(typeof (Program));
+
+ static void Main() {
+ //Configure the logging
+ ConfigureLogging();
+ try {
+ // Initial setup, create credentials instance
+ ICredentials credentials = new ServicePrincipalCredentials(
+ Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_ID"),
+ Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_SECRET"));
+
+ // Creates a PDF Services instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Creates an asset(s) from source file(s) and upload
+ using Stream inputStream = File.OpenRead(@"checkerPDFInput.pdf");
+ IAsset inputDocumentAsset = pdfServices.Upload(inputStream, PDFServicesMediaType.PDF.GetMIMETypeValue());
+
+ // Set up PDF Accessibility Checker parameters
+ PDFAccessibilityCheckerParams pdfAccessibilityCheckerParams = PDFAccessibilityCheckerParams
+ .PDFAccessibilityCheckerParamsBuilder()
+ .WithPageStart(1)
+ .WithPageEnd(5)
+ .Build();
+
+ // Create the PDF Accessibility Checker job instance
+ PDFAccessibilityCheckerJob pdfAccessibilityCheckerJob =
+ new PDFAccessibilityCheckerJob(inputDocumentAsset).SetParams(pdfAccessibilityCheckerParams);
+
+ // Submits the job and gets the job result
+ String location = pdfServices.Submit(pdfAccessibilityCheckerJob);
+ PDFServicesResponse pdfServicesResponse =
+ pdfServices.GetJobResult (location, typeof (PDFAccessibilityCheckerResult));
+
+ // Get content from the resulting asset(s)
+ IAsset outputAsset = pdfServicesResponse.Result.Asset;
+ StreamAsset streamAsset = pdfServices.GetContent(outputAsset);
+
+ IAsset outputReportAsset = pdfServicesResponse.Result.Report;
+ StreamAsset streamReportAsset = pdfServices.GetContent(outputReportAsset);
+
+ // Creating output streams and copying stream asset's content to it
+ String outputPdfPath = '/output/accessibilityChecker.pdf';
+ new FileInfo(Directory.GetCurrentDirectory() + outputPdfPath).Directory.Create();
+ Stream outputStream = File.OpenWrite(Directory.GetCurrentDirectory() + outputPdfPath);
+ streamAsset.Stream.CopyTo(outputStream);
+ outputStream.Close();
+
+ String outputJSONPath = '/output/accessibilityChecker.json';
+ new FileInfo(Directory.GetCurrentDirectory() + outputJSONPath).Directory.Create();
+ Stream outputJSONStream = File.OpenWrite(Directory.GetCurrentDirectory() + outputJSONPath);
+ streamReportAsset.Stream.CopyTo(outputJSONStream);
+ outputStream.Close();
+ } catch (ServiceUsageException ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ } catch (ServiceApiException ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ } catch (SDKException ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ } catch (IOException ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ } catch (Exception ex) {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ }
+
+ static void ConfigureLogging() {
+ ILoggerRepository
+ logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
+ XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
+ }
+ }
+}
+```
+
+#### Node JS
+
+```javascript
+// Get the samples from https://github.com/adobe/pdfservices-node-sdk-samples
+// Run the sample:
+// node src/pdfaccessibilitychecker/pdf-accessibility-checker-with-options.js
+const {
+ ServicePrincipalCredentials,
+ PDFServices,
+ MimeType,
+ SDKError,
+ ServiceUsageError,
+ ServiceApiError,
+ PDFAccessibilityCheckerJob,
+ PDFAccessibilityCheckerResult
+} = require("@adobe/pdfservices-node-sdk");
+const fs = require("fs");
+
+(async () => {
+ let readStream;
+ try {
+ // Initial setup, create credentials instance
+ const credentials = new ServicePrincipalCredentials({
+ clientId: process.env.PDF_SERVICES_CLIENT_ID,
+ clientSecret: process.env.PDF_SERVICES_CLIENT_SECRET
+ });
+
+ // Creates a PDF Services instance
+ const pdfServices = new PDFServices({credentials});
+
+ // Creates an asset(s) from source file(s) and upload
+ readStream = fs.createReadStream("resources/accessibilityCheckerInput.pdf");
+ const inputAsset = await pdfServices.upload({
+ readStream,
+ mimeType: MimeType.PDF
+ });
+
+ // Create parameters for the job
+ const params = new PDFAccessibilityCheckerParams({pageStart:1, pageEnd:5});
+
+ // Create a new job instance
+ const job = new PDFAccessibilityCheckerJob({inputAsset, params});
+
+ // Submit the job and get the job result
+ const pollingURL = await pdfServices.submit({job});
+ const pdfServicesResponse = await pdfServices.getJobResult({
+ pollingURL,
+ resultType: PDFAccessibilityCheckerResult
+ });
+
+ // Get content from the resulting asset(s)
+ const resultAsset = pdfServicesResponse.result.asset;
+ const streamAsset = await pdfServices.getContent({asset: resultAsset});
+
+ const resultAssetReport = pdfServicesResponse.result.report;
+ const streamAssetReport = await pdfServices.getContent({asset: resultAssetReport});
+
+ // Creates an output stream and copy result asset's content to it
+ const outputFilePath = "output/PDFAccessibilityChecker.pdf"
+ const outputFilePathReport = "output/PDFAccessibilityChecker.json"
+ console.log(`Saving asset at ${outputFilePath}`);
+ console.log(`Saving asset at ${outputFilePathReport}`);
+
+ let writeStream = fs.createWriteStream(outputFilePath);
+ streamAsset.readStream.pipe(writeStream);
+ writeStream = fs.createWriteStream(outputFilePathReport);
+ streamAssetReport.readStream.pipe(writeStream);
+ } catch (err) {
+ if (err instanceof SDKError || err instanceof ServiceUsageError || err instanceof ServiceApiError) {
+ console.log("Exception encountered while executing operation", err);
+ } else {
+ console.log("Exception encountered while executing operation", err);
+ }
+ } finally {
+ readStream?.destroy();
+ }
+})();
+```
+
+#### Python
+
+```javascript
+# Get the samples from https://github.com/adobe/pdfservices-python-sdk-samples
+# Run the sample:
+# python src/PDFAccessibilityChecker/pdf_accessibility_checker.py
+
+class PDFAccessibilityChecker:
+ def __init__(self):
+ try:
+ pdf_file = open("src/resources/CheckerPDFInput.pdf", 'rb')
+ input_stream = pdf_file.read()
+ pdf_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)
+
+ # Create parameters for the job
+ pdf_accessibility_checker_params = PDFAccessibilityCheckerParams(page_start=1, page_end=5)
+
+ # Creates a new job instance
+ pdf_accessibility_checker_job = PDFAccessibilityCheckerJob(input_asset=input_asset,
+ pdf_accessibility_checker_params=pdf_accessibility_checker_params)
+
+ # Submit the job and gets the job result
+ location = pdf_services.submit(pdf_accessibility_checker_job)
+ pdf_services_response = pdf_services.get_job_result(location, PDFAccessibilityCheckerResult)
+
+ # Get content from the resulting asset(s)
+ result_asset: CloudAsset = pdf_services_response.get_result().get_asset()
+ stream_asset: StreamAsset = pdf_services.get_content(result_asset)
+
+ report_asset: CloudAsset = pdf_services_response.get_result().get_report()
+ stream_report: StreamAsset = pdf_services.get_content(report_asset)
+
+ output_file_path = 'output/accessibilitychecker.pdf'
+ with open(output_file_path, "wb") as file:
+ file.write(stream_asset.get_input_stream())
+
+ output_file_path_json = 'output/accessibilitychecker.json'
+ with open(output_file_path_json, "wb") as file:
+ file.write(stream_report.get_input_stream())
+
+ except (ServiceApiException, ServiceUsageException, SdkException) as e:
+ logging.exception(f'Exception encountered while executing operation: {e}')
+
+
+ if __name__ == "__main__":
+ PDFAccessibilityChecker()
+```
#### REST API
@@ -46,4 +630,4 @@ curl --location --request POST 'https://pdf-services.adobe.io/operation/accessib
"pageStart":1,
"pageEnd":5
}'
-```
\ No newline at end of file
+```
diff --git a/src/pages/overview/pdf-services-api/howtos/pdf-watermark-api.md b/src/pages/overview/pdf-services-api/howtos/pdf-watermark-api.md
index 17e9a87a5..e917e4f4a 100644
--- a/src/pages/overview/pdf-services-api/howtos/pdf-watermark-api.md
+++ b/src/pages/overview/pdf-services-api/howtos/pdf-watermark-api.md
@@ -1,14 +1,11 @@
---
title: PDF Watermark | How Tos | PDF Services API | Adobe PDF Services
---
-
-
-PDF Watermark is currently accessible through the REST API only.
# PDF Watermark
A watermark in a document is usually semi-transparent or faded text, a logo, or a pattern placed in the background or foreground of the page for security, authenticity, and branding.
-PDF Watermark API is a cloud based solution to apply watermark on specified pages of PDF document using a source watermark PDF. The first page of source watermark PDF will be added as a watermark in input PDF document. If a page range is not specified, the watermark will be applied on all pages of the source document.
+PDF Watermark API is a cloud based solution to apply watermark on specified pages of PDF document using a source watermark PDF. The first page of the source watermark PDF will be added as a watermark in the input PDF document. If a page range is not specified, the watermark will be applied on all pages of the source document.

@@ -25,31 +22,685 @@ A PDF document to which a watermark will be applied.
A PDF document whose first page will be used as a watermark for the input document.
The output generated will retain the content along with the watermark from the first page.
+Note: If the watermark document is a scanned PDF, placing the watermark in the foreground may make the content of the input PDF unreadable.
+Place watermarks from scanned PDF files in the background by setting appearOnForeground to false.
+
+
## Watermark Parameters
### Page ranges (_pageRanges_)
Specifies the number of pages on which the watermark will be applied. Page numbers are indexed from 1 to N. If a page range is not specified, the watermark will be applied on all pages of the source document.
The page ranges are specified as an array of objects whose length cannot exceed beyond 20. Each object has the following properties:
-* **Start Page** (*start*) : The first page number of the range. Default value is 1.
-* **End Page** (*end*) : The last page number of the range. Default value is the last page of the document.
+
+* **Start Page** (_start_) : The first page number of the range. Default value is 1.
+* **End Page** (_end_) : The last page number of the range. Default value is the last page of the document.
### Appearance (_appearance_)
-* **Foreground** (*appearOnForeground*) : Specifies the placement of the watermark on the page. It can appear in the foreground or background. The default value is true, placing the watermark in the foreground.
-* **Opacity** (*opacity*) : Specifies the opacity of the watermark, represented as an integer percentage value ranging from 0 to 100. The default value is 100.
+* **Foreground** (_appearOnForeground_) : Specifies the placement of the watermark on the page. It can appear in the foreground or background. The default value is true, placing the watermark in the foreground.
+* **Opacity** (_opacity_) : Specifies the opacity of the watermark, represented as an integer percentage value ranging from 0 to 100. The default value is 100.
## REST API
See our public API Reference for [PDF Watermark API](../../../apis/#tag/PDF-Watermark).
+## Apply Watermark on Input PDF
+
+The sample below performs watermark operation applying watermark in foreground on all pages of a given PDF.
+
+Please refer to the [API usage guide](../api-usage.md) to understand how to use our APIs.
+
+
+
+#### Java
+
+```javascript
+// Get the samples from https://github.com/adobe/pdfservices-java-sdk-samples
+// Run the sample:
+// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.pdfwatermark.PDFWatermark
+
+package com.adobe.pdfservices.operation.samples.pdfwatermark;
+
+public class PDFWatermark {
+
+ // Initialize the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(PDFWatermark.class);
+
+ public static void main(String[] args) {
+
+ try (
+ InputStream sourceFileInputStream = Files.newInputStream(new File("src/main/resources/pdfWatermarkInput.pdf").toPath());
+ InputStream watermarkFileInputStream = Files.newInputStream(new File("src/main/resources/watermark.pdf").toPath())) {
+
+ // Initial setup, create credentials instance
+ Credentials credentials = new ServicePrincipalCredentials(System.getenv("PDF_SERVICES_CLIENT_ID"), System.getenv("PDF_SERVICES_CLIENT_SECRET"));
+
+ // Creates a PDF Services instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Creates an asset(s) from source file(s) and upload
+ Asset inputDocumentAsset = pdfServices.upload(sourceFileInputStream, PDFServicesMediaType.PDF.getMediaType());
+ Asset watermarkDocumentAsset = pdfServices.upload(watermarkFileInputStream, PDFServicesMediaType.PDF.getMediaType());
+
+ // Creates a new job instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Creates a new job instance
+ PDFWatermarkJob pdfWatermarkJob = new PDFWatermarkJob(inputDocumentAsset, watermarkDocumentAsset);
+
+ // Submit the job and gets the job result
+ String location = pdfServices.submit(pdfWatermarkJob);
+ PDFServicesResponse pdfServicesResponse = pdfServices.getJobResult(location, PDFWatermarkResult.class);
+
+ // Get content from the resulting asset(s)
+ Asset resultAsset = pdfServicesResponse.getResult().getAsset();
+ StreamAsset streamAsset = pdfServices.getContent(resultAsset);
+
+ // Creates an output stream and copy stream asset's content to it
+ Files.createDirectories(Paths.get("output/"));
+ OutputStream outputStream = Files.newOutputStream(new File("output/pdfWatermarkWithOptionsOutput.pdf").toPath());
+ LOGGER.info("Saving asset at output/pdfWatermarkWithOptionsOutput.pdf");
+ IOUtils.copy(streamAsset.getInputStream(), outputStream);
+ outputStream.close();
+ } catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
+ LOGGER.error("Exception encountered while executing operation", ex);
+ }
+ }
+}
+```
+
+#### .NET
+
+```javascript
+// Get the samples from https://github.com/adobe/PDFServices.NET.SDK.Samples
+// Run the sample:
+// cd PDFWatermark/
+// dotnet run PDFWatermark.csproj
+
+namespace PDFWatermark
+{
+ class Program
+ {
+ // Initialize the logger.
+ private static readonly ILog log = LogManager.GetLogger(typeof(Program));
+
+ static void Main()
+ {
+ //Configure the logging
+ ConfigureLogging();
+
+ try
+ {
+ // Initial setup, create credentials instance
+ ICredentials credentials = new ServicePrincipalCredentials(
+ Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_ID"),
+ Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_SECRET"));
+
+ // Creates a PDF Services instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Creates an asset(s) from source file(s) and upload
+ Stream sourceFileInputStream = File.OpenRead(@"pdfWatermarkInput.pdf");
+ IAsset inputDocumentAsset = pdfServices.Upload(sourceFileInputStream, PDFServicesMediaType.PDF.GetMIMETypeValue());
+
+ // Creates a watermark asset from source file(s) and upload
+ Stream watermarkFileInputStream = File.OpenRead(@"watermark.pdf");
+ IAsset watermarkDocumentAsset = pdfServices.Upload(watermarkFileInputStream, PDFServicesMediaType.PDF.GetMIMETypeValue());
+
+ // Submits the job and gets the job result
+ PDFWatermarkJob pdfWatermarkJob = new PDFWatermarkJob(inputDocumentAsset, watermarkDocumentAsset);
+ String location = pdfServices.Submit(pdfWatermarkJob);
+
+ // Get content from the resulting asset(s)
+ PDFServicesResponse pdfServicesResponse =
+ pdfServices.GetJobResult(location, typeof(PDFWatermarkResult));
+
+ // Creating output streams and copying stream asset's content to it
+ IAsset resultAsset = pdfServicesResponse.Result.Asset;
+ StreamAsset streamAsset = pdfServices.GetContent(resultAsset);
+
+ // Creating output streams and copying stream asset's content to it
+ String outputFilePath = "/output/pdfWatermarkWithOptionsOutput.pdf";
+ new FileInfo(Directory.GetCurrentDirectory() + outputFilePath).Directory.Create();
+ Stream outputStream = File.OpenWrite(Directory.GetCurrentDirectory() + outputFilePath);
+ streamAsset.Stream.CopyTo(outputStream);
+ outputStream.Close();
+ }
+ catch (ServiceUsageException ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ catch (ServiceApiException ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ catch (SDKException ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ catch (IOException ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ catch (Exception ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ }
+
+ static void ConfigureLogging()
+ {
+ ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
+ XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
+ }
+ }
+}
+```
+
+#### Node JS
+
+```javascript
+// Get the samples from https://github.com/adobe/pdfservices-node-sdk-samples
+// Run the sample:
+// node src/pdfwatermark/pdf-watermark.js
+
+const {
+ ServicePrincipalCredentials,
+ PDFServices,
+ MimeType,
+ PDFWatermarkJob,
+ PDFWatermarkResult,
+ SDKError,
+ ServiceUsageError,
+ ServiceApiError,
+} = require("@adobe/pdfservices-node-sdk");
+const fs = require("fs");
+
+(async () => {
+ let sourceFileReadStream;
+ let watermarkFileReadStream;
+ try {
+ // Initial setup, create credentials instance
+ const credentials = new ServicePrincipalCredentials({
+ clientId: process.env.PDF_SERVICES_CLIENT_ID,
+ clientSecret: process.env.PDF_SERVICES_CLIENT_SECRET
+ });
+
+ // Creates a PDF Services instance
+ const pdfServices = new PDFServices({credentials});
+
+ // Creates an asset(s) from source file(s) and upload
+ sourceFileReadStream = fs.createReadStream("resources/watermarkPDFInput.pdf");
+ watermarkFileReadStream = fs.createReadStream("resources/watermark.pdf");
+
+ const [inputAsset, watermarkAsset] = await pdfServices.uploadAssets({
+ streamAssets: [{
+ readStream: sourceFileReadStream,
+ mimeType: MimeType.PDF
+ }, {
+ readStream: waterMarkReadStream,
+ mimeType: MimeType.PDF
+ }]
+ });
+
+ // Creates a new job instance
+ const job = new PDFWatermarkJob({
+ inputAsset: inputAsset,
+ watermarkAsset: watermarkAsset
+ });
+
+ // Submit the job and get the job result
+ const pollingURL = await pdfServices.submit({job});
+ const pdfServicesResponse = await pdfServices.getJobResult({
+ pollingURL,
+ resultType: PDFWatermarkResult
+ });
+
+ // Get content from the resulting asset(s)
+ const resultAsset = pdfServicesResponse.result.asset;
+ const streamAsset = await pdfServices.getContent({asset: resultAsset});
+
+ // Creates a write stream and copy stream asset's content to it
+ const outputFilePath = "./pdfWatermarkOutput.pdf";
+ console.log(`Saving asset at ${outputFilePath}`);
+
+ const writeStream = fs.createWriteStream(outputFilePath);
+ streamAsset.readStream.pipe(writeStream);
+ } catch (err) {
+ if (err instanceof SDKError || err instanceof ServiceUsageError || err instanceof ServiceApiError) {
+ console.log("Exception encountered while executing operation", err);
+ } else {
+ console.log("Exception encountered while executing operation", err);
+ }
+ } finally {
+ sourceFileReadStream?.destroy();
+ watermarkFileReadStream?.destroy();
+ }
+})();
+```
+
+#### Python
+
+```javascript
+# Get the samples from https://github.com/adobe/pdfservices-python-sdk-samples
+# Run the sample:
+# python src/pdfwatermark/watermark_pdf.py
+
+# Initialize the logger
+logging.basicConfig(level=logging.INFO)
+
+class PDFWatermark:
+ def __init__(self):
+ try:
+ pdf_file = open("src/resources/watermarkPDFInput.pdf", 'rb')
+ source_file_input_stream = pdf_file.read()
+ pdf_file.close()
+
+ pdf_file = open("src/resources/watermark.pdf", 'rb')
+ watermark_file_input_stream = pdf_file.read()
+ pdf_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=source_file_input_stream, mime_type=PDFServicesMediaType.PDF)
+ watermark_asset = pdf_services.upload(input_stream=watermark_file_input_stream, mime_type=PDFServicesMediaType.PDF)
+
+ # Creates a new job instance
+ pdf_watermark_job = PDFWatermarkJob(input_asset=input_asset, watermark_asset=watermark_asset)
+
+ # Submit the job and gets the job result
+ location = pdf_services.submit(pdf_watermark_job)
+ pdf_services_response = pdf_services.get_job_result(location, PDFWatermarkResult)
+
+ # Get content from the resulting asset(s)
+ pdf_watermark_result: CloudAsset = pdf_services_response.get_result().get_asset()
+ stream_asset: StreamAsset = pdf_services.get_content(pdf_watermark_result)
+
+ # Creates an output stream and copy stream asset's content to it
+ output_file_path = 'output/pdfWatermark.pdf'
+ 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}')
+
+ if __name__ == "__main__":
+ PDFWatermark()
+```
+
+#### REST API
+
+```javascript
+curl --location --request POST 'https://pdf-services.adobe.io/operation/addwatermark' \
+--header 'x-api-key: {{Placeholder for client_id}}' \
+--header 'Content-Type: application/json' \
+--header 'Authorization: Bearer {{Placeholder for token}}' \
+--data-raw '{
+ "inputDocumentAssetID": "urn:aaid:AS:UE1:54cbf87f-d7f5-4918-8e4b-9f68",
+ "watermarkDocumentAssetID": "urn:aaid:AS:UE1:54cbf87f-d7f5-4918-8e4b-9f1878678e68"
+}'
+```
+
## Apply Watermark on specified pages
The sample below performs watermark operation applying watermark in foreground on specified pages of a given PDF.
-Please refer the [API usage guide](../gettingstarted.md) to understand how to use our APIs.
+Please refer to the [API usage guide](../api-usage.md) to understand how to use our APIs.
+
+
+
+#### Java
+
+```javascript
+// Get the samples from https://github.com/adobe/pdfservices-java-sdk-samples
+// Run the sample:
+// mvn -f pom.xml exec:java -Dexec.mainClass=com.adobe.pdfservices.operation.samples.pdfwatermark.PDFWatermarkWithOptions
+
+package com.adobe.pdfservices.operation.samples.pdfwatermark;
+
+public class PDFWatermarkWithOptions {
+
+ // Initialize the logger
+ private static final Logger LOGGER = LoggerFactory.getLogger(PDFWatermarkWithOptions.class);
+
+ public static void main(String[] args) {
+
+ try (
+ InputStream sourceFileInputStream = Files.newInputStream(new File("src/main/resources/pdfWatermarkInput.pdf").toPath());
+ InputStream watermarkFileInputStream = Files.newInputStream(new File("src/main/resources/watermark.pdf").toPath())) {
+
+ // Initial setup, create credentials instance
+ Credentials credentials = new ServicePrincipalCredentials(System.getenv("PDF_SERVICES_CLIENT_ID"), System.getenv("PDF_SERVICES_CLIENT_SECRET"));
+
+ // Creates a PDF Services instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Creates an asset(s) from source file(s) and upload
+ Asset inputDocumentAsset = pdfServices.upload(sourceFileInputStream, PDFServicesMediaType.PDF.getMediaType());
+ Asset watermarkDocumentAsset = pdfServices.upload(watermarkFileInputStream, PDFServicesMediaType.PDF.getMediaType());
+
+ // Creates a new job instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Watermark pages of the document (as specified by PageRanges).
+ PageRanges pageRangeForPDFWatermark = new PageRanges();
+
+ pageRangeForPDFWatermark.addRange(2, 5);
+ pageRangeForPDFWatermark.addRange(8, 10);
+
+ // Creates PDF Watermark appearance option
+ WatermarkAppearance watermarkAppearance = new WatermarkAppearance();
+ watermarkAppearance.setOpacity(50);
+
+ // Create parameters for the job
+ PDFWatermarkParams pdfWatermarkParams = PDFWatermarkParams.pdfWatermarkParamsBuilder()
+ .withPageRanges(pageRangeForPDFWatermark)
+ .withWatermarkAppearance(watermarkAppearance)
+ .build();
+
+ // Creates a new job instance
+ PDFWatermarkJob pdfWatermarkJob = new PDFWatermarkJob(inputDocumentAsset, watermarkDocumentAsset)
+ .setParams(pdfWatermarkParams);
+
+
+ // Submit the job and gets the job result
+ String location = pdfServices.submit(pdfWatermarkJob);
+ PDFServicesResponse pdfServicesResponse = pdfServices.getJobResult(location, PDFWatermarkResult.class);
+
+ // Get content from the resulting asset(s)
+ Asset resultAsset = pdfServicesResponse.getResult().getAsset();
+ StreamAsset streamAsset = pdfServices.getContent(resultAsset);
+
+ // Creates an output stream and copy stream asset's content to it
+ Files.createDirectories(Paths.get("output/"));
+ OutputStream outputStream = Files.newOutputStream(new File("output/pdfWatermarkWithOptionsOutput.pdf").toPath());
+ LOGGER.info("Saving asset at output/pdfWatermarkWithOptionsOutput.pdf");
+ IOUtils.copy(streamAsset.getInputStream(), outputStream);
+ outputStream.close();
+ } catch (ServiceApiException | IOException | SDKException | ServiceUsageException ex) {
+ LOGGER.error("Exception encountered while executing operation", ex);
+ }
+ }
+}
+```
+
+#### .NET
+
+```javascript
+// Get the samples from https://github.com/adobe/PDFServices.NET.SDK.Samples
+// Run the sample:
+// cd PDFWatermarkWithOptions/
+// dotnet run PDFWatermarkWithOptions.csproj
+
+namespace PDFWatermarkWithOptions
+{
+ class Program
+ {
+ // Initialize the logger.
+ private static readonly ILog log = LogManager.GetLogger(typeof(Program));
+
+ static void Main()
+ {
+ //Configure the logging
+ ConfigureLogging();
+
+ try
+ {
+ // Initial setup, create credentials instance
+ ICredentials credentials = new ServicePrincipalCredentials(
+ Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_ID"),
+ Environment.GetEnvironmentVariable("PDF_SERVICES_CLIENT_SECRET"));
+
+ // Creates a PDF Services instance
+ PDFServices pdfServices = new PDFServices(credentials);
+
+ // Creates an asset(s) from source file(s) and upload
+ Stream sourceFileInputStream = File.OpenRead(@"pdfWatermarkInput.pdf");
+ IAsset inputDocumentAsset = pdfServices.Upload(sourceFileInputStream, PDFServicesMediaType.PDF.GetMIMETypeValue());
+
+ // Creates a watermark asset from source file(s) and upload
+ Stream watermarkFileInputStream = File.OpenRead(@"watermark.pdf");
+ IAsset watermarkDocumentAsset = pdfServices.Upload(watermarkFileInputStream, PDFServicesMediaType.PDF.GetMIMETypeValue());
+
+ // Watermark pages of the document
+ PageRanges pageRangeForPDFWatermark = new PageRanges();
+
+ pageRangeForPDFWatermark.AddRange(2, 5);
+ pageRangeForPDFWatermark.AddRange(8, 10);
+
+ // Creates PDF Watermark appearance option
+ WatermarkAppearance watermarkAppearance = new WatermarkAppearance();
+ watermarkAppearance.SetOpacity(50);
+
+ // Create parameters for the job
+ PDFWatermarkParams pdfWatermarkParams = PDFWatermarkParams.PDFWatermarkParamsBuilder()
+ .WithPageRanges(pageRangesForPDFWatermark)
+ .WithWatermarkAppearance(watermarkAppearance).Build();
+
+ // Submits the job and gets the job result
+ PDFWatermarkJob pdfWatermarkJob = new PDFWatermarkJob(inputDocumentAsset, watermarkDocumentAsset).SetParams(pdfWatermarkParams);
+ String location = pdfServices.Submit(pdfWatermarkJob);
+
+ // Get content from the resulting asset(s)
+ PDFServicesResponse pdfServicesResponse =
+ pdfServices.GetJobResult(location, typeof(PDFWatermarkResult));
+
+ // Creating output streams and copying stream asset's content to it
+ IAsset resultAsset = pdfServicesResponse.Result.Asset;
+ StreamAsset streamAsset = pdfServices.GetContent(resultAsset);
-
+ // Creating output streams and copying stream asset's content to it
+ String outputFilePath = "/output/pdfWatermarkWithOptionsOutput.pdf";
+ new FileInfo(Directory.GetCurrentDirectory() + outputFilePath).Directory.Create();
+ Stream outputStream = File.OpenWrite(Directory.GetCurrentDirectory() + outputFilePath);
+ streamAsset.Stream.CopyTo(outputStream);
+ outputStream.Close();
+ }
+ catch (ServiceUsageException ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ catch (ServiceApiException ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ catch (SDKException ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ catch (IOException ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ catch (Exception ex)
+ {
+ log.Error("Exception encountered while executing operation", ex);
+ }
+ }
+
+ static void ConfigureLogging()
+ {
+ ILoggerRepository logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
+ XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
+ }
+ }
+}
+```
+
+#### Node JS
+
+```javascript
+// Get the samples from https://github.com/adobe/pdfservices-node-sdk-samples
+// Run the sample:
+// node src/pdfwatermark/pdf-watermark-with-options.js
+
+const {
+ ServicePrincipalCredentials,
+ PDFServices,
+ MimeType,
+ PDFWatermarkJob,
+ PDFWatermarkResult,
+ SDKError,
+ ServiceUsageError,
+ ServiceApiError,
+} = require("@adobe/pdfservices-node-sdk");
+const fs = require("fs");
+
+(async () => {
+ let sourceFileReadStream;
+ let watermarkFileReadStream;
+ try {
+ // Initial setup, create credentials instance
+ const credentials = new ServicePrincipalCredentials({
+ clientId: process.env.PDF_SERVICES_CLIENT_ID,
+ clientSecret: process.env.PDF_SERVICES_CLIENT_SECRET
+ });
+
+ // Creates a PDF Services instance
+ const pdfServices = new PDFServices({credentials});
+
+ // Creates an asset(s) from source file(s) and upload
+ sourceFileReadStream = fs.createReadStream("resources/watermarkPDFInput.pdf");
+ watermarkFileReadStream = fs.createReadStream("resources/watermark.pdf");
+
+ const [inputAsset, watermarkAsset] = await pdfServices.uploadAssets({
+ streamAssets: [{
+ readStream: sourceFileReadStream,
+ mimeType: MimeType.PDF
+ }, {
+ readStream: waterMarkReadStream,
+ mimeType: MimeType.PDF
+ }]
+ });
+
+ const pageRangesForWatermark = new PageRanges();
+
+ pageRangesForWatermark.addRange(2, 5);
+ pageRangesForWatermark.addRange(8, 10);
+
+ const watermarkAppearance = new WatermarkAppearance({
+ appearOnForeground: true,
+ opacity: 50,
+ });
+
+ // Create parameters for the job
+ const pdfWatermarkParams = new PDFWatermarkParams({
+ watermarkAppearance: watermarkAppearance,
+ pageRanges: pageRangesForWatermark
+ })
+
+ // Creates a new job instance
+ const job = new PDFWatermarkJob({
+ inputAsset: inputAsset,
+ watermarkAsset: watermarkAsset,
+ params: pdfWatermarkParams
+ });
+
+ // Submit the job and get the job result
+ const pollingURL = await pdfServices.submit({job});
+ const pdfServicesResponse = await pdfServices.getJobResult({
+ pollingURL,
+ resultType: PDFWatermarkResult
+ });
+
+ // Get content from the resulting asset(s)
+ const resultAsset = pdfServicesResponse.result.asset;
+ const streamAsset = await pdfServices.getContent({asset: resultAsset});
+
+ // Creates a write stream and copy stream asset's content to it
+ const outputFilePath = "./pdfWatermarkOutput.pdf";
+ console.log(`Saving asset at ${outputFilePath}`);
+
+ const writeStream = fs.createWriteStream(outputFilePath);
+ streamAsset.readStream.pipe(writeStream);
+ } catch (err) {
+ if (err instanceof SDKError || err instanceof ServiceUsageError || err instanceof ServiceApiError) {
+ console.log("Exception encountered while executing operation", err);
+ } else {
+ console.log("Exception encountered while executing operation", err);
+ }
+ } finally {
+ sourceFileReadStream?.destroy();
+ watermarkFileReadStream?.destroy();
+ }
+})();
+```
+
+#### Python
+
+```javascript
+# Get the samples from https://github.com/adobe/pdfservices-python-sdk-samples
+# Run the sample:
+# python src/pdfwatermark/watermark_pdf_with_params.py
+
+# Initialize the logger
+logging.basicConfig(level=logging.INFO)
+
+class PDFWatermark:
+ def __init__(self):
+ try:
+ pdf_file = open("src/resources/watermarkPDFInput.pdf", 'rb')
+ source_file_input_stream = pdf_file.read()
+ pdf_file.close()
+
+ pdf_file = open("src/resources/watermark.pdf", 'rb')
+ watermark_file_input_stream = pdf_file.read()
+ pdf_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=source_file_input_stream, mime_type=PDFServicesMediaType.PDF)
+ watermark_asset = pdf_services.upload(input_stream=watermark_file_input_stream, mime_type=PDFServicesMediaType.PDF)
+
+ watermark_appearance = WatermarkAppearance(appear_on_foreground=True, opacity=50)
+
+ page_ranges = PageRanges()
+ page_ranges.add_range(2, 5)
+ page_ranges.add_range(8, 10)
+
+ # Create parameters for the job
+ pdf_watermark_params = PDFWatermarkParams(page_ranges=page_ranges, watermark_appearance=watermark_appearance)
+
+ # Creates a new job instance
+ pdf_watermark_job = PDFWatermarkJob(input_asset=input_asset, watermark_asset=watermark_asset,
+ pdf_watermark_params=pdf_watermark_params)
+
+ # Submit the job and gets the job result
+ location = pdf_services.submit(pdf_watermark_job)
+ pdf_services_response = pdf_services.get_job_result(location, PDFWatermarkResult)
+
+ # Get content from the resulting asset(s)
+ pdf_watermark_result: CloudAsset = pdf_services_response.get_result().get_asset()
+ stream_asset: StreamAsset = pdf_services.get_content(pdf_watermark_result)
+
+ # Creates an output stream and copy stream asset's content to it
+ output_file_path = 'output/pdfWatermark.pdf'
+ 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}')
+
+ if __name__ == "__main__":
+ PDFWatermark()
+```
#### REST API
@@ -63,12 +714,12 @@ curl --location --request POST 'https://pdf-services.adobe.io/operation/addwater
"watermarkDocumentAssetID": "urn:aaid:AS:UE1:54cbf87f-d7f5-4918-8e4b-9f1878678e68",
"pageRanges": [
{
- "start": 2,
- "end": 5
+ "start": 2,
+ "end": 5
},
{
- "start": 8,
- "end": 10
+ "start": 8,
+ "end": 10
}
],
"appearance": {
diff --git a/src/pages/overview/pdf-services-api/quickstarts/dotnet/index.md b/src/pages/overview/pdf-services-api/quickstarts/dotnet/index.md
index 6c73535ef..0060e1ed3 100644
--- a/src/pages/overview/pdf-services-api/quickstarts/dotnet/index.md
+++ b/src/pages/overview/pdf-services-api/quickstarts/dotnet/index.md
@@ -55,7 +55,7 @@ To complete this guide, you will need:
-
+
diff --git a/src/pages/overview/pdf-services-api/quickstarts/java/index.md b/src/pages/overview/pdf-services-api/quickstarts/java/index.md
index 18b3235da..a2e773880 100644
--- a/src/pages/overview/pdf-services-api/quickstarts/java/index.md
+++ b/src/pages/overview/pdf-services-api/quickstarts/java/index.md
@@ -63,7 +63,7 @@ To complete this guide, you will need:
UTF-8
11
11
- 4.1.0
+ 4.2.0
diff --git a/src/pages/overview/pdf-services-api/quickstarts/python/index.md b/src/pages/overview/pdf-services-api/quickstarts/python/index.md
index 1192875f2..8bc889420 100644
--- a/src/pages/overview/pdf-services-api/quickstarts/python/index.md
+++ b/src/pages/overview/pdf-services-api/quickstarts/python/index.md
@@ -51,7 +51,7 @@ At this point, we've installed the Python SDK for Adobe PDF Services API as a de
Our application will take a PDF, `Bodea Brochure.pdf` (downloadable from here) and convert it to a Microsoft Word document, `Bodea Brochure.docx`.
-4) In your editor, open the directory where you previously copied the credentials. Create a new file, `autotag.py`.
+4) In your editor, open the directory where you previously copied the credentials. Create a new file, `export_pdf_to_docx.py`.
Now you're ready to begin coding.
@@ -100,7 +100,7 @@ pdf_services = PDFServices(credentials=credentials)
4) Now, let's create an asset from source file and upload.
```python
-file = open('src/resources/Bodea Brochure.pdf', 'rb')
+file = open('./Bodea Brochure.pdf', 'rb')
input_stream = file.read()
file.close()
diff --git a/src/pages/overview/releasenotes.md b/src/pages/overview/releasenotes.md
index d00101090..3d13f6f58 100644
--- a/src/pages/overview/releasenotes.md
+++ b/src/pages/overview/releasenotes.md
@@ -93,8 +93,8 @@ version.
UTF-8
11
11
- 4.1.0
- 4.1.0
+ 4.2.0
+ 4.2.0
@@ -116,7 +116,7 @@ import com.adobe.pdfservices.operation.ExecutionContext;
* Update the latest SDK dependency in package.json file of your project
```
-"@adobe/pdfservices-node-sdk": "4.0.1"
+"@adobe/pdfservices-node-sdk": "4.1.0"
```
* Require the `@adobe/pdfservices-node-sdk` in the Sample file to access the SDK interface
@@ -140,7 +140,7 @@ const pageLayout = new PDFServicesSdk.CreatePDF.options.html.PageLayout();
```
-
+
```
@@ -181,6 +181,15 @@ Upgrading to the latest SDK should not break existing applications.
## Change history
+
+### November 06, 2024; Java SDK 4.2.0 and NodeJS, .NET, Python SDK 4.1.0 minor release
+
+- PDF Watermark and PDF Accessibility Checker operations are now available for all the users in PDF Services SDKs.
+
+### September 10, 2024; Adobe Document Generation Server Side Release
+
+- Enhanced support for [JSONata functions](../document-generation-api/templatetags/#jsonata-functions) in Table Tag with Markers.
+
### August 23, 2024; Added new features for Document Generation API and updated Acrobat Service API postman collection
- Added base64 format support for inline images.