# DOCX 파일을 PDF 파일로 변환



DOCX 문서 한 개를 업로드해 PDF 파일로 받습니다. 응답은 JSON이 아닌 PDF 파일입니다.



인증: Authorization: Bearer $APICK_API_KEY

본문 있는 REST 요청: multipart/form-data. GET 본문 및 MCP JSON-RPC 규격은 해당 명세를 따릅니다.

인증키는 서버에 보관하세요. 모든 예제는 정적 자료입니다.



## POST /rest/docx_to_pdf 응답 필드

## API 요청: POST /rest/docx_to_pdf



### 입력

- `docx` (file, 필수): 변환할 DOCX 파일 한 개입니다. multipart/form-data로 전송하며, 파일 경로가 아니라 파일 본문을 첨부합니다.



### 응답 명세

```json

{
  "type": "object",
  "properties": {}
}

```

### curl

```curl

curl --fail-with-body --request POST 'https://apick.app/rest/docx_to_pdf' \
  --header "Authorization: Bearer $APICK_API_KEY" \
  --form 'docx=@document.docx' \
  --dump-header response.headers --output result.bin
# response.headers의 Content-Type을 확인한 뒤 파일을 사용하세요.

```

### Node.js (서버 ESM)

```javascript

import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("docx", new Blob([await readFile("document.docx")]), "document.docx");
const response = await fetch("https://apick.app/rest/docx_to_pdf", {
  method: "POST",
  headers: { Authorization: "Bearer " + process.env.APICK_API_KEY },
  body: form,
  signal: AbortSignal.timeout(120_000),
});
if (!response.ok) throw new Error(`HTTP ${response.status}: ${await response.text()}`);
if ((response.headers.get("content-type") || "").includes("json")) {
  throw new Error(JSON.stringify(await response.json()));
}
const { writeFile } = await import("node:fs/promises");
await writeFile("result.bin", new Uint8Array(await response.arrayBuffer()));

```

### python

```python

import os
import requests
parts = [
    ("docx", ("document.docx", open("document.docx", "rb"))),
]
response = requests.request("POST", "https://apick.app/rest/docx_to_pdf",
    headers={"Authorization": "Bearer " + os.environ["APICK_API_KEY"]},
    files=parts,
    timeout=(10, 120), stream=True)
response.raise_for_status()
if "json" in response.headers.get("Content-Type", ""):
    raise RuntimeError(response.json())
with open("result.bin", "wb") as output:
    for chunk in response.iter_content(65536):
        output.write(chunk)

```

### php

```php

<?php
$headers = ["Authorization: Bearer " . getenv("APICK_API_KEY")];
$form = [
    'docx' => new CURLFile('document.docx'),
];
$curl = curl_init('https://apick.app/rest/docx_to_pdf');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => $headers,
    CURLOPT_POSTFIELDS => $form,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_TIMEOUT => 120,
]);
$body = curl_exec($curl);
if ($body === false) { throw new RuntimeException(curl_error($curl)); }
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
$type = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: "";
curl_close($curl);
if ($status >= 400) { throw new RuntimeException($body); }
if (strpos($type, "json") !== false) { throw new RuntimeException($body); }
file_put_contents('result.bin', $body);

```

## 사용 예시 1. 견적서 DOCX를 PDF로

Word로 만든 문서를 고객에게 보내기 전에 PDF로 고정합니다.

```bash

curl --fail-with-body --request POST 'https://apick.app/rest/docx_to_pdf' \
  --header "Authorization: Bearer $APICK_API_KEY" \
  --form 'docx=@./quote.docx' \
  --dump-header response.headers --output result.bin
# response.headers의 Content-Type을 확인한 뒤 파일을 사용하세요.

```

- 응답 헤더 `success`가 1이고 `Content-Type`이 `application/pdf`이면 본문을 PDF로 저장합니다.

- HTTP 424이면 `data.error`를 확인하고 필드 이름이 `docx`인지 점검하세요.

## 사용 예시 2. 변환 실패 시 다시 저장해서 요청

오래된 형식이나 손상된 문서는 실패할 수 있습니다. 문서 편집기에서 DOCX로 다시 저장한 파일로 요청합니다.

```bash

curl --fail-with-body --request POST 'https://apick.app/rest/docx_to_pdf' \
  --header "Authorization: Bearer $APICK_API_KEY" \
  --form 'docx=@./resaved.docx' \
  --dump-header response.headers --output result.bin
# response.headers의 Content-Type을 확인한 뒤 파일을 사용하세요.

```

- 실패 응답은 과금되지 않습니다(`api.cost` 0). 같은 파일로 자동 반복 호출하지 마세요.

## 코드·오류

## 상세 기능·요금

이용 전 확인 견적서·계약서처럼 Word로 만든 문서를 고객에게 보내거나 보관용으로 고정할 때 사용합니다. DOCX 형식만 받으며, 예전 형식(DOC)은 DOCX로 다시 저장한 뒤 올리세요. 성공한 변환 건당 80P가 차감됩니다. 파일이 없거나 변환에 실패한 응답의 비용은 0P입니다. 실제 차감액은 응답의 cost 헤더에서 확인하세요. REST 요청의 첨부파일 합계는 1GiB 이하여야 합니다. 파일 크기와 문서 구성에 따라 변환 시간이 달라지며, 처리 시간이 초과되면 오류가 반환됩니다. MCP 도구에서 URL로 파일을 넘길 때는 25MiB까지 받습니다.

## 상세 요청

항목설정 메서드·주소POST https://apick.app/rest/docx_to_pdf 인증 헤더Authorization: Bearer 내 계정의 API 인증키 본문 형식multipart/form-data 요청 예시 환경변수에 인증키를 설정하고 document.docx를 준비한 뒤 실행합니다. 성공 시 과금되는 실제 요청입니다. form-data 전체 예제 보기 response-headers.txt에서 success: 1과 Content-Type: application/pdf를 확인한 뒤 response.bin을 PDF로 저장하세요. 오류 응답은 JSON이므로 파일 확장자만으로 성공을 판단하지 마세요.

## 상세 코드·정책

응답과 오류 복구 항목의미 성공 본문PDF 바이너리. 내려받기 파일명은 output.pdf입니다. 성공 헤더success: 1, 차감 포인트 cost, 처리시간 ms, URI 인코딩된 안내 msg HTTP 424파일 누락 또는 변환 실패. data.error를 확인하고 DOCX 파일과 필드 이름 docx를 점검하세요. HTTP 408처리시간 초과. data.success: 3으로 구분합니다. 문서 크기를 줄인 뒤 다시 시도하세요. 오류 본문data.error, data.success, api.cost, api.success, api.ms를 확인합니다. api.success만으로 파일 변환 성공을 판단하지 마세요. 연결이 끊겨 최종 결과를 받지 못했다면 이용 내역을 먼저 확인하세요. 자동으로 반복 호출하면 중복 변환과 추가 과금이 발생할 수 있습니다.

## 상세 예제

호출 예시 같은 요청을 JavaScript와 Python으로 옮긴 예시입니다. 키는 환경변수 APICK_API_KEY 에서 읽습니다. JavaScript 예시 form-data 전체 예제 보기 Python 예시 form-data 전체 예제 보기
