In the previous article "Python reportlab library hello world" we demonstrated a simple Demo and used the Canvas object in the Demo.
This article will briefly introduce the Canvas object. First, let me take a look at the Canvas constructor
The filename parameter controls the name of the final PDF file
pagesize There are two parameters: width and height. The default size of canvas is A4 paper (American letter letters use A4). The specific demo is as follows
Running effect
The bottomup parameter is used for switching. coordinate system. Some systems set the (0,0) coordinate to the bottom left. bottomup may be removed in the future.
pageCompression Select whether to compress each page. The default page is not compressed because compression affects file processing speed. If pageCompression =1, then the file will be compressed to a minimum, but the generation time will also be extended. Note that images are always compressed. If you have a large number of articles and vector images that would cause the file size to become too large, using the pageCompression parameter will effectively reduce the file size.
The encoding parameter has been omitted in version 2.0, and you can basically ignore this parameter.
The verbosity parameter determines how much log information is printed. By default, verbosity is 0. If the value is 1, you will get the log information of the generated document. Higher values ??may produce more log output in the future.
The encrypt parameter determines whether the document is encrypted. By default, documents are not encrypted.