Hướng dẫn xhtml2pdf --css - xhtml2pdf --css

Tôi đang cố gắng cải thiện PDF được tạo của mình được tạo bởi xhtml2pdf với một số CSS style trong

from xhtml2pdf import pisa             # import python module

# Define your data
source_html = "

To PDF or not to PDF

"
output_filename = "test.pdf" # Utility function def convert_html_to_pdf(source_html, output_filename): # open output file for writing (truncated binary) result_file = open(output_filename, "w+b") # convert HTML to PDF pisa_status = pisa.CreatePDF( source_html, # the HTML to convert dest=result_file) # file handle to recieve result # close output file result_file.close() # close output file # return False on success and True on errors return pisa_status.err # Main program if __name__ == "__main__": pisa.showLogging() convert_html_to_pdf(source_html, output_filename)
0 của tôi.

Tôi muốn ví dụ như

from xhtml2pdf import pisa             # import python module

# Define your data
source_html = "

To PDF or not to PDF

"
output_filename = "test.pdf" # Utility function def convert_html_to_pdf(source_html, output_filename): # open output file for writing (truncated binary) result_file = open(output_filename, "w+b") # convert HTML to PDF pisa_status = pisa.CreatePDF( source_html, # the HTML to convert dest=result_file) # file handle to recieve result # close output file result_file.close() # close output file # return False on success and True on errors return pisa_status.err # Main program if __name__ == "__main__": pisa.showLogging() convert_html_to_pdf(source_html, output_filename)
1, nhưng rõ ràng, nó không hoạt động và tôi không tìm thấy tại sao. Tôi đang đọc rất nhiều tài liệu về thư viện này, tôi đã viết một số tập lệnh CSS nhưng vẫn không có gì.

Đây là tệp HTML của tôi:


    
    {% load staticfiles %}