Skip to content

PDF to Word Tool Guide

Note:Before learning how to use different functions, we recommend that read the Request Workflow to know a basic PDF processing process. When using different functions, you can set their own special parameters when uploading files. Other basic steps are consistent.

PDF to Word:

java
{
        "enableAiLayout": 1,
        "isContainImg": 1,
        "isContainAnnot": 1,
        "enableOcr": 0,
        "ocrLanguage": 8,
        "pageRanges": "1,2,3-5",
        "pageLayoutMode": "e_Flow",
        "formulaToImage": 1
        }

Required parameters

enableAiLayout: Whether to enable AI layout analysis (0: not enabled; 1: enabled). Default 1.

isContainImg: Whether to include images during conversion (0: not enabled; 1: enabled). Default 1.

isContainAnnot: Whether to include annotations during conversion (0: not enabled; 1: enabled). Default is 1.

enableOcr: Whether to use OCR (0: not enabled; 1: enabled). Default is 0.

ocrLanguage: OCR recognition language. 1: CHINESE; 2: CHINESE_TRA; 3: ENGLISH; 4: KOREAN; 5: JAPANESE; 6: LATIN; 7: DEVANAGARI; 8: AUTO. Default is 8.

pageRanges: Specify page number conversion, starting from 1. Default is empty.

pageLayoutMode: Specify the layout mode. e_Box: fixed layout; e_Flow: reflowable layout. Default e_Flow.

Layout differences

Word's Streaming Layout Ideal for editing, with your editing, the content dynamically adapts to different positions. However, a Word file would display differently due to the incompatibility of various software or app versions. It makes it unsuitable for precise documentation like electronic files or certificates.

PDF's Fixed Page Layout: Ensures a stable, uniform appearance and print quality across all devices. The content and formatting are locked upon creation, making alterations difficult without affecting the overall layout. It's preferred for formal documentation such as business reports and official electronic records.

formulaToImage: Whether to convert formulas to images (0: not enabled; 1: enabled). Default 0.If enabled, save as image; if not, save as text. For complex formulas, it is recommended to save as image.

Java Example:

You need to replace apiKey with the publicKey you obtained from the console, file with the file you want to convert, and language with the interface error prompt language type you want.

java
import java.io.*;
import okhttp3.*;
public class main {
  public static void main(String []args) throws IOException{
    OkHttpClient client = new OkHttpClient().newBuilder()
      .build();
    MediaType mediaType = MediaType.parse("text/plain");
    RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
      .addFormDataPart("file","{{file}}",
 RequestBody.create(MediaType.parse("application/octet-stream"),
                                          new File("<file>")))
      .addFormDataPart("language","{{language}}")
      .addFormDataPart("password","")
      .addFormDataPart("parameter","{  \"isContainImg\": 1}")
      .build();
    Request request = new Request.Builder()
      .url("https://api-server.compdf.com/server/v1/process/pdf/docx")
      .method("POST", body)
      .addHeader("x-api-key", "{{apiKey}}")
      .build();
    Response response = client.newCall(request).execute();
  }
}

Result:

File TypeDescription
.docxThe Word file after the transfer process is completed