Skip to content

Commit cb4e15e

Browse files
authored
Merge pull request #860 from AdobeDocs/py-devdocs-imports
Python SDK 4.0 doc fixes
2 parents b0a662a + b4dae6b commit cb4e15e

File tree

24 files changed

+210
-310
lines changed

24 files changed

+210
-310
lines changed

src/pages/overview/document-generation-api/gettingstarted.md

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -374,35 +374,9 @@ const fs = require("fs");
374374
# Run the sample:
375375
# python src/documentmerge/merge_document_to_pdf.py
376376

377-
import json
378-
import logging
379-
import os
380-
from datetime import datetime
381-
382-
from adobe.pdfservices.operation.auth.service_principal_credentials import ServicePrincipalCredentials
383-
from adobe.pdfservices.operation.exception.exceptions import ServiceApiException, ServiceUsageException, SdkException
384-
from adobe.pdfservices.operation.io.cloud_asset import CloudAsset
385-
from adobe.pdfservices.operation.io.stream_asset import StreamAsset
386-
from adobe.pdfservices.operation.pdf_services import PDFServices
387-
from adobe.pdfservices.operation.pdf_services_media_type import PDFServicesMediaType
388-
from adobe.pdfservices.operation.pdfjobs.jobs.document_merge_job import DocumentMergeJob
389-
from adobe.pdfservices.operation.pdfjobs.params.documentmerge.document_merge_params import DocumentMergeParams
390-
from adobe.pdfservices.operation.pdfjobs.params.documentmerge.output_format import OutputFormat
391-
from adobe.pdfservices.operation.pdfjobs.result.document_merge_result import DocumentMergePDFResult
392-
393377
# Initialize the logger
394378
logging.basicConfig(level=logging.INFO)
395379

396-
397-
#
398-
# This sample illustrates how to merge the Word based document template with the input JSON data to generate
399-
# the output document in the PDF format.
400-
#
401-
# To know more about document generation and document templates, please see the
402-
# <a href="http://www.adobe.com/go/dcdocgen_overview_doc">documentation</a>
403-
#
404-
# Refer to README.md for instructions on how to run the samples.
405-
#
406380
class MergeDocumentToPDF:
407381
def __init__(self):
408382
try:
@@ -863,39 +837,9 @@ const fs = require("fs");
863837
# Run the sample:
864838
# python src/documentmerge/merge_document_to_docx_with_fragments.py
865839

866-
import logging
867-
import os
868-
from datetime import datetime
869-
870-
from adobe.pdfservices.operation.auth.service_principal_credentials import ServicePrincipalCredentials
871-
from adobe.pdfservices.operation.exception.exceptions import ServiceApiException, ServiceUsageException, SdkException
872-
from adobe.pdfservices.operation.io.cloud_asset import CloudAsset
873-
from adobe.pdfservices.operation.io.stream_asset import StreamAsset
874-
from adobe.pdfservices.operation.pdf_services import PDFServices
875-
from adobe.pdfservices.operation.pdf_services_media_type import PDFServicesMediaType
876-
from adobe.pdfservices.operation.pdfjobs.jobs.document_merge_job import DocumentMergeJob
877-
from adobe.pdfservices.operation.pdfjobs.params.documentmerge.document_merge_params import DocumentMergeParams
878-
from adobe.pdfservices.operation.pdfjobs.params.documentmerge.fragments import Fragments
879-
from adobe.pdfservices.operation.pdfjobs.params.documentmerge.output_format import OutputFormat
880-
from adobe.pdfservices.operation.pdfjobs.result.document_merge_result import DocumentMergePDFResult
881-
882840
# Initialize the logger
883841
logging.basicConfig(level=logging.INFO)
884842

885-
886-
#
887-
# This sample illustrates how to merge the Word based document template with the input JSON data and fragments JSON
888-
# to generate
889-
# the output document in the docx format.
890-
# The document template used in the sample covers the use of various document generation template tags.
891-
#
892-
# To know more about document generation and document templates, please see the
893-
# <a href="http://www.adobe.com/go/dcdocgen_overview_doc">documentation</a>
894-
# And to know more about fragments use-case in document generation and document templates, please see the
895-
# <a href="http://www.adobe.com/go/dcdocgen_fragments_support">documentation</a>
896-
#
897-
# Refer to README.md for instructions on how to run the samples.
898-
#
899843
class MergeDocumentToDOCXWithFragments:
900844
def __init__(self):
901845
try:

src/pages/overview/document-generation-api/quickstarts/python/index.md

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ To complete this guide, you will need:
3737

3838
## Step Two: Setting up the project
3939

40-
1) In your Downloads folder, find the ZIP file with your credentials: PDFServicesSDK-Python (Extract, Auto-tag)Samples.zip. If you unzip that archive, you will find a folder of samples and the `pdfservices-api-credentials.json` file.
40+
1) In your Downloads folder, find the ZIP file with your credentials: PDFServicesSDK-PythonSamples.zip. If you unzip that archive, you will find a folder of samples and the `pdfservices-api-credentials.json` file.
4141

4242
![Samples](./shot5_spc.png)
4343

44-
2) Take the `pdfservices-api-credentials.json` file and place it in a new directory.
44+
2) Take the `pdfservices-api-credentials.json` file and place it in a new directory. Remember that these credential files are important and should be stored safely.
4545

4646
3) At the command line, change to the directory you created, and run the following command to install the Python SDK: `pip install pdfservices-sdk`.
4747

@@ -202,35 +202,9 @@ with open(output_file_path, "wb") as file:
202202
Here's the complete application (`src/documentmerge/merge_document_to_pdf.py`):
203203

204204
```python
205-
import json
206-
import logging
207-
import os
208-
from datetime import datetime
209-
210-
from adobe.pdfservices.operation.auth.service_principal_credentials import ServicePrincipalCredentials
211-
from adobe.pdfservices.operation.exception.exceptions import ServiceApiException, ServiceUsageException, SdkException
212-
from adobe.pdfservices.operation.io.cloud_asset import CloudAsset
213-
from adobe.pdfservices.operation.io.stream_asset import StreamAsset
214-
from adobe.pdfservices.operation.pdf_services import PDFServices
215-
from adobe.pdfservices.operation.pdf_services_media_type import PDFServicesMediaType
216-
from adobe.pdfservices.operation.pdfjobs.jobs.document_merge_job import DocumentMergeJob
217-
from adobe.pdfservices.operation.pdfjobs.params.documentmerge.document_merge_params import DocumentMergeParams
218-
from adobe.pdfservices.operation.pdfjobs.params.documentmerge.output_format import OutputFormat
219-
from adobe.pdfservices.operation.pdfjobs.result.document_merge_result import DocumentMergePDFResult
220-
221205
# Initialize the logger
222206
logging.basicConfig(level=logging.INFO)
223207

224-
225-
#
226-
# This sample illustrates how to merge the Word based document template with the input JSON data to generate
227-
# the output document in the PDF format.
228-
#
229-
# To know more about document generation and document templates, please see the
230-
# <a href="http://www.adobe.com/go/dcdocgen_overview_doc">documentation</a>
231-
#
232-
# Refer to README.md for instructions on how to run the samples.
233-
#
234208
class MergeDocumentToPDF:
235209
def __init__(self):
236210
try:
39.8 KB
Loading

src/pages/overview/pdf-accessibility-auto-tag-api/gettingstarted.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ The quickest way to get up and running is to download the code samples during th
226226

227227
1. Download [the Java sample project](https://www.adobe.com/go/pdftoolsapi_java_samples).
228228
2. Build the sample project with Maven: `mvn clean install`.
229-
3. Set the environment variables `PDF_SERVICES_CLIENT_ID` and `CLIET_SECRET` by running the following commands :
229+
3. Set the environment variables `PDF_SERVICES_CLIENT_ID` and `CLIENT_SECRET` by running the following commands :
230230
- **Windows:**
231231
- `set PDF_SERVICES_CLIENT_ID=<YOUR CLIENT ID>`
232232
- `set PDF_SERVICES_CLIENT_SECRET=<YOUR CLIENT SECRET>`
@@ -593,27 +593,42 @@ After downloading the zip, you can run the samples in the zip directly by settin
593593

594594
#### Setup a Python environment
595595

596+
Running any sample or custom code requires the following steps:
597+
596598
1. Install [Python 3.10](https://www.python.org/downloads/) or higher.
597599
2. Verify your installation by running this command: `python --version`.
598600

601+
<InlineAlert slots="text" />
602+
603+
pip uses requirements.txt file to fetch pdfservices-sdk from the public PyPi repository when running the project. The .whl automatically downloads when you build the sample project. Alternatively, you can download the pdfservices-sdk .whl file, and configure your own environment.
604+
605+
599606
##### Running the samples
600607

601608
The quickest way to get up and running is to download the code samples during the Getting Credentials workflow. These samples provide everything from ready-to-run sample code, an embedded credential json file, and pre-configured connections to dependencies.
602609

603610
1. Download and extract the [Python sample project](https://github.com/adobe/pdfservices-python-sdk-samples).
604611
2. Copy the downloaded zip to the directory that you set up for this project and unzip the files there.
605-
3. Set the environment variables `PDF_SERVICES_CLIENT_ID` and `CLIET_SECRET` by running the following commands :
612+
3. Set the environment variables `PDF_SERVICES_CLIENT_ID` and `CLIENT_SECRET` by running the following commands :
606613
- **Windows:**
607614
- `set PDF_SERVICES_CLIENT_ID=<YOUR CLIENT ID>`
608615
- `set PDF_SERVICES_CLIENT_SECRET=<YOUR CLIENT SECRET>`
609616

610617
- **MacOS/Linux:**
611618
- `export PDF_SERVICES_CLIENT_ID=<YOUR CLIENT ID>`
612619
- `export PDF_SERVICES_CLIENT_SECRET=<YOUR CLIENT SECRET>`
613-
4. Go to the project directory (which contains `requirements.txt` file) and build the sample project using this command in terminal: `pip install -r requirements.txt`.
614-
5. Test the sample code on the command line.
615-
6. Refer to this document for details about running samples as well as the API Reference for API details.
616-
7. You can import the samples into your preferred IDE and run the samples from there or run the below commands from terminal:
620+
4. Go to the project directory (which contains `requirements.txt` file) and setup a virtual environment.
621+
622+
```
623+
pip install virtualenv
624+
python -m venv myenv
625+
source myenv/bin/activate # on windows, use `myenv\Scripts\activate`
626+
```
627+
628+
5. Now build the sample project using this command in terminal: `pip install -r requirements.txt`.
629+
6. Test the sample code on the command line.
630+
7. Refer to this document for details about running samples as well as the API Reference for API details.
631+
8. You can import the samples into your preferred IDE and run the samples from there or run the commands from the README.md file in terminal.
617632

618633
#### Verifying download authenticity
619634

@@ -622,7 +637,7 @@ For security reasons you may wish to confirm the installer's authenticity. To do
622637
1. After downloading the package zip, run following command
623638

624639
```
625-
pip hash <download_dir>/pdfservices-sdk-3.0.0.tar.gz
640+
pip hash <download_dir>/pdfservices-sdk-4.0.0.tar.gz
626641
```
627642

628643
1. Above command will return the hash of downloaded package.

src/pages/overview/pdf-accessibility-auto-tag-api/howtos/index.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ the SDK supports custom timeouts for the API calls. You can tailor the
2929
timeout settings for your environment and network speed. In addition to
3030
the details below, you can refer to working code samples:
3131

32+
[//]: # (TODO update python sample)
33+
3234
- [Java](https://github.com/adobe/pdfservices-java-sdk-samples/blob/master/src/main/java/com/adobe/pdfservices/operation/samples/customconfigurations/CreatePDFWithCustomTimeouts.java)
3335
- [.NET](https://github.com/adobe/PDFServices.NET.SDK.Samples/blob/master/CreatePDFWithCustomTimeouts/Program.cs)
3436
- [Node.js](https://github.com/adobe/pdfservices-node-sdk-samples/blob/master/src/customconfigurations/create-pdf-with-custom-timeouts.js)
@@ -107,13 +109,10 @@ const clientConfig = new ClientConfig({
107109
Available properties:
108110

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

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

@@ -122,9 +121,8 @@ Override the timeout properties via a custom `ClientConfig` class:
122121
###
123122

124123
```javascript
125-
client_config = ClientConfig.builder()
126-
.with_connect_timeout(10000)
127-
.with_read_timeout(40000)
128-
.with_processing_timeout(900000)
129-
.build()
124+
client_config = ClientConfig(
125+
connect_timeout=4000,
126+
read_timeout=10000
127+
)
130128
```

0 commit comments

Comments
 (0)