Skip to main content
Participating Frequently
April 3, 2024
Question

PDF generation API error on recent DOCX

  • April 3, 2024
  • 4 replies
  • 7432 views

Hello, 
I use the PDF generation API to send docx template + array to retrieve pdf. All was working fine since end of March.
A working docx template will no longer work if i save it again (like add space + remove + save).
the problem occurs only when converting in pdf: template docx to docx seem working fine.

'cpf:inline' => [
                        'outputFormat'     => 'pdf',
                        'jsonDataForMerge' => ['toto' => 'toto'],
                    ],

outputFormat as PDF trigger the error.

here is the UNSUPPORTED_OR_CORRUPTED_TEMPLATE error : 

\"cpf:status\":{\"completed\":true,\"type\":\"\",\"title\":\"Either unsupported or corrupted file content provided. The only supported format is docx; transactionId=XpY0r4AgreDVkynOlMAPp60Qau7COeTL\",\"status\":400,\"report\":\"{\\\"error_code\\\":\\\"UNSUPPORTED_OR_CORRUPTED_TEMPLATE\\\",\\\"source\\\":\\\"docgen_engine\\\"}\"}

It seems there is may be a conflict with the Microsoft Word update and Adobe API service ?
You can reproduce event with an empty template

    4 replies

    bnroberts
    New Participant
    February 24, 2025

    I'm getting the same kind of problem. 

    New documents are generating ok, however some of my existing documents no longer generate. Even if I delete all content from the document it is still rejected as corrupted.

    I've attached a minimal document example.

    Unzipping the document the only thing thats obvious is that some 'media' has been retained even though it is not referenced in the content.


    New Participant
    May 14, 2024

    Any updates about this? I have the same issue with template docx & json file from the playground https://acrobatservices.adobe.com/dc-docgen-playground/index.html#/ . Here's my postman collection https://drive.google.com/file/d/1GWFzKj5-uzn2Ed4JlJY6oVS4dnIfyaGL/view?usp=sharing

    New Participant
    April 4, 2024

    I'm facing the same issue, except that I'm using the node sdk.

    Raymond Camden
    Community Manager
    Community Manager
    April 4, 2024

    @Yashwanth36533953k2p5 can you share your Word doc and code?

    New Participant
    April 5, 2024
     

     

    import PDFServicesSdk from "@adobe/pdfservices-node-sdk";
    import * as batcher from "./batcher.js";
    
    export async function createPdfs(templatesComponents) {
      const promises = [];
    
      for (const templateComponents of templatesComponents) {
        const { input, templatePath, outputPath } = templateComponents;
        const job = async () => await createPdf(input, templatePath, outputPath);
        const promise = batcher.pushJob(job);
        promises.push(promise);
      }
    
      return await Promise.all(promises);
    }
    
    export async function combinePdfs(filePaths, outputPath) {
      const job = async () => await _combinePdfs(filePaths, outputPath);
      return await batcher.pushJob(job);
    }
    
    async function _combinePdfs(filePaths, outputPath) {
      // Initial setup, create credentials instance.
      const executionContext = getExecutionContext();
      const combineFilesOperation =
        PDFServicesSdk.CombineFiles.Operation.createNew();
    
      // Set operation input from a source file.
      for (const filePath of filePaths) {
        const source = PDFServicesSdk.FileRef.createFromLocalFile(filePath);
        combineFilesOperation.addInput(source);
      }
    
      // Execute the operation and Save the result to the specified location.
      const result = await combineFilesOperation.execute(executionContext);
      await result.saveAsFile(outputPath);
      return outputPath;
    }
    
    async function createPdf(input, templatePath, outputPath) {
      const executionContext = getExecutionContext();
    
      // Create a new DocumentMerge options instance.
      const documentMerge = PDFServicesSdk.DocumentMerge;
      const documentMergeOptions = documentMerge.options;
    
      const options = new documentMergeOptions.DocumentMergeOptions(
        input,
        documentMergeOptions.OutputFormat.PDF
      );
    
      // Create a new operation instance using the options instance.
      const documentMergeOperation = documentMerge.Operation.createNew(options);
    
      // Set operation input document template from a source file.
      const template = PDFServicesSdk.FileRef.createFromLocalFile(templatePath);
      documentMergeOperation.setInput(template);
    
      // Execute the operation and Save the result to the specified location.
      const result = await documentMergeOperation.execute(executionContext);
      await result.saveAsFile(outputPath);
      return outputPath;
    }
    
    function getExecutionContext() {
      // Initial setup, create credentials instance.
      const credentials =
        PDFServicesSdk.Credentials.serviceAccountCredentialsBuilder()
          .fromFile("credentials/pdfservices-api-credentials.json")
          .build();
    
      const clientConfig = PDFServicesSdk.ClientConfig.clientConfigBuilder()
        .withConnectTimeout(20000)
        .withReadTimeout(20000)
        .build();
    
      // Create an ExecutionContext using credentials.
      return PDFServicesSdk.ExecutionContext.create(credentials, clientConfig);
    }​

     

    Raymond Camden
    Community Manager
    Community Manager
    April 3, 2024

    Are you using the old REST API? If so - please switch to the new one and test there.

    CronaDevAuthor
    Participating Frequently
    April 3, 2024

    ok, thanks i will try for basic test, can you let me know when the "old" API will ne longer be usable ?

    Raymond Camden
    Community Manager
    Community Manager
    April 3, 2024

    I don't think we're taking it away, but we aren't providing any suupport for it.