From a5cc635816137164d53f5eb8c1ff2a5e0207868e Mon Sep 17 00:00:00 2001 From: zinzo Date: Fri, 17 Jan 2025 01:01:11 +0900 Subject: [PATCH] =?UTF-8?q?docs:=20README.md,=20LICENSE=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 21 ++++++++++++++ README.md | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 LICENSE create mode 100644 README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..2f39d39 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 LEE JIN JOO + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..dc53858 --- /dev/null +++ b/README.md @@ -0,0 +1,82 @@ +# PDF-MAKER +[![](https://jitpack.io/v/zinzoddari/pdf-maker.svg)](https://jitpack.io/#zinzoddari/pdf-maker)
+PDF-MAKER는 HTML 템플릿을 기반으로 PDF 파일을 생성할 수 있는 Java 라이브러리입니다.
+HTML 템플릿의 데이터 바인딩 및 PDF 암호화 기능을 제공하여 사용자 맞춤형 PDF를 생성할 수 있습니다. + +## 주요 기능 +- HTML 템플릿 렌더링: HTML 템플릿과 데이터를 결합하여 PDF 콘텐츠 생성. +- PDF 암호화: 사용자 및 소유자 비밀번호를 설정하고, 권한 제어 가능 (예: 인쇄 허용). +- 유연한 빌더 패턴: PdfMaker 빌더를 통해 간단한 PDF 생성 워크플로우 지원 + +## 설치 방법 +Gradle +pdf-maker는 [🔗JitPack](https://jitpack.io/#zinzoddari/pdf-maker)에 배포되어 있습니다. 아래와 같이 Gradle에 의존성을 추가해주세요. +- `build.gradle.kts` +```yml +repositories { + ... + maven("https://jitpack.io") +} +``` +```yml +dependencies { + implementation("com.github.zinzoddari:pdf-maker:v0.1.5") +} +``` + +## 사용법 +### 기본 설정 및 PDF 생성 +```java +public class Main { + + private static final String TEMPLATE_PATH = "src/main/resources/template/freemarkerReceipt.html"; + private static final String PDF_PATH = "temp.pdf"; + + public static void main(String[] args) throws IOException { + PdfMakerFactory factory = new PdfMakerFactory(new FreemarkerTemplateManager()); + + PdfMaker pdfMaker = factory.create() + .withTemplatePath(TEMPLATE_PATH) + .withData(new User("홍길동")) + .withUserPassword("user-pass") + .withOwnerPassword("owner-pass") + .withPermissions(PdfWriter.ALLOW_PRINTING) + .build(); + + try (OutputStream outputStream = new FileOutputStream(PDF_PATH)) { + pdfMaker.generate(outputStream); + } + } + + class User { + private final String name; + + public User(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } +} +``` +### 주요 메서드 설명 + - `withTemplatePath(String templatePath)`: HTML 템플릿 파일 경로를 설정합니다. + - `withData(T data)`: 템플릿에 바인딩할 데이터를 설정합니다. + - `withUserPassword(String userPassword)`: PDF 사용자 비밀번호를 설정합니다. + - `withOwnerPassword(String ownerPassword`: PDF 소유자 비밀번호를 설정합니다. + - `withPermissions(int permissions)`: PDF 권한을 설정합니다. (예: `PdfWriter.ALLOW_PRINTING`) + - bit 연산으로 `|`를 이용해 다중 설정이 가능합니다. + +## 사용 오픈소스 라이브러리 +`pdf-maker`는 다음 라이브러리를 사용하였습니다. +- [flying-saucer-pdf](https://github.com/flyingsaucerproject/flyingsaucer): HTML과 CSS 기반 PDF 생성 +- [Freemarker](https://github.com/apache/freemarker): 템플릿 엔진 + 기여 + +# 기여 +이 프로젝트에 기여하려면 이슈를 생성하거나 풀 리퀘스트를 제출해주세요. 기여는 언제나 환영입니다. 😁 + +# License +이 프로젝트는 [MIT 라이선스](https://opensource.org/license/mit) 하에 배포됩니다.