PDF to image

Updated at:

The PDF to image API converts each page of a PDF document into an image. It supports PDF documents with up to 1,000 pages. This topic describes how to call the PDF to image API. Before you call an OpenAPI, review the API guide.

How to call the API

The PDF to image API is asynchronous. To use it, you first submit an asynchronous task by calling the SubmitConvertPdfToImageJob or SubmitConvertPdfToImageJobAdvance API. Then, you poll for the result by calling the GetDocumentConvertResult API.

Note
  • You must poll for the result every 10 seconds for a maximum of 120 minutes. If the task is not complete within this time, the task times out.

  • After an asynchronous task is submitted, you can query the result within 24 hours after the task is complete. After 24 hours, the result is no longer available.

  • Only single PDF files are supported.

Step 1: Call the SubmitConvertPdfToImageJob API

This API supports uploading a local file or a file from a URL.

  • To upload a local file, call the SubmitConvertPdfToImageJobAdvance API.

  • To upload a file from a URL, call the SubmitConvertPdfToImageJob API.

Request parameters

Name

Type

Required

Description

Example value

FileUrl

string

Yes

The URL of a single document. PDF files with more than 1,000 pages or larger than 100 MB are not supported.

To upload a local file, the software development kit (SDK) provides a separate input parameter to support file stream uploads.

https://example.com/example.pdf

FileName

string

No

The file name, including the file extension. This API supports only PDF files.

example.pdf

OssBucket

string

No

The name of your OSS bucket. For more information, see OSS hosting support.

docmind-trust

OssEndpoint

string

No

The endpoint of your OSS bucket. For more information, see OSS hosting support.

oss-cn-hangzhou.aliyuncs.com

EnableEventCallback

bool

No

Specifies whether to enable event callbacks. The default value is False. For more information, see EventBridge support.

false

Response parameters

Name

Type

Description

Example value

RequestId

string

The unique request ID.

43A29C77-405E-4CC0-BC55-EE694AD0****

Data

object

The returned data.

{"Id": "docmind-20220712-b15f****"}

Id

string

The business order number. This is the unique identifier used to query the result with a subsequent API call.

docmind-20220712-b15f****

Code

string

The status code.

200

Message

string

The detailed information.

Message

Usage examples

You can use this API to upload a local file or a file from a URL.

  • Upload a local file: The following code provides an example of how to upload a local file using the Java SDK. To do this, call the SubmitConvertPdfToImageJobAdvance API and use the fileUrlObject parameter to upload the local document.

    Note

    To learn how to obtain and use your AccessKey information, see the SDK usage guide for your preferred language in SDK Overview.

    import com.aliyun.docmind_api20220711.models.*;
    import com.aliyun.teaopenapi.models.Config;
    import com.aliyun.docmind_api20220711.Client;
    import com.aliyun.teautil.models.RuntimeOptions;
    import java.io.File;
    import java.io.FileInputStream;
    
    public static void main(String[] args) throws Exception {
            submit();
        }
    public static void submit() throws Exception {
        // Initialize the Credentials Client with the default credentials.
        com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
        Config config = new Config()
            // Get the AccessKey ID from the configuration using credentials.
            .setAccessKeyId(credentialClient.getAccessKeyId())
            // Get the AccessKey secret from the configuration using credentials.
            .setAccessKeySecret(credentialClient.getAccessKeySecret());
        // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
        config.endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
        Client client = new Client(config);
        // Create a RuntimeObject instance and set runtime parameters.
        RuntimeOptions runtime = new RuntimeOptions();
        SubmitConvertPdfToImageJobAdvanceRequest advanceRequest = new SubmitConvertPdfToImageJobAdvanceRequest();
        File file = new File("D:\\example.pdf");
        advanceRequest.fileUrlObject = new FileInputStream(file);
        advanceRequest.fileName = "example.pdf";
        // Send the request and handle the response or exceptions.
        SubmitConvertPdfToImageJobResponse response = client.submitConvertPdfToImageJobAdvance(advanceRequest, runtime);
        System.out.println(JSON.toJSON(response.getBody()));
    }
    const Client = require('@alicloud/docmind-api20220711');
    const Credential = require('@alicloud/credentials');
    const Util = require('@alicloud/tea-util');
    const fs = require('fs');
    
    const getResult = async () => {
      // Initialize the Credentials Client with the default credentials.
      const cred = new Credential.default();
      const client = new Client.default({
        // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
        endpoint: 'docmind-api.cn-hangzhou.aliyuncs.com',
        // Get the AccessKey ID from the configuration using credentials.
        accessKeyId: cred.credential.accessKeyId,
        // Get the AccessKey secret from the configuration using credentials.
        accessKeySecret: cred.credential.accessKeySecret,
        type: 'access_key',
        regionId: 'cn-hangzhou'
      });
      
      const advanceRequest = new Client.SubmitConvertPdfToImageJobAdvanceRequest();
      const file = fs.createReadStream('./example.pdf');
      advanceRequest.fileUrlObject = file;
      advanceRequest.fileName = 'example.pdf';
      const runtimeObject = new Util.RuntimeOptions({});
      const response = await client.submitConvertPdfToImageJobAdvance(advanceRequest, runtimeObject);
    	return response.body;
    }
    from alibabacloud_docmind_api20220711.client import Client as docmind_api20220711Client
    from alibabacloud_tea_openapi import models as open_api_models
    from alibabacloud_docmind_api20220711 import models as docmind_api20220711_models
    from alibabacloud_tea_util.client import Client as UtilClient
    from alibabacloud_credentials.client import Client as CredClient
    
    if __name__ == '__main__':
        cred=CredClient()
        config = open_api_models.Config(
            # Get the AccessKey ID from the configuration using credentials.
            access_key_id=cred.get_credential().get_access_key_id(),
            # Get the AccessKey secret from the configuration using credentials.
            access_key_secret=cred.get_credential().get_access_key_secret()
        )
        # The endpoint.
        config.endpoint = f'docmind-api.cn-hangzhou.aliyuncs.com'
        client = docmind_api20220711Client(config)
        request = docmind_api20220711_models.SubmitConvertPdfToImageJobAdvanceRequest(
            # file_url_object: The local file stream.
            file_url_object=open("./example.pdf", "rb"),
            # file_name: The file name. The name must include the file extension.
            file_name='123.pdf',
        )
        runtime = util_models.RuntimeOptions()
        try:
            # To run the code, copy it and print the API return value.
            response = client.submit_convert_pdf_to_image_job_advance(request, runtime)
            # The API returns data in the format of body -> data -> specific property. Print the results as needed. The following example shows how to print the returned business ID.
            # Property names for access start with a lowercase letter.
            print(response.body)        
        except Exception as error:
            # If necessary, print the error.
            UtilClient.assert_as_string(error.message)
    using Newtonsoft.Json;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Threading.Tasks;
    
    using Tea;
    using Tea.Utils;
    
    public static void SubmitFile()
            {
                // Initialize the Credentials Client with the default credentials.
              	var akCredential = new Aliyun.Credentials.Client(null);
                AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
                {
                    // Get the AccessKey ID from the configuration using credentials.
                    AccessKeyId = akCredential.GetAccessKeyId(),
                    // Get the AccessKey secret from the configuration using credentials.
                    AccessKeySecret = akCredential.GetAccessKeySecret(),
                };
                // The endpoint.
                config.Endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
                // You must install the AlibabaCloud.DarabonbaStream dependency library.
                AlibabaCloud.SDK.Docmind_api20220711.Client client = new AlibabaCloud.SDK.Docmind_api20220711.Client(config);
                Stream bodySyream = AlibabaCloud.DarabonbaStream.StreamUtil.ReadFromFilePath("<YOUR-FILE-PATH>");
                AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitConvertPdfToImageJobAdvanceRequest request = new AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitConvertPdfToImageJobAdvanceRequest
                {
                    FileUrlObject = bodySyream,
                    FileName = "example.pdf"
                };
                AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
                try
                {
                    // To run the code, copy it and print the API return value.
                    client.SubmitConvertPdfToImageJobAdvance(request, runtime);
                }
                catch (TeaException error)
                {
                    // If necessary, print the error.
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
                catch (Exception _error)
                {
                    TeaException error = new TeaException(new Dictionary<string, object>
                    {
                        { "message", _error.Message }
                    });
                    // If necessary, print the error.
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
            }
    import (
    	"fmt"
    	"os"
      
    	openClient "github.com/alibabacloud-go/darabonba-openapi/v2/client"
    	"github.com/alibabacloud-go/docmind-api-20220711/client"
    	"github.com/alibabacloud-go/tea-utils/v2/service"
      "github.com/aliyun/credentials-go/credentials"
    )
    
    func submit(){
      // Initialize the Credentials Client with the default credentials.
    	credential, err := credentials.NewCredential(nil)
    	// Get the AccessKey ID from the configuration using credentials.
    	accessKeyId, err := credential.GetAccessKeyId()
    	// Get the AccessKey secret from the configuration using credentials.
    	accessKeySecret, err := credential.GetAccessKeySecret()
      // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
      var endpoint string = "docmind-api.cn-hangzhou.aliyuncs.com"
    	config := openClient.Config{AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, Endpoint: &endpoint}
      // Initialize the client.
      cli, err := client.NewClient(&config)
    	if err != nil {
    		panic(err)
    	}
      // Call the API to upload a local document.
      filename := "D:\\example.pdf"    
      f, err := os.Open(filename)
    	if err != nil {
        panic(err)
    	}
      // Initialize the API request.
      request := client.SubmitConvertPdfToImageJobAdvanceRequest{
    		FileName:      &filename,
    		FileUrlObject: f,
    	}
      // Create a RuntimeObject instance and set runtime parameters.
      options := service.RuntimeOptions{}
      response, err := cli.SubmitConvertPdfToImageJobAdvance(&request, &options)
      if err != nil {
    		panic(err)
    	}
      // Print the result.
    	fmt.Println(response.Body.String())
    }
  • Upload a file from a URL: The following code provides an example of how to upload a file from a URL using the Java SDK. To do this, call the SubmitConvertPdfToImageJob API and use the fileUrl parameter to pass the document URL. Note that the URL must be publicly accessible for download and must not have cross-domain restrictions or contain special escape characters.

    Note

    To learn how to obtain and use your AccessKey information, see the SDK usage guide for your preferred language in SDK Overview.

    import com.aliyun.docmind_api20220711.models.*;
    import com.aliyun.teaopenapi.models.Config;
    import com.aliyun.docmind_api20220711.Client;
    
    public static void main(String[] args) throws Exception {
            submit();
        }
    public static void submit() throws Exception {
        // Initialize the Credentials Client with the default credentials.
        com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
        Config config = new Config()
            // Get the AccessKey ID from the configuration using credentials.
            .setAccessKeyId(credentialClient.getAccessKeyId())
            // Get the AccessKey secret from the configuration using credentials.
            .setAccessKeySecret(credentialClient.getAccessKeySecret());
        // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
        config.endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
        Client client = new Client(config);
        SubmitConvertPdfToImageJobRequest request = new SubmitConvertPdfToImageJobRequest();
        request.fileName = "example.pdf";
        request.fileUrl = "https://example.com/example.pdf";
        SubmitConvertPdfToImageJobResponse response = client.submitConvertPdfToImageJob(request);
        System.out.println(JSON.toJSON(response.getBody()));
    }
    const Client = require('@alicloud/docmind-api20220711');
    const Credential = require('@alicloud/credentials');
    
    const getResult = async () => {
      // Initialize the Credentials Client with the default credentials.
      const cred = new Credential.default();
      const client = new Client.default({
        // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
        endpoint: 'docmind-api.cn-hangzhou.aliyuncs.com',
        // Get the AccessKey ID from the configuration using credentials.
        accessKeyId: cred.credential.accessKeyId,
        // Get the AccessKey secret from the configuration using credentials.
        accessKeySecret: cred.credential.accessKeySecret,
        type: 'access_key',
        regionId: 'cn-hangzhou'
      });
      
      const request = new Client.SubmitConvertPdfToImageJobRequest();
      request.fileName = 'example.pdf';
      request.fileUrl = 'https://example.com/example.pdf';
      const response = await client.submitConvertPdfToImageJob(request);
      
      return response.body;
    }
    from alibabacloud_docmind_api20220711.client import Client as docmind_api20220711Client
    from alibabacloud_tea_openapi import models as open_api_models
    from alibabacloud_docmind_api20220711 import models as docmind_api20220711_models
    from alibabacloud_tea_util.client import Client as UtilClient
    from alibabacloud_credentials.client import Client as CredClient
    
    if __name__ == '__main__':
        cred=CredClient()
        config = open_api_models.Config(
            # Get the AccessKey ID from the configuration using credentials.
            access_key_id=cred.get_credential().get_access_key_id(),
            # Get the AccessKey secret from the configuration using credentials.
            access_key_secret=cred.get_credential().get_access_key_secret()
        )
        # The endpoint.
        config.endpoint = f'docmind-api.cn-hangzhou.aliyuncs.com'
        client = docmind_api20220711Client(config)
        request = docmind_api20220711_models.SubmitConvertPdfToImageJobRequest(
            # file_url: The URL of the file.
            file_url='https://example.com/example.pdf',
            # file_name: The file name. The name must include the file extension.
            file_name='123.pdf',
        )
        try:
            # To run the code, copy it and print the API return value.
            response = client.submit_convert_pdf_to_image_job(request)
            # The API returns data in the format of body -> data -> specific property. Print the results as needed. The following example shows how to print the returned business ID.
            # Property names for access start with a lowercase letter.
            print(response.body)        
        except Exception as error:
            # If necessary, print the error.
            UtilClient.assert_as_string(error.message)
    using Newtonsoft.Json;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Threading.Tasks;
    
    using Tea;
    using Tea.Utils;
    
    public static void SubmitUrl()
            {
                // Initialize the Credentials Client with the default credentials.
              	var akCredential = new Aliyun.Credentials.Client(null);
                AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
                {
                    // Get the AccessKey ID from the configuration using credentials.
                    AccessKeyId = akCredential.GetAccessKeyId(),
                    // Get the AccessKey secret from the configuration using credentials.
                    AccessKeySecret = akCredential.GetAccessKeySecret(),
                };
                // The endpoint.
                config.Endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
                AlibabaCloud.SDK.Docmind_api20220711.Client client = new AlibabaCloud.SDK.Docmind_api20220711.Client(config);
                AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitConvertPdfToImageJobRequest request = new AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitConvertPdfToImageJobRequest
                {
                    FileUrl = "https://example.pdf",
                    FileName = "example.pdf"
                };
                try
                {
                    // To run the code, copy it and print the API return value.
                    client.SubmitConvertPdfToImageJob(request);
                }
                catch (TeaException error)
                {
                    // If necessary, print the error.
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
                catch (Exception _error)
                {
                    TeaException error = new TeaException(new Dictionary<string, object>
                    {
                        { "message", _error.Message }
                    });
                    // If necessary, print the error.
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
            }
    import (
    	"fmt"
    
    	openClient "github.com/alibabacloud-go/darabonba-openapi/v2/client"
      "github.com/alibabacloud-go/docmind-api-20220711/client"
      "github.com/aliyun/credentials-go/credentials"
    )
    
    func submit(){
      // Initialize the Credentials Client with the default credentials.
    	credential, err := credentials.NewCredential(nil)
    	// Get the AccessKey ID from the configuration using credentials.
    	accessKeyId, err := credential.GetAccessKeyId()
    	// Get the AccessKey secret from the configuration using credentials.
    	accessKeySecret, err := credential.GetAccessKeySecret()
      // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
      var endpoint string = "docmind-api.cn-hangzhou.aliyuncs.com"
    	config := openClient.Config{AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, Endpoint: &endpoint}
      // Initialize the client.
      cli, err := client.NewClient(&config)
    	if err != nil {
    		panic(err)
    	}
      // File URL
      fileURL := "https://example.com/example.pdf"
      // File name
      fileName := "example.pdf"
      // Initialize the API request.
      request := client.SubmitConvertPdfToImageJobRequest{
    		FileUrl:  &fileURL,
    		FileName: &fileName,
    	}
      response, err := cli.SubmitConvertPdfToImageJob(&request)
      if err != nil {
    		panic(err)
    	}
      // Print the result.
    	fmt.Println(response.Body.String())
    }
    use AlibabaCloud\SDK\Docmindapi\V20220711\Docmindapi;
    use AlibabaCloud\SDK\Docmindapi\V20220711\Models\SubmitConvertPdfToImageJobRequest;
    use Darabonba\OpenApi\Models\Config;
    use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
    use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
    use AlibabaCloud\Credentials\Credential;
    
    // Initialize the Credentials Client with the default credentials.
    $bearerToken = new Credential();    
    $config = new Config();
    // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
    $config->endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
    // Get the AccessKey ID from the configuration using credentials.
    $config->accessKeyId = $bearerToken->getCredential()->getAccessKeyId();
    // Get the AccessKey secret from the configuration using credentials.
    $config->accessKeySecret = $bearerToken->getCredential()->getAccessKeySecret();
    $config->type = "access_key";
    $config->regionId = "cn-hangzhou";
    $client = new Docmindapi($config);
    $request = new SubmitConvertPdfToImageJobRequest();
    
    $runtime = new RuntimeOptions();
    $runtime->maxIdleConns = 3;
    $runtime->connectTimeout = 10000;
    $runtime->readTimeout = 10000;
    
    $request->fileName = "example.pdf";
    $request->fileUrl = "https://example.com/example.pdf";
    
    try {
      $response = $client->submitConvertPdfToImageJob($request, $runtime);
      var_dump($response->toMap());
    } catch (TeaUnableRetryError $e) {
      var_dump($e->getMessage());
      var_dump($e->getErrorInfo());
      var_dump($e->getLastException());
      var_dump($e->getLastRequest());
    }

Sample response:

{
  "RequestId": "43A29C77-405E-4CC0-BC55-EE694AD0****",
  "Data": {
    "Id": "docmind-20220712-b15f****"
  }  
}

Step 2: Call the GetDocumentConvertResult API

The Id input parameter for this query API is the Id returned by the task submission API. The query returns one of three statuses: processing, successful, or failed.

Request parameters

Name

Type

Required

Description

Example value

Id

string

Yes

The business order number to query. Obtain this number from the response of the submission API.

docmind-20220712-b15f****

Response parameters

Name

Type

Description

Example value

RequestId

string

The unique request ID.

43A29C77-405E-4CC0-BC55-EE694AD0****

Completed

boolean

Indicates whether the asynchronous task is complete. false means the task is still processing. true means the task is complete, with a result of either successful or failed.

true

Status

string

The final status of the asynchronous task after it is complete. Success indicates the task was successful. Fail indicates the task failed.

Success

Data

object

The result of the document conversion. For details about the parameters, see the following table.

This is a list.

Code

string

The status code.

200

Message

string

The detailed information.

Message

Url

String

The URL of the converted file.

https://example.com/example.pdf

Size

Integer

The size of the converted file in bytes.

1345488

Type

String

Specifies the file extension of the converted file. For a PDF-to-Word conversion, the extension is .docx.

pdf

Md5

String

The MD5 hash of the converted file. You can use this value for verification.

2d49eb7705f9f93ed857874db247****

Usage example

The following code provides an example of how to call the result query API using the Java SDK. Call the GetDocumentConvertResult API and pass the task ID to the Id parameter.

Note

To learn how to obtain and use your AccessKey information, see the SDK usage guide for your preferred language in SDK Overview.

import com.aliyun.docmind_api20220711.models.*;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.docmind_api20220711.Client;

public static void main(String[] args) throws Exception {
        submit();
    }
public static void submit() throws Exception {
    // Initialize the Credentials Client with the default credentials.
    com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
    Config config = new Config()
        // Get the AccessKey ID from the configuration using credentials.
        .setAccessKeyId(credentialClient.getAccessKeyId())
        // Get the AccessKey secret from the configuration using credentials.
        .setAccessKeySecret(credentialClient.getAccessKeySecret());
    // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
    config.endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
    Client client = new Client(config);
    GetDocumentConvertResultRequest resultRequest = new GetDocumentConvertResultRequest();
    resultRequest.id = "docmind-20220902-824b****";
    GetDocumentConvertResultResponse response = client.getDocumentConvertResult(resultRequest);
    System.out.println(JSON.toJSON(response.getBody()));
}
const Client = require('@alicloud/docmind-api20220711');
const Credential = require('@alicloud/credentials');

const getResult = async () => {
  // Initialize the Credentials Client with the default credentials.
  const cred = new Credential.default();
  const client = new Client.default({
    // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
    endpoint: 'docmind-api.cn-hangzhou.aliyuncs.com',
    // Get the AccessKey ID from the configuration using credentials.
    accessKeyId: cred.credential.accessKeyId,
    // Get the AccessKey secret from the configuration using credentials.
    accessKeySecret: cred.credential.accessKeySecret,
    type: 'access_key',
    regionId: 'cn-hangzhou'
  });
  
  const resultRequest = new Client.GetDocumentConvertResultRequest();
  resultRequest.id = "docmind-20220902-824b****";
  const response = await client.getDocumentConvertResult(resultRequest);
  
  return response.body;
}
from alibabacloud_docmind_api20220711.client import Client as docmind_api20220711Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_docmind_api20220711 import models as docmind_api20220711_models
from alibabacloud_tea_util.client import Client as UtilClient
from alibabacloud_credentials.client import Client as CredClient

if __name__ == '__main__':
    cred=CredClient()
    config = open_api_models.Config(
        # Get the AccessKey ID from the configuration using credentials.
        access_key_id=cred.get_credential().get_access_key_id(),
        # Get the AccessKey secret from the configuration using credentials.
        access_key_secret=cred.get_credential().get_access_key_secret()
    )
    # The endpoint.
    config.endpoint = f'docmind-api.cn-hangzhou.aliyuncs.com'
    client = docmind_api20220711Client(config)
    request = docmind_api20220711_models.GetDocumentConvertResultRequest(
        # id: The ID returned by the task submission API.
        id='docmind-20220902-824b****'
    )
    try:
        # To run the code, copy it and print the API return value.
        response = client.get_document_convert_result(request)
        # The API returns data in the format of body -> data -> specific property. Print the results as needed. Property names for access start with a lowercase letter.
        # Get the status of the asynchronous task. You can check response.body.completed to determine whether to continue polling for the result.
        print(response.body.completed)
        # Get the returned result. First, convert response.body.data to JSON. Then, extract the required values from the JSON object.
        print(response.body)        
    except Exception as error:
        # If necessary, print the error.
        UtilClient.assert_as_string(error.message)
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using Tea;
using Tea.Utils;

public static void GetResult() 
        {
            // Initialize the Credentials Client with the default credentials.
          	var akCredential = new Aliyun.Credentials.Client(null);
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                // Get the AccessKey ID from the configuration using credentials.
                AccessKeyId = akCredential.GetAccessKeyId(),
                // Get the AccessKey secret from the configuration using credentials.
                AccessKeySecret = akCredential.GetAccessKeySecret(),
            };
            // The endpoint.
            config.Endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
            AlibabaCloud.SDK.Docmind_api20220711.Client client = new AlibabaCloud.SDK.Docmind_api20220711.Client(config);
            AlibabaCloud.SDK.Docmind_api20220711.Models.GetDocumentConvertResultRequest request = new AlibabaCloud.SDK.Docmind_api20220711.Models.GetDocumentConvertResultRequest
            {
                Id = "docmind-20220902-824b****"
            };
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                // To run the code, copy it and print the API return value.
                client.GetDocumentConvertResult(request);
            }
            catch (TeaException error)
            {
                // If necessary, print the error.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // If necessary, print the error.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
        }
import (
	"fmt"

	openClient "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  "github.com/alibabacloud-go/docmind-api-20220711/client"
  "github.com/aliyun/credentials-go/credentials"
)

func submit(){
    // Initialize the Credentials Client with the default credentials.
		credential, err := credentials.NewCredential(nil)
		// Get the AccessKey ID from the configuration using credentials.
		accessKeyId, err := credential.GetAccessKeyId()
		// Get the AccessKey secret from the configuration using credentials.
		accessKeySecret, err := credential.GetAccessKeySecret()
  	// The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
  	var endpoint string = "docmind-api.cn-hangzhou.aliyuncs.com"
		config := openClient.Config{AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, Endpoint: &endpoint}
  	// Initialize the client.
    cli, err := client.NewClient(&config)
    if err != nil {
      panic(err)
    }
    id := "docmind-20220925-76b1****"
    // Call the query API.
    request := client.GetDocumentConvertResultRequest{Id: &id}
    response, err := cli.GetDocumentConvertResult(&request)
    if err != nil {
      panic(err)
    }
    // Print the query result.
    fmt.Println(response.Body)
  // Note: The Go SDK URL-encodes the ampersand (&) in the returned URL to \u0026. You must manually decode \u0026 back to & to download the file from the URL.
  // The following is a sample URL returned by the Go SDK: http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/convert/docmind-20220927-87ad**/example.pdf?Expires=XX\u0026OSSAccessKeyId=YY\u0026Signature=ZZ
}
use AlibabaCloud\SDK\Docmindapi\V20220711\Docmindapi;
use AlibabaCloud\SDK\Docmindapi\V20220711\Models\GetDocumentConvertResultRequest;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
use AlibabaCloud\Credentials\Credential;

// Initialize the Credentials Client with the default credentials.
$bearerToken = new Credential();    
$config = new Config();
// The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
$config->endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
// Get the AccessKey ID from the configuration using credentials.
$config->accessKeyId = $bearerToken->getCredential()->getAccessKeyId();
// Get the AccessKey secret from the configuration using credentials.
$config->accessKeySecret = $bearerToken->getCredential()->getAccessKeySecret();
$config->type = "access_key";
$config->regionId = "cn-hangzhou";
$client = new Docmindapi($config);
$request = new GetDocumentConvertResultRequest();   
$request->id = "docmind-20220902-824b****";

$runtime = new RuntimeOptions();
$runtime->maxIdleConns = 3;
$runtime->connectTimeout = 10000;
$runtime->readTimeout = 10000;

try {
  $response = $client->getDocumentConvertResult($request, $runtime);
  var_dump($response->toMap());
} catch (TeaUnableRetryError $e) {
  var_dump($e->getMessage());
  var_dump($e->getErrorInfo());
  var_dump($e->getLastException());
  var_dump($e->getLastRequest());
}

Result

The response indicates one of three statuses: processing, successful, or failed. The following sections provide sample responses for each status.

  • The following is the response for an in-progress request:

    {
      "RequestId": "2AABD2C2-D24F-12F7-875D-683A27C3****",
      "Completed": false,
      "Code": "DocProcessing",
      "Message": "Document processing",
      "HostId": "ocr-api.cn-hangzhou.aliyuncs.com",
      "Recommend": "https://next.api.aliyun.com/troubleshoot?q=DocProcessing&product=docmind-api"
    }

    If the task is processing, the value of Completed is false. You must continue to poll for the result until Completed returns true or the maximum polling time is exceeded.

  • The following sample response indicates that the task failed:

    {
      "RequestId": "A8EF3A36-1380-1116-A39E-B377BE27****",
      "Completed": true,
      "Status": "Fail",
      "Code": "UrlNotLegal",
      "Message": "Failed to process the document.  The document url you provided is not legal.",
      "HostId": "docmind-api.cn-hangzhou.aliyuncs.com",
      "Recommend": "https://next.api.aliyun.com/troubleshoot?q=IDP.UrlNotLegal&product=docmind-api"
    }

    If the task failed, the value of Completed is true and the value of Status is Fail. The response also includes an error Code and a detailed Message. For more information about error codes, see Error codes.

  • The following sample response indicates that the task was successful:

    {
      "Status": "Success",
      "RequestId": "53E5D072-F0F7-1B66-A33A-CBEDD8A3****",
      "Completed": true,
      "Data": [
        {
          "Type": "jpg",
          "Size": 717128,
          "Url": "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/convert/docmind-20220902-57de****/example1.jpg?Expires=1662190830&OSSAccessKeyId=XX&Signature=YY",
          "Md5": "36256a4c2db8e31e056aeeb8b871****"
        },
        {
          "Type": "jpg",
          "Size": 534688,
          "Url": "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/convert/docmind-20220902-57de****/example2.jpg?Expires=1662190830&OSSAccessKeyId=XX&Signature=YY",
          "Md5": "36256a4c2db8e31e056aeeb8b871****"
        }
      ]
    }

    If the task was successful, the value of Completed is true and the value of Status is Success. The result is in the Data node. The Data node is a list in which each element represents a converted image. The following list describes the format of each element in the Data node:

    • Type indicates the document type of the converted file. For example, the PDF to image API returns multiple image documents in JPG format.

    • Url is the download link for the converted document. The URL returned by each query request is valid for 60 minutes. After it expires, you must call the query API again to obtain a new download link.

    • Size is the file size of the converted document in bytes. You can use this value to verify the integrity of the downloaded file by comparing its size with the Size value.

    • Md5 is the MD5 digest of the converted document. You can use this value to verify the integrity of the downloaded file by comparing its MD5 hash with the Md5 value.