简体   繁体   中英

Strip type Pdf generating using reportlab in django

I want to create a strip type pdf in django using Reportlab. The output pdf should be in 79mm width and its height should be content height (endless). Can you help me to solve this problem? Thank you in advance.

The way the pagesize is set depends on whether you use PLATYPUS or just canvases. First to make sure that you get the proper height use pageWidth = 79 * mm (this requires from reportlab.lib.units import mm . The pageHeight is something you have to specify your self.

From there you can set the size based on the object used, in the case you use Platypus is done as follows:

baseDocTemplate(self, filename, pagesize=(pageWidth, pageHeight))

If you use a canvas is done like this:

canvas.setPageSize((pageWidth, pageHeight)) 

Reportlab also contains default pagesizes which are also pair like mentioned above they can be found in from reportlab.lib.pagesizes import letter, A4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM