--- xhtml2pdf/context.py 2020-01-18 14:03:21.000000000 +0800
+++ xhtml2pdf/context.py 2026-01-27 06:03:42.000000000 +0800
@@ -11,8 +11,19 @@
from reportlab.lib.styles import ParagraphStyle
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
-from reportlab.platypus.frames import Frame, ShowBoundaryValue
from reportlab.platypus.paraparser import ParaFrag, ps2tt, tt2ps
+from reportlab.platypus.frames import Frame
+try:
+ from reportlab.platypus.frames import ShowBoundaryValue
+except ImportError:
+ # ShowBoundaryValue was removed in ReportLab 4.0+
+ class ShowBoundaryValue:
+ def __init__(self, color=None, width=None):
+ self.color = color
+ self.width = width
+ def __bool__(self):
+ return self.color is not None or self.width is not None
+
import six
import xhtml2pdf.default
--- xhtml2pdf/xhtml2pdf_reportlab.py 2020-01-18 14:03:21.000000000 +0800
+++ xhtml2pdf/xhtml2pdf_reportlab.py 2026-01-27 06:09:20.000000000 +0800
@@ -17,8 +17,13 @@
from hashlib import md5
from reportlab.lib.enums import TA_RIGHT
from reportlab.lib.styles import ParagraphStyle
-from reportlab.lib.utils import flatten, open_for_read, getStringIO, \
+from reportlab.lib.utils import flatten, open_for_read, \
LazyImageReader, haveImages
+try:
+ from reportlab.lib.utils import getStringIO
+except ImportError:
+ # getStringIO was removed in newer ReportLab versions
+ from io import BytesIO as getStringIO
from reportlab.platypus.doctemplate import BaseDocTemplate, PageTemplate, IndexingFlowable
from reportlab.platypus.flowables import Flowable, CondPageBreak, \
KeepInFrame, ParagraphAndImage