hebrew-document-generator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHebrew Document Generator
希伯来语文档生成器
Instructions
使用说明
Step 1: Choose the Output Format
步骤1:选择输出格式
| Format | Library | Best For | RTL Support |
|---|---|---|---|
| reportlab | Invoices, tax docs, printable forms | Register Hebrew font, use | |
| WeasyPrint | Styled documents from HTML/CSS | Native via | |
| DOCX | python-docx | Contracts, proposals, meeting minutes | Set paragraph |
| PPTX | pptxgenjs (Node) | Presentations, slide decks | RTL text boxes with |
| 格式 | 库 | 适用场景 | RTL支持方式 |
|---|---|---|---|
| reportlab | 发票、税务文档、可打印表单 | 注册希伯来语字体,使用 | |
| WeasyPrint | 基于HTML/CSS的样式化文档 | 通过HTML中的 | |
| DOCX | python-docx | 合同、报价单、会议纪要 | 设置段落 |
| PPTX | pptxgenjs (Node) | 演示文稿、幻灯片 | 启用 |
Step 2: Install Dependencies and Hebrew Fonts
步骤2:安装依赖包和希伯来语字体
Python PDF generation:
bash
pip install reportlab weasyprintPython DOCX generation:
bash
pip install python-docx python-bidiNode.js PPTX generation:
bash
npm install pptxgenjsRecommended Hebrew fonts (install on system):
| Font | Style | Best For | Source |
|---|---|---|---|
| Heebo | Sans-serif, modern | Web-style documents, invoices | Google Fonts |
| David | Classic serif | Legal contracts, formal letters | System (Windows/macOS) |
| Narkisim | Serif, elegant | Proposals, invitations | System (Windows) |
| Frank Ruehl | Traditional serif | Academic, literary | Google Fonts (Frank Ruhl Libre) |
| Rubik | Sans-serif, rounded | Presentations, marketing | Google Fonts |
| Assistant | Sans-serif, clean | Business correspondence | Google Fonts |
See for download links and installation instructions.
references/hebrew-fonts.mdPython PDF生成:
bash
pip install reportlab weasyprintPython DOCX生成:
bash
pip install python-docx python-bidiNode.js PPTX生成:
bash
npm install pptxgenjs推荐希伯来语字体(需安装到系统):
| 字体 | 样式 | 适用场景 | 来源 |
|---|---|---|---|
| Heebo | 无衬线、现代风格 | 网页风格文档、发票 | Google Fonts |
| David | 经典衬线 | 法律合同、正式信函 | 系统自带(Windows/macOS) |
| Narkisim | 衬线、优雅风格 | 报价单、邀请函 | 系统自带(Windows) |
| Frank Ruehl | 传统衬线 | 学术、文学文档 | Google Fonts(Frank Ruhl Libre) |
| Rubik | 无衬线、圆角风格 | 演示文稿、营销材料 | Google Fonts |
| Assistant | 无衬线、简洁风格 | 商务信函 | Google Fonts |
下载链接和安装说明请查看。
references/hebrew-fonts.mdStep 3: Generate Hebrew PDF with reportlab
步骤3:使用reportlab生成希伯来语PDF
See for the full generation pipeline.
scripts/generate_doc.pypython
from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.units import mm
from bidi import get_display # python-bidi 0.6.x; see note below完整生成流程请查看。
scripts/generate_doc.pypython
from reportlab.lib.pagesizes import A4
from reportlab.pdfgen import canvas
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.units import mm
from bidi import get_display # python-bidi 0.6.x; see note belowRegister Hebrew font
Register Hebrew font
pdfmetrics.registerFont(TTFont('Heebo', 'Heebo-Regular.ttf'))
pdfmetrics.registerFont(TTFont('Heebo-Bold', 'Heebo-Bold.ttf'))
def create_hebrew_pdf(filename, title, content_lines):
c = canvas.Canvas(filename, pagesize=A4)
width, height = A4
# Title -- right-aligned for RTL
c.setFont('Heebo-Bold', 18)
hebrew_title = get_display(title)
c.drawRightString(width - 20*mm, height - 30*mm, hebrew_title)
# Body lines
c.setFont('Heebo', 12)
y = height - 50*mm
for line in content_lines:
display_line = get_display(line)
c.drawRightString(width - 20*mm, y, display_line)
y -= 7*mm
c.save()
Key points for reportlab Hebrew:
- Always use `get_display()` from python-bidi to reorder characters
- Use `drawRightString()` for right-aligned RTL text
- Register TTF Hebrew fonts explicitly -- reportlab has no built-in Hebrew support
- Set line height to at least 1.5x font size for Hebrew readability
- **python-bidi import:** since python-bidi 0.5.0 the canonical import is `from bidi import get_display` (the old `from bidi.algorithm import get_display` path was removed). Current python-bidi is 0.6.x, which restored a parallel algorithm module but kept the top-level import as the recommended one. python-bidi 0.6.x also dropped support for Python below 3.9.
- **Multi-line text:** `drawRightString()` draws a single line and does NOT wrap. For any body text longer than one line, use reportlab's `Paragraph` flowable (from `reportlab.platypus`) with a right-aligned, RTL `ParagraphStyle` instead. The bundled `scripts/generate_doc.py` uses per-line `drawRightString` for compact fixed-layout documents (invoices, receipts); it will clip long Hebrew strings. Reach for `Paragraph` / platypus flowables for contracts or any wrapping body copy.pdfmetrics.registerFont(TTFont('Heebo', 'Heebo-Regular.ttf'))
pdfmetrics.registerFont(TTFont('Heebo-Bold', 'Heebo-Bold.ttf'))
def create_hebrew_pdf(filename, title, content_lines):
c = canvas.Canvas(filename, pagesize=A4)
width, height = A4
# Title -- right-aligned for RTL
c.setFont('Heebo-Bold', 18)
hebrew_title = get_display(title)
c.drawRightString(width - 20*mm, height - 30*mm, hebrew_title)
# Body lines
c.setFont('Heebo', 12)
y = height - 50*mm
for line in content_lines:
display_line = get_display(line)
c.drawRightString(width - 20*mm, y, display_line)
y -= 7*mm
c.save()
reportlab生成希伯来语文档的关键点:
- 必须使用python-bidi的`get_display()`对字符重新排序
- 使用`drawRightString()`实现RTL文本右对齐
- 显式注册TTF希伯来语字体——reportlab无内置希伯来语支持
- 行高至少设置为字体大小的1.5倍以保证希伯来语可读性
- **python-bidi导入说明:** 自python-bidi 0.5.0起,标准导入方式为`from bidi import get_display`(旧路径`from bidi.algorithm import get_display`已移除)。当前python-bidi版本为0.6.x,恢复了algorithm模块的并行路径,但仍推荐使用顶层导入。python-bidi 0.6.x不再支持Python 3.9以下版本。
- **多行文本:** `drawRightString()`仅绘制单行文本,不支持自动换行。对于超过一行的正文内容,请使用reportlab的`Paragraph`流式组件(来自`reportlab.platypus`),并设置右对齐的RTL`ParagraphStyle`。附带的`scripts/generate_doc.py`使用逐行`drawRightString`生成紧凑的固定布局文档(如发票、收据);长希伯来语字符串会被截断。合同或需要自动换行的正文内容请使用`Paragraph`/platypus流式组件。Mixed Hebrew / Latin / Digit Lines
希伯来语/拉丁语/数字混合行
The single most common RTL failure in generated documents is a line that mixes a Hebrew description with LTR numbers and a currency symbol, for example an invoice line item. handles the bidi reordering, but you must pass the whole logical string in one call so the algorithm sees the full context:
get_display()python
from bidi import get_display生成文档中最常见的RTL问题是希伯来语描述与LTR数字、货币符号混合的行(如发票明细项)。可处理双向排序,但必须传入完整的逻辑字符串,以便算法获取完整上下文:
get_display()python
from bidi import get_displayLogical order: Hebrew description, then qty, unit price, currency
Logical order: Hebrew description, then qty, unit price, currency
line = 'ייעוץ טכני (3 שעות) - 1,500.00 ש"ח'
c.setFont('Heebo', 11)
c.drawRightString(width - 20 * mm, y, get_display(line))
The digits, the comma, the period, and the parentheses all stay in their correct LTR positions because the bidi algorithm resolves them relative to the surrounding Hebrew. Do NOT split the line into pieces and reorder them yourself, and do NOT call `get_display()` on the Hebrew part only, both approaches break the number ordering.line = 'ייעוץ טכני (3 שעות) - 1,500.00 ש"ח'
c.setFont('Heebo', 11)
c.drawRightString(width - 20 * mm, y, get_display(line))
数字、逗号、句号和括号会保持正确的LTR位置,因为双向算法会根据周围的希伯来语内容自动解析。请勿自行拆分文本并重新排序,也请勿仅对希伯来语部分调用`get_display()`,这两种方式都会破坏数字顺序。Step 4: Generate Hebrew PDF with WeasyPrint
步骤4:使用WeasyPrint生成希伯来语PDF
python
from weasyprint import HTML
html_content = """
<!DOCTYPE html>
<html lang="he" dir="rtl">
<head>
<meta charset="utf-8">
<style>
@font-face {
font-family: 'Heebo';
src: url('Heebo-Regular.ttf');
}
body {
font-family: 'Heebo', sans-serif;
direction: rtl;
font-size: 12pt;
line-height: 1.7;
}
h1 { font-size: 18pt; text-align: start; }
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #333;
padding: 6px 10px;
text-align: start;
}
</style>
</head>
<body>
<h1>חשבונית מס</h1>
<!-- Document content here -->
</body>
</html>
"""
HTML(string=html_content).write_pdf('invoice.pdf')WeasyPrint advantages for Hebrew:
- Full CSS support including logical properties
- Native RTL via HTML attribute
dir - Tables render correctly in RTL
- Supports for custom Hebrew fonts
@font-face
python
from weasyprint import HTML
html_content = """
<!DOCTYPE html>
<html lang="he" dir="rtl">
<head>
<meta charset="utf-8">
<style>
@font-face {
font-family: 'Heebo';
src: url('Heebo-Regular.ttf');
}
body {
font-family: 'Heebo', sans-serif;
direction: rtl;
font-size: 12pt;
line-height: 1.7;
}
h1 { font-size: 18pt; text-align: start; }
table {
width: 100%;
border-collapse: collapse;
}
th, td {
border: 1px solid #333;
padding: 6px 10px;
text-align: start;
}
</style>
</head>
<body>
<h1>חשבונית מס</h1>
<!-- Document content here -->
</body>
</html>
"""
HTML(string=html_content).write_pdf('invoice.pdf')WeasyPrint处理希伯来语的优势:
- 完整支持CSS逻辑属性
- 通过HTML属性原生支持RTL
dir - 表格可正确渲染RTL布局
- 支持自定义希伯来语字体
@font-face
Step 5: Generate Hebrew DOCX with python-docx
步骤5:使用python-docx生成希伯来语DOCX
python
from docx import Document
from docx.shared import Pt, Inches
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.oxml.ns import qn
def set_paragraph_rtl(paragraph):
"""Set paragraph direction to RTL for Hebrew text."""
pPr = paragraph._p.get_or_add_pPr()
bidi = pPr.makeelement(qn('w:bidi'), {})
pPr.append(bidi)
paragraph.alignment = WD_ALIGN_PARAGRAPH.RIGHT
def set_run_rtl(run):
"""Set run direction to RTL."""
rPr = run._r.get_or_add_rPr()
rtl = rPr.makeelement(qn('w:rtl'), {})
rPr.append(rtl)
doc = Document()python
from docx import Document
from docx.shared import Pt, Inches
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.oxml.ns import qn
def set_paragraph_rtl(paragraph):
"""Set paragraph direction to RTL for Hebrew text."""
pPr = paragraph._p.get_or_add_pPr()
bidi = pPr.makeelement(qn('w:bidi'), {})
pPr.append(bidi)
paragraph.alignment = WD_ALIGN_PARAGRAPH.RIGHT
def set_run_rtl(run):
"""Set run direction to RTL."""
rPr = run._r.get_or_add_rPr()
rtl = rPr.makeelement(qn('w:rtl'), {})
rPr.append(rtl)
doc = Document()Set default font
Set default font
style = doc.styles['Normal']
font = style.font
font.name = 'David'
font.size = Pt(12)
style = doc.styles['Normal']
font = style.font
font.name = 'David'
font.size = Pt(12)
Add Hebrew heading
Add Hebrew heading
heading = doc.add_heading(level=1)
run = heading.add_run('חוזה שירותים')
set_run_rtl(run)
set_paragraph_rtl(heading)
heading = doc.add_heading(level=1)
run = heading.add_run('חוזה שירותים')
set_run_rtl(run)
set_paragraph_rtl(heading)
Add Hebrew paragraph
Add Hebrew paragraph
para = doc.add_paragraph()
run = para.add_run('הסכם זה נערך ונחתם ביום...')
run.font.name = 'David'
run.font.size = Pt(12)
set_run_rtl(run)
set_paragraph_rtl(para)
doc.save('contract.docx')
undefinedpara = doc.add_paragraph()
run = para.add_run('הסכם זה נערך ונחתם ביום...')
run.font.name = 'David'
run.font.size = Pt(12)
set_run_rtl(run)
set_paragraph_rtl(para)
doc.save('contract.docx')
undefinedStep 6: Generate Hebrew PPTX with pptxgenjs
步骤6:使用pptxgenjs生成希伯来语PPTX
javascript
const pptxgen = require('pptxgenjs');
const pptx = new pptxgen();
pptx.layout = 'LAYOUT_16x9';
pptx.rtlMode = true;
const slide = pptx.addSlide();
// Hebrew title
slide.addText('סקירה רבעונית', {
x: 0.5, y: 0.5, w: '90%', h: 1.0,
fontSize: 28,
fontFace: 'Heebo',
color: '1a1a2e',
align: 'right',
rtlMode: true,
bold: true,
});
// Hebrew bullet points
slide.addText([
{ text: 'תוצאות כספיות', options: { bullet: true, rtlMode: true } },
{ text: 'יעדים לרבעון הבא', options: { bullet: true, rtlMode: true } },
{ text: 'סיכום פעילות', options: { bullet: true, rtlMode: true } },
], {
x: 0.5, y: 2.0, w: '90%', h: 3.0,
fontSize: 18,
fontFace: 'Heebo',
align: 'right',
rtlMode: true,
});
pptx.writeFile({ fileName: 'quarterly-review.pptx' });javascript
const pptxgen = require('pptxgenjs');
const pptx = new pptxgen();
pptx.layout = 'LAYOUT_16x9';
pptx.rtlMode = true;
const slide = pptx.addSlide();
// Hebrew title
slide.addText('סקירה רבעונית', {
x: 0.5, y: 0.5, w: '90%', h: 1.0,
fontSize: 28,
fontFace: 'Heebo',
color: '1a1a2e',
align: 'right',
rtlMode: true,
bold: true,
});
// Hebrew bullet points
slide.addText([
{ text: 'תוצאות כספיות', options: { bullet: true, rtlMode: true } },
{ text: 'יעדים לרבעון הבא', options: { bullet: true, rtlMode: true } },
{ text: 'סיכום פעילות', options: { bullet: true, rtlMode: true } },
], {
x: 0.5, y: 2.0, w: '90%', h: 3.0,
fontSize: 18,
fontFace: 'Heebo',
align: 'right',
rtlMode: true,
});
pptx.writeFile({ fileName: 'quarterly-review.pptx' });Step 7: Israeli Business Document Templates
步骤7:以色列商务文档模板
See for complete field specifications per document type.
references/templates.md| Template | Hebrew Name | Required Fields |
|---|---|---|
| Tax Invoice | חשבונית מס | Business name, Osek Murshe number, date, line items, VAT (18%), total |
| Contract | חוזה | Parties, TZ/company numbers, terms, signatures, date |
| Price Proposal | הצעת מחיר | Business details, itemized pricing, validity period, terms |
| Meeting Minutes | פרוטוקול | Date, attendees, agenda, decisions, action items |
| Receipt | קבלה | Business name, receipt number, amount, payment method, date |
Tax Invoice (Heshbonit Mas) required fields by Israeli law:
- Business name and address
- Osek Murshe (authorized dealer) number
- Sequential invoice number
- Date of issue
- Customer name and TZ/company number
- Line items with description, quantity, unit price
- Subtotal, VAT at 18%, and total in NIS
各类文档的完整字段规范请查看。
references/templates.md| 模板 | 希伯来语名称 | 必填字段 |
|---|---|---|
| 税务发票 | חשבונית מס | 企业名称、Osek Murshe编号、日期、明细项、增值税(18%)、总计 |
| 合同 | חוזה | 双方信息、身份证/企业编号、条款、签名、日期 |
| 报价单 | הצעת מחיר | 企业详情、分项定价、有效期、条款 |
| 会议纪要 | פרוטוקול | 日期、参会人员、议程、决议、行动项 |
| 收据 | קבלה | 企业名称、收据编号、金额、支付方式、日期 |
以色列法律规定的税务发票(Heshbonit Mas)必填字段:
- 企业名称和地址
- Osek Murshe(授权经销商)编号
- 连续发票编号
- 开具日期
- 客户名称和身份证/企业编号
- 含描述、数量、单价的明细项
- 小计、18%增值税、新以色列谢克尔(NIS)总计
Examples
示例
Example 1: Generate Tax Invoice PDF
示例1:生成税务发票PDF
User says: "Create a Hebrew tax invoice PDF for my business"
Result: Use reportlab or WeasyPrint to generate A4 PDF with RTL layout, business header, sequential invoice number, itemized table, VAT calculation at 18%, totals in NIS with shekel symbol, and Hebrew font throughout.
用户需求:“为我的企业创建希伯来语税务发票PDF”
结果:使用reportlab或WeasyPrint生成A4尺寸的PDF,包含RTL布局、企业页眉、连续发票编号、分项表格、18%增值税计算、带谢克尔符号的NIS总计,全程使用希伯来语字体。
Example 2: Create Hebrew Contract DOCX
示例2:创建希伯来语合同DOCX
User says: "Draft a Hebrew service contract as a Word document"
Result: Use python-docx with bidi paragraph support, David font, RTL alignment, structured sections (parties, scope, payment terms, termination, signatures), proper Hebrew legal phrasing.
用户需求:“起草一份希伯来语服务合同Word文档”
结果:使用支持双向段落的python-docx,采用David字体、RTL对齐,包含结构化章节(双方信息、服务范围、付款条款、终止条款、签名),使用标准希伯来语法律措辞。
Example 3: Build Hebrew Presentation
示例3:制作希伯来语演示文稿
User says: "Make a Hebrew PowerPoint for our quarterly review"
Result: Use pptxgenjs with rtlMode enabled, Heebo font, right-aligned text boxes, RTL bullet points, Hebrew slide titles, and professional layout.
用户需求:“为我们的季度评审制作希伯来语PowerPoint”
结果:使用启用rtlMode的pptxgenjs,采用Heebo字体、右对齐文本框、RTL项目符号、希伯来语幻灯片标题,搭配专业布局。
Example 4: Batch Document Generation
示例4:批量生成文档
User says: "Generate 50 Hebrew invoices from a CSV file"
Result: Read CSV data, iterate rows, use to produce individual PDFs with unique invoice numbers, customer details, and line items per row.
scripts/generate_doc.py用户需求:“从CSV文件生成50份希伯来语发票”
结果:读取CSV数据,遍历每一行,使用生成包含唯一发票编号、客户详情和对应明细项的独立PDF。
scripts/generate_doc.pyBundled Resources
附带资源
Scripts
脚本
- - Generate Hebrew PDF documents with reportlab: register Hebrew fonts, apply RTL text reordering with python-bidi, produce Israeli business documents (invoices, receipts) with proper VAT calculations and NIS formatting. Run:
scripts/generate_doc.pypython scripts/generate_doc.py --help
- - 使用reportlab生成希伯来语PDF文档:注册希伯来语字体,通过python-bidi实现RTL文本重排序,生成符合要求的以色列商务文档(发票、收据),包含正确的增值税计算和NIS格式。运行方式:
scripts/generate_doc.pypython scripts/generate_doc.py --help
References
参考文档
- - Hebrew font catalog with recommended fonts for different document types (sans-serif, serif, monospace), Google Fonts download links, system font availability matrix, font pairing suggestions, and installation instructions for macOS, Linux, and Windows.
references/hebrew-fonts.md - - Israeli business document templates with required fields per document type (tax invoice, contract, proposal, receipt, meeting minutes), Israeli legal requirements for invoices, VAT rules, and standard Hebrew business phrasing.
references/templates.md
- - 希伯来语字体目录,包含不同文档类型推荐字体(无衬线、衬线等)、Google Fonts下载链接、系统字体可用性矩阵、字体搭配建议,以及macOS、Linux、Windows系统的安装说明。
references/hebrew-fonts.md - - 以色列商务文档模板,包含各类文档(税务发票、合同、报价单、收据、会议纪要)的必填字段、以色列发票法律要求、增值税规则和标准希伯来语商务措辞。
references/templates.md
Reference Links
参考链接
| Source | URL | What to Check |
|---|---|---|
| reportlab documentation | https://docs.reportlab.com/ | Canvas API, platypus flowables, font registration |
| WeasyPrint documentation | https://doc.courtbouillon.org/weasyprint/stable/ | HTML/CSS to PDF, RTL support, @font-face |
| python-docx documentation | https://python-docx.readthedocs.io/ | Document model, runs, paragraph properties |
| python-bidi (PyPI) | https://pypi.org/project/python-bidi/ | Current version, import path, changelog |
| Israeli tax invoice requirements | https://he.wikipedia.org/wiki/%D7%97%D7%A9%D7%91%D7%95%D7%A0%D7%99%D7%AA_%D7%9E%D7%A1 | Mandatory fields for a Heshbonit Mas; cross-check against current Israel Tax Authority rules |
For binding legal requirements always confirm against the current Israel Tax Authority (Rashut HaMisim) guidance, the Wikipedia entry is a starting orientation, not the authority.
| 来源 | URL | 查看内容 |
|---|---|---|
| reportlab文档 | https://docs.reportlab.com/ | Canvas API、platypus流式组件、字体注册 |
| WeasyPrint文档 | https://doc.courtbouillon.org/weasyprint/stable/ | HTML/CSS转PDF、RTL支持、@font-face |
| python-docx文档 | https://python-docx.readthedocs.io/ | 文档模型、运行属性、段落属性 |
| python-bidi(PyPI) | https://pypi.org/project/python-bidi/ | 当前版本、导入路径、更新日志 |
| 以色列税务发票要求 | https://he.wikipedia.org/wiki/%D7%97%D7%A9%D7%91%D7%95%D7%A0%D7%99%D7%AA_%D7%9E%D7%A1 | Heshbonit Mas必填字段;请与以色列税务局现行规则交叉验证 |
法律相关要求请始终以以色列税务局(Rashut HaMisim)的最新指南为准,维基百科条目仅作为入门参考,不具备权威效力。
Recommended MCP Servers
推荐MCP服务器
No MCP server applies to this skill. Hebrew document generation runs entirely through local Python and Node libraries (reportlab, WeasyPrint, python-docx, pptxgenjs); there is no external service to wrap as an MCP server. Use the bundled scripts and the code in the Instructions section directly.
本技能无需MCP服务器。希伯来语文档生成完全通过本地Python和Node库(reportlab、WeasyPrint、python-docx、pptxgenjs)实现;无需封装外部服务为MCP服务器。直接使用附带脚本和使用说明中的代码即可。
Gotchas
注意事项
- must be applied per line at draw time, immediately before
get_display(), NOT once on a whole multi-line document or block. The bidi algorithm is not idempotent: running it on text that was already reordered double-reverses the characters and produces scrambled output. A common agent mistake is to "pre-process" a whole list of lines throughdrawRightString()and then call it again inside the draw loop.get_display() - PDF generators often default to left-to-right text flow. Hebrew documents MUST use RTL paragraph direction, and mixed Hebrew-English text requires proper BiDi (bidirectional) algorithm support.
- Agents may pick fonts that lack Hebrew character support (e.g., Arial works, but many decorative Latin fonts do not). Always verify the font includes the Hebrew Unicode range (U+0590-U+05FF).
- Hebrew date formatting uses DD/MM/YYYY in secular context and Hebrew calendar dates (e.g., 15 Adar 5786) for religious/traditional documents. Agents may default to MM/DD/YYYY.
- Legal documents in Israel require specific formatting: nikud (vowel marks) is NOT used in standard business/legal Hebrew. Agents may add nikud thinking it improves clarity, but it actually looks unprofessional in formal documents.
- 必须在绘制时逐行调用,即紧接在
get_display()之前,而非对整个多行文档或文本块一次性预处理。双向算法不具备幂等性:对已排序的文本再次调用会导致字符反向两次,产生乱码。常见错误是提前将所有行通过drawRightString()预处理,然后在绘制循环中再次调用。get_display() - PDF生成器通常默认左到右文本流。希伯来语文档必须使用RTL段落方向,希伯来语-英语混合文本需要正确的双向(BiDi)算法支持。
- 可能会选择不支持希伯来语字符的字体(如Arial可用,但许多装饰性拉丁语字体不可用)。请始终验证字体包含希伯来语Unicode范围(U+0590-U+05FF)。
- 希伯来语日期格式在世俗场景中使用DD/MM/YYYY,宗教/传统文档使用希伯来日历日期(如15 Adar 5786)。默认可能会使用MM/DD/YYYY格式。
- 以色列法律文档有特定格式要求:标准商务/法律希伯来语不使用nikud(元音标记)。若添加nikud可能会被认为是不专业的做法,而非提升清晰度。
Troubleshooting
故障排除
Error: "Hebrew characters display as boxes or question marks"
错误:“希伯来语字符显示为方框或问号”
Cause: Hebrew font not registered or not found on system
Solution: Download a Hebrew TTF font (e.g., Heebo from Google Fonts), register it with for reportlab, or install it as a system font for WeasyPrint.
pdfmetrics.registerFont()原因:希伯来语字体未注册或系统中未找到
解决方案:下载希伯来语TTF字体(如Google Fonts的Heebo),在reportlab中使用注册,或为WeasyPrint安装为系统字体。
pdfmetrics.registerFont()Error: "Text appears left-to-right instead of right-to-left"
错误:“文本显示为左到右而非右到左”
Cause: Missing bidi reordering or RTL direction setting
Solution: For reportlab, apply from python-bidi. For python-docx, call and . For WeasyPrint, ensure on the HTML element.
get_display()set_paragraph_rtl()set_run_rtl()dir="rtl"原因:缺少双向排序或RTL方向设置
解决方案:reportlab需应用python-bidi的;python-docx需调用和;WeasyPrint需确保HTML元素设置。
get_display()set_paragraph_rtl()set_run_rtl()dir="rtl"Error: "Numbers and punctuation in wrong position"
错误:“数字和标点位置错误”
Cause: Bidirectional text algorithm not handling mixed Hebrew/number content
Solution: Wrap numeric sequences in LTR marks. In reportlab, use with . In HTML-based tools, ensure proper on embedded LTR spans.
get_display()base_dir='R'unicode-bidi: isolate原因:双向文本算法未处理希伯来语/数字混合内容
解决方案:将数字序列包裹在LTR标记中。reportlab中使用并设置;基于HTML的工具需确保嵌入的LTR span设置。
get_display()base_dir='R'unicode-bidi: isolate