Markdown에서 생성
Markdown 콘텐츠를 올바르게 서식이 지정된 PDF 문서로 변환합니다. 제목, 단락, 볼드/이탈릭 텍스트, 목록, 코드 블록, 인용문 등을 지원합니다.
빠른 예제
Python
from pdf_oxide import Pdf
pdf = Pdf.from_markdown("# Hello\n\nWorld")
pdf.save("out.pdf")
WASM
import { WasmPdf } from "pdf-oxide-wasm";
import { writeFileSync } from "fs";
const pdf = WasmPdf.fromMarkdown("# Hello\n\nWorld");
writeFileSync("out.pdf", pdf.toBytes());
Rust
use pdf_oxide::api::Pdf;
let pdf = Pdf::from_markdown("# Hello\n\nWorld")?;
pdf.save("out.pdf")?;
지원되는 Markdown 구문
| 요소 | Markdown | 설명 |
|---|---|---|
| 제목 1 | # 제목 |
최상위 굵은 제목 |
| 제목 2 | ## 섹션 |
중간 크기 굵은 제목 |
| 제목 3 | ### 서브섹션 |
작은 제목 |
| 제목 4–6 | #### ... |
부차적 제목 |
| 단락 | 빈 줄로 구분한 일반 텍스트 | 자동 줄 바꿈이 있는 본문 텍스트 |
| 굵게 | **bold** |
굵은 텍스트 |
| 기울임 | *italic* |
기울임꼴 텍스트 |
| 번호 없는 목록 | - 항목 또는 * 항목 |
글머리 기호 목록 |
| 번호 목록 | 1. 항목 |
번호 목록 |
| 코드 블록 | ```로 감싼 블록 |
고정폭 코드 |
| 인라인 코드 | `code` |
인라인 고정폭 텍스트 |
| 인용구 | > 인용 텍스트 |
들여쓰기된 인용문 |
전체 API 레퍼런스
Pdf::from_markdown(content) (정적 메서드)
기본 설정(Letter 페이지, 72pt 여백, 12pt Helvetica)으로 Markdown 콘텐츠에서 PDF를 생성합니다.
Rust:
use pdf_oxide::api::Pdf;
let pdf = Pdf::from_markdown("# Report\n\nFindings are summarized below.")?;
pdf.save("report.pdf")?;
JavaScript:
import { WasmPdf } from "pdf-oxide-wasm";
import { writeFileSync } from "fs";
const pdf = WasmPdf.fromMarkdown("# Report\n\nFindings are summarized below.");
writeFileSync("report.pdf", pdf.toBytes());
Python:
from pdf_oxide import Pdf
pdf = Pdf.from_markdown("# Report\n\nFindings are summarized below.")
pdf.save("report.pdf")
Python Signature:
Pdf.from_markdown(
content: str,
title: str | None = None,
author: str | None = None
) -> Pdf
PdfBuilder::new().from_markdown(content) (빌더 패턴)
페이지 크기, 여백, 폰트 크기, 메타데이터를 제어해야 할 때 PdfBuilder를 사용합니다.
Rust:
use pdf_oxide::api::PdfBuilder;
use pdf_oxide::writer::PageSize;
let pdf = PdfBuilder::new()
.title("Quarterly Report")
.author("Finance Team")
.page_size(PageSize::A4)
.margin(54.0) // 0.75 inch margins
.font_size(11.0)
.line_height(1.6)
.from_markdown("# Q4 Report\n\n## Revenue\n\nRevenue grew **12%** year-over-year.")?;
pdf.save("quarterly.pdf")?;
고급 예제
다중 섹션 문서
use pdf_oxide::api::Pdf;
let markdown = r#"
# Annual Report 2025
## Executive Summary
The company achieved **record growth** in all key metrics.
## Financial Highlights
- Revenue: $142M (+18%)
- Net Income: $31M (+24%)
- Operating Margin: 21.8%
## Strategic Priorities
1. Expand international presence
2. Launch next-generation platform
3. Invest in R&D capabilities
### Timeline
> Phase 1 launches in Q2, with full rollout expected by Q4.
## Technical Appendix
```json
{
"version": "2.1.0",
"release_date": "2025-03-15"
}
"#;
let pdf = Pdf::from_markdown(markdown)?; pdf.save(“annual_report.pdf”)?;
### Python에서 메타데이터 사용
```python
from pdf_oxide import Pdf
content = """
# Meeting 비고
## Attendees
- Alice (Engineering)
- Bob (Product)
- Carol (Design)
## Action Items
1. **Alice**: Complete API review by Friday
2. **Bob**: Update roadmap with new timeline
3. **Carol**: Share mockups for dashboard redesign
"""
pdf = Pdf.from_markdown(content, title="Meeting 비고", author="Alice")
pdf.save("meeting_notes.pdf")
파일에서 Markdown 읽기
from pdf_oxide import Pdf
with open("README.md") as f:
content = f.read()
pdf = Pdf.from_markdown(content, title="README")
pdf.save("readme.pdf")
import { WasmPdf } from "pdf-oxide-wasm";
import { readFileSync, writeFileSync } from "fs";
const content = readFileSync("README.md", "utf-8");
const pdf = WasmPdf.fromMarkdown(content);
writeFileSync("readme.pdf", pdf.toBytes());
use pdf_oxide::api::Pdf;
let content = std::fs::read_to_string("README.md")?;
let pdf = Pdf::from_markdown(&content)?;
pdf.save("readme.pdf")?;
관련 페이지
- HTML에서 PDF 생성 — HTML을 PDF로 변환
- PdfBuilder 플루언트 API — 빌더의 전체 설정 옵션
- DocumentBuilder 저수준 API — 프로그래밍 방식의 페이지 구성