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 構文
| Syntax | Markdown | 説明 |
|---|---|---|
| Heading 1 | # Title |
大きい太字見出し |
| Heading 2 | ## Section |
中くらいの太字見出し |
| Heading 3 | ### Subsection |
小見出し |
| Heading 4-6 | #### ... |
マイナー見出し |
| Paragraph | Plain text with blank line | ワードラップ付き本文テキスト |
| Bold | **bold** |
太字テキスト |
| Italic | *italic* |
斜体テキスト |
| Unordered list | - item or * item |
箇条書きリスト |
| Ordered list | 1. item |
番号付きリスト |
| Code block | ``` fenced blocks |
等幅コード |
| Inline code | `code` |
Inline monospace |
| Blockquote | > quoted text |
Indented quotation |
完全な API リファレンス
Pdf::from_markdown(content) (Static Method)
デフォルト設定で Markdown から PDF を生成します(Letter サイズ、72pt マージン、Helvetica 12pt)。
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) (Builder Pattern)
Use PdfBuilder when you need control over page size, margins, font size, or metadata.
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 Notes
## 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 Notes", 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")?;
関連ページ
- Create from HTML – Convert HTMLからPDFへ
- PdfBuilder Fluent API – フルビルダー設定オプション
- DocumentBuilder Low-Level API – プログラム的ページ構築