{"id":10024,"library":"pdfservices-sdk","title":"Adobe PDF Services SDK for Python","description":"Adobe PDF Services SDK for Python provides client libraries to interact with Adobe Document Cloud PDF Services APIs. It enables developers to programmatically perform operations like PDF creation, export, compression, OCR, document generation, and more. The current version is 4.2.0. Releases are typically infrequent, corresponding to updates in the underlying Adobe API services.","status":"active","version":"4.2.0","language":"en","source_language":"en","source_url":"https://github.com/adobe/pdfservices-sdk-python","tags":["adobe","pdf","document processing","api client","automation"],"install":[{"cmd":"pip install pdfservices-sdk","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.10 or higher.","package":"python","optional":false}],"imports":[{"symbol":"PdfServiceClient","correct":"from pdfservices_sdk.pdf_services_client import PdfServiceClient"},{"note":"SDKConfig was deprecated and removed in v4.x, replaced by PdfServicesConfig for SDK configuration.","wrong":"from pdfservices_sdk.sdk_config import SDKConfig","symbol":"PdfServicesConfig","correct":"from pdfservices_sdk.pdf_services_config import PdfServicesConfig"},{"note":"For file-based credentials, AdobeAuthCredentials is the correct class in v4.x. While ServicePrincipalCredentials still exists for JWT authentication, its 'file_based_credentials_builder' method was removed for file-based auth in v4.x.","wrong":"from pdfservices_sdk.auth.credentials import ServicePrincipalCredentials","symbol":"AdobeAuthCredentials","correct":"from pdfservices_sdk.auth.credentials import AdobeAuthCredentials"},{"symbol":"FileRef","correct":"from pdfservices_sdk.io.file_ref import FileRef"},{"symbol":"CreatePdfFromHtmlJob","correct":"from pdfservices_sdk.jobs.createpdf.create_pdf_from_html_job import CreatePdfFromHtmlJob"}],"quickstart":{"code":"import os\nfrom pdfservices_sdk.pdf_services_client import PdfServiceClient\nfrom pdfservices_sdk.pdf_services_config import PdfServicesConfig\nfrom pdfservices_sdk.auth.credentials import AdobeAuthCredentials\nfrom pdfservices_sdk.io.file_ref import FileRef\nfrom pdfservices_sdk.jobs.createpdf.create_pdf_from_html_job import CreatePdfFromHtmlJob\n\n# Ensure you have your credentials.json file path set as an environment variable\n# Or provide the path directly: credentials_path = \"./pdfservices-api-credentials.json\"\ncredentials_path = os.environ.get(\"PDF_SERVICES_SDK_CLIENT_CREDENTIALS_PATH\", \"./pdfservices-api-credentials.json\")\n\n# Create a dummy HTML file for conversion\ndummy_html_content = \"<h1>Hello from Adobe PDF Services!</h1><p>This is a test.</p>\"\nwith open(\"input.html\", \"w\") as f:\n    f.write(dummy_html_content)\n\ntry:\n    # 1. Build AdobeAuthCredentials using a file-based builder.\n    #    Ensure credentials.json has 'client_id', 'client_secret', and 'organization_id'.\n    credentials = AdobeAuthCredentials.file_based_credentials_builder()\\\n        .with_credentials_path(credentials_path).build()\n\n    # 2. Build PdfServicesConfig with the created credentials.\n    pdf_services_config = PdfServicesConfig.builder().with_credentials(credentials).build()\n\n    # 3. Create a PdfServiceClient.\n    pdf_service_client = PdfServiceClient.builder().with_pdf_services_config(pdf_services_config).build()\n\n    # 4. Create an input FileRef from the HTML file.\n    input_file_ref = FileRef.from_local_file(\"input.html\")\n\n    # 5. Create a CreatePdfFromHtmlJob instance.\n    create_pdf_from_html_job = CreatePdfFromHtmlJob(input_file_ref)\n\n    # 6. Execute the job and get the output FileRef.\n    result_file_ref = pdf_service_client.execute(create_pdf_from_html_job)\n\n    # 7. Save the result to a local file.\n    output_path = \"output.pdf\"\n    result_file_ref.save_as_file(output_path)\n    print(f\"Successfully created PDF: {output_path}\")\n\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\nfinally:\n    # Clean up dummy files\n    if os.path.exists(\"input.html\"):\n        os.remove(\"input.html\")\n    # if os.path.exists(\"output.pdf\"):\n    #     os.remove(\"output.pdf\") # Uncomment to remove generated PDF after successful run\n","lang":"python","description":"This quickstart demonstrates how to initialize the PDF Services client, authenticate using file-based credentials, and convert a simple HTML string to a PDF document. It highlights the use of `AdobeAuthCredentials` and `PdfServicesConfig` for setup, and `FileRef` for handling input/output files."},"warnings":[{"fix":"Update all instances of `SDKConfig` to `PdfServicesConfig` and ensure `PdfServiceClient` is built with `with_pdf_services_config` instead of `with_sdk_config`.","message":"Major API changes in version 4.0.0 related to SDK configuration. The `SDKConfig` class has been replaced by `PdfServicesConfig`.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Replace `ServicePrincipalCredentials` with `AdobeAuthCredentials` for file-based authentication setup. The `credentials.json` file structure remains the same.","message":"File-based authentication for `ServicePrincipalCredentials` was refactored in v4.x. You must now use `AdobeAuthCredentials.file_based_credentials_builder()` instead of `ServicePrincipalCredentials.file_based_credentials_builder()`.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Ensure your `credentials.json` file is correctly formatted and accessible via the specified path (or environment variable). Obtain credentials from the Adobe Developer Console.","message":"All API calls require valid `credentials.json` with `client_id`, `client_secret`, and `organization_id`.","severity":"gotcha","affected_versions":"All"},{"fix":"Always use `FileRef.from_local_file()` for inputs and `FileRef.save_as_file()` for outputs. Ensure proper error handling for file operations.","message":"Input and output files are handled using `FileRef` objects. For local files, ensure the paths are correct and the SDK has read/write permissions.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Replace `SDKConfig` with `PdfServicesConfig`. Example: `from pdfservices_sdk.pdf_services_config import PdfServicesConfig`.","cause":"Attempting to use the deprecated `SDKConfig` class from a pre-v4.x SDK version with a v4.x or later installation.","error":"AttributeError: module 'pdfservices_sdk.sdk_config' has no attribute 'SDKConfig'"},{"fix":"Use `AdobeAuthCredentials.file_based_credentials_builder()` instead. Example: `from pdfservices_sdk.auth.credentials import AdobeAuthCredentials; credentials = AdobeAuthCredentials.file_based_credentials_builder().with_credentials_path(...).build()`.","cause":"Attempting to use the old file-based credentials builder method from `ServicePrincipalCredentials` (deprecated in v4.x) for file-based authentication.","error":"AttributeError: type object 'ServicePrincipalCredentials' has no attribute 'file_based_credentials_builder'"},{"fix":"Verify the path to your `credentials.json` file. Ensure it exists and has read permissions. Consider setting it via an environment variable `PDF_SERVICES_SDK_CLIENT_CREDENTIALS_PATH` for consistent access.","cause":"The SDK cannot find your `credentials.json` file at the specified path, or the path is incorrect.","error":"FileNotFoundError: [Errno 2] No such file or directory: 'pdfservices-api-credentials.json'"},{"fix":"Check your `credentials.json` for correctness. Examine the input file for any corruption or unsupported formats. Review the full exception details for more specific error codes or messages from the API. Implement robust retry mechanisms for transient errors.","cause":"A general error from the Adobe PDF Services API. This often indicates issues with authentication (invalid credentials), malformed input files, or exceeding service limits.","error":"pdfservices_sdk.exceptions.ServiceApiException: Error occurred while executing the API."}]}