LibreOffice Extension을 사용하여, LibreOffice를 headless 모드로 실행하고 HWP 파일을 PDF 및 DOCX 형식으로 변환하는 API 서버입니다.
Palantir Foundry내에서의 HWP 파일 처리를 위해 개발하였습니다. Palantir Foundry의 Container Transforms에서 사용할 수 있도록 Image Requirements를 준수합니다.
.hwp.hwpx
.pdf.docx
-
Docker 이미지 빌드:
docker build -t hwp-converter-api . -
컨테이너 실행:
docker run -p 8800:8800 hwp-converter-api
-
Health Check:
curl http://localhost:8800/health
GET /healthResponse:
{
"status": "ok",
"message": "Server is running"
}POST /convertParameters:
file(required): HWP/HWPX file to convertoutput_format(optional): Output format -pdfordocx(default:pdf)
Example using curl:
curl -X POST "http://localhost:8800/convert" \
-H "accept: application/json" \
-H "Content-Type: multipart/form-data" \
-F "[email protected]" \
-F "output_format=pdf" \
--output converted.pdfExample using Python:
import requests
url = "http://localhost:8800/convert"
files = {"file": open("document.hwp", "rb")}
data = {"output_format": "pdf"}
response = requests.post(url, files=files, data=data)
if response.status_code == 200:
with open("converted.pdf", "wb") as f:
f.write(response.content)
print("Conversion successful!")
else:
print(f"Error: {response.json()}")The API returns appropriate HTTP status codes and error messages:
400 Bad Request: Unsupported file type or invalid output format500 Internal Server Error: Conversion failure or file processing error
Error responses include detailed information:
{
"error": "Unsupported file type",
"detail": "Only .hwp, .hwpx files are supported"
}