# HTML PDF 변환



HTML 코드를 PDF 파일로 변환합니다.



인증: Authorization: Bearer $APICK_API_KEY

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

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



## POST /rest/html_to_pdf 응답 필드

## API 요청: POST /rest/html_to_pdf



### 입력

- `html` (string, 필수): 변환할 HTML 코드

- `pagination` (integer, 필수): 페이지 번호 표시 여부 (0: 없음(기본값), 1: 표시)



### 응답 명세

```json

{
  "type": "string",
  "format": "binary"
}

```

### curl

```curl

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

```

### Node.js (서버 ESM)

```javascript

const form = new FormData();
form.append("html", "$HTML_CODE");
form.append("pagination", "1");
const response = await fetch("https://apick.app/rest/html_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 = [
    ("html", (None, "$HTML_CODE")),
    ("pagination", (None, "1")),
]
response = requests.request("POST", "https://apick.app/rest/html_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 = [
    'html' => '$HTML_CODE',
    'pagination' => '1',
];
$curl = curl_init('https://apick.app/rest/html_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);

```

## 코드·오류

## 상세 기능·요금

Method URL POST https://apick.app/rest/html_to_pdf

## 상세 요청

Header 이름 필수 설명 Authorization O Bearer 인증키

## 상세 응답

Header 이름 필수 설명 success O API 서버 정상 응답 여부 cost O API 호출 요금 ms O API 응답 시간 Content-Type O 응답 바디 데이터 타입 Content-Disposition O 파일명(output 고정) Body 이름 타입 설명 PDF 형식의 바이너리 데이터

## 상세 예제

요청 예시 form-data 전체 예제 보기 응답 예시 {PDF 형식의 바이너리 데이터}
