我正在使用ReportlabSimpleDocTemplate
创建pdf文件。我必须写(画)多个图像行,这样我可以调整文件中的许多图像。在
class PrintBarCodes(View):
def get(self, request, format=None):
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment;\
filename="barcodes.pdf"'
# Close the PDF object cleanly, and we're done.
ean = barcode.get('ean13', '123456789102', writer=ImageWriter())
filename = ean.save('ean13')
doc = SimpleDocTemplate(response, pagesize=A4)
parts = []
parts.append(Image(filename))
doc.build(parts)
return response
在代码中,我打印了一个条形码到文件中。输出显示在图像中,如下所示。在
但是,我需要画一些条形码。如何在绘图到pdf文件之前减小图像大小并按行调整?在
由于你的问题表明你需要灵活性,我认为最明智的方法是使用
Flowable
的。条形码通常不是一个,但我们可以很容易地make it one。{让我们来决定你的条码在多大的空间里。在所以第一步是
Barcode
Flowable
,如下所示:然后回答您的问题,现在在一个页面上放置多个条形码的最简单方法是使用
^{pr2}$Table
,如下所示:哪些输出:
相关问题 更多 >
编程相关推荐