Python Reportlab
:
私のpdf
ような特殊文字を印刷しているときに問題に直面しています"&"
# -*- coding: utf-8 -*-
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.rl_config import defaultPageSize
from reportlab.lib.units import inch
styles = getSampleStyleSheet()
def myFirstPage(canvas, doc):
canvas.saveState()
def go():
doc = SimpleDocTemplate("phello.pdf")
Story = [Spacer(1,2*inch)]
Story.append(Paragraph("Some text", styles["Normal"]))
Story.append(Paragraph("Some other text with &", styles["Normal"]))
doc.build(Story, onFirstPage=myFirstPage)
go()
次の出力が期待されます
Some text
Some other text with &
しかし、私が得る出力は
Some text
Some other text with
「&」が消えた場所。
としてエンコードする必要があると言っているフォーラムをいくつか検索しまし&
たが、各特殊文字をエンコードするよりも簡単にこれを処理する方法はありませんか?
スクリプトの先頭に追加"# -*- coding: utf-8 -*-"
しましたが、問題は解決しません