HTML 파일을 PDF로 변환
Convert an entire HTML file into a pixel-perfect PDF with IronPDF for Python’s RenderHtmlFileAsPdf method.
시작하기
To convert an HTML file to PDF, you can use the RenderHtmlFileAsPdf method. This method requires only the path to the local HTML file and returns a PdfDocument object. 이 객체는 HTML 파일의 내용을 웹 브라우저에서 보는 것처럼 렌더링한 형태로 담고 있습니다. 렌더링 문제를 방지하려면 HTML에 유효한 마크업이 포함되어 있는지 확인하십시오.
다음은 해당 방법을 사용하는 간단한 예입니다.
코드 이해하기
ChromePdfRenderer : 이 객체는 렌더링 프로세스와의 상호 작용 지점 역할을 합니다. 이 기능을 사용하면 머리글, 바닥글 등의 속성을 설정하여 PDF 출력물을 조정할 수 있습니다.
ChromePdfRenderer: This method takes a path to an HTML file and converts it into aPdfDocument. 생성된 PDF 파일은 웹 브라우저에 표시되는 HTML 파일과 거의 동일합니다.save_as: This method saves the newly created PDF document to the specified path on your file system.
PDF 출력 사용자 지정
ChromePdfRenderer comes with various options for customization, including setting headers, footers, margins, backgrounds, page numbers, etc. For more advanced features and customization, see this code example and learn how to customize PDF output.






