![]() |
|
Right to left alignment in python report using Reportlab - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Right to left alignment in python report using Reportlab (/thread-38279.html) |
Right to left alignment in python report using Reportlab - jalal0034 - Sep-25-2022 Hi Everyone, How can I write Right to left passage in Report lab in persian language using Reportlab ? my code returns this file : ![]() here is my code : def grouper(iterable, n):
args = [iter(iterable)] * n
return itertools.zip_longest(*args)
def export_to_pdf(data):
c = canvas.Canvas("Report.pdf", pagesize=A4)
w, h = A4
max_rows_per_page = 35
# Margin.
x_offset = 50
y_offset = 50
# Space between rows.
padding = 15
xlist = [x + x_offset for x in [0, 500]]
ylist = [h -100 - y_offset - i*padding for i in range(max_rows_per_page + 1)]
for rows in grouper(data, max_rows_per_page):
rows = tuple(filter(bool, rows))
c.grid(xlist, ylist[:len(rows) + 1])
for y, row in zip(ylist[:-1], rows):
for x, cell in zip(xlist, row):
c.drawString(x + 2, y - padding + 3, str(cell))
c.showPage()
c.save()
os.startfile('report.pdf')
def utf8_converter(text):
reshaped_text = arabic_reshaper.reshape(text)
bidi_text = get_display(reshaped_text)
return bidi_text
RE: Raight to left alignment in python report using Reportlab - jalal0034 - Sep-27-2022 This link may help |