Initial commit: 동물약 복약안내 PDF API
This commit is contained in:
66
test_render.py
Normal file
66
test_render.py
Normal file
@@ -0,0 +1,66 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
동물약 복약안내 PDF 테스트
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
|
||||
from animal_med import AnimalMedRenderer
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 60)
|
||||
print("동물약 복약안내 PDF 테스트")
|
||||
print("=" * 60)
|
||||
|
||||
renderer = AnimalMedRenderer()
|
||||
|
||||
# 약품 목록 확인
|
||||
print("\n[1] 등록된 약품 목록:")
|
||||
for drug in renderer.list_drugs():
|
||||
print(f" {drug['apc_code']} - {drug['name']} ({drug['category']})")
|
||||
|
||||
# PDF 렌더링 테스트 (3개 약품)
|
||||
test_codes = ["0519012001", "0519023002", "0519034003"]
|
||||
|
||||
print(f"\n[2] PDF 렌더링 테스트 ({len(test_codes)}개 약품)")
|
||||
print(f" APC 코드: {test_codes}")
|
||||
|
||||
output_dir = os.path.join(os.path.dirname(__file__), 'output')
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
pdf_path = os.path.join(output_dir, 'animal_medication_guide.pdf')
|
||||
|
||||
result = renderer.render_to_pdf(
|
||||
apc_codes=test_codes,
|
||||
output_path=pdf_path,
|
||||
patient_name="김철수",
|
||||
pet_name="뽀삐",
|
||||
pet_species="포메라니안",
|
||||
pet_age="3세"
|
||||
)
|
||||
|
||||
if result['success']:
|
||||
print(f" ✅ 성공!")
|
||||
print(f" 📄 PDF: {result['pdf_path']}")
|
||||
print(f" 약품: {', '.join(result['drugs'])}")
|
||||
|
||||
# 파일 크기
|
||||
size = os.path.getsize(pdf_path)
|
||||
print(f" 크기: {size / 1024:.1f} KB")
|
||||
|
||||
# PDF 페이지 수
|
||||
import fitz
|
||||
doc = fitz.open(pdf_path)
|
||||
print(f" 페이지 수: {len(doc)}")
|
||||
doc.close()
|
||||
else:
|
||||
print(f" ❌ 실패: {result.get('error')}")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user