有什么方法可以让我在 reportlab 中获得 Flowable Paragraph 的行数?我有一个用不同大小和字体打印的很长的字符串。我需要知道使用 TA_JUSTIFY 对齐方式打印的整个段落使用了多少行。
这能做到吗?
下面是我的示例 python 文件
import os
import sys
import string
import pprint
import imp
import tempfile
from reportlab.pdfgen import canvas
from reportlab.platypus import Preformatted, XPreformatted, Paragraph, Frame, Image, \
Table, TableStyle, Spacer
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
from reportlab.lib import styles
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.pagesizes import *
from reportlab.lib import colors
import reportlab.rl_config
# Import as may be needed if we require embedded true type fonts
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.fonts import addMapping
from reportlab.graphics.barcode import code39, code128, code93
from reportlab.graphics.barcode import common
from reportlab.graphics.barcode import qr
from reportlab.graphics import renderPDF
from reportlab.graphics.shapes import Drawing
import string
import os
import imp
from reportlab.lib import colors
canv = canvas.Canvas('Output.pdf')
styles = getSampleStyleSheet()
parastyle = ParagraphStyle(name='Justify', alignment=TA_JUSTIFY)
parastyle.leading = 12
parastyle.fontSize = 11
styles.add(parastyle)
我需要获取段落中打印的行数。在我的例子中,我必须得到 11。
如果我更改字体和字体大小,我必须相应地获取值。
元芳怎么了
临摹微笑
相关分类