2017-08-03 11 views
0

背景情報

次のPythonコードを使用して、pdfファイルを生成します。それはpdfkit libraryを使用します。pythonでpdfkitライブラリを使用してフッターの上にフッターの行を表示する方法は?

import pdfkit    # import python module 

if __name__=="__main__": 


    options = { 
     'page-size': 'Letter', 
     'margin-top': '0.5in', 
     'margin-right': '0.75in', 
     'margin-bottom': '0.5in', 
     'margin-left': '0.75in', 
     'encoding': "UTF-8", 
     'footer-left': "This is a footer", 
     'footer-font-size':'7', 
     'footer-right': '[page] of [topage]', 

     'custom-header' : [ 
      ('Accept-Encoding', 'gzip') 
     ], 
     'no-outline': None 
    } 

    ##this is the path of the whkhtmltopdf.exe in order for the library to 
    ##work on a Windows OS 
    path_wkthmltopdf = r'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe' 
    config = pdfkit.configuration(wkhtmltopdf=path_wkthmltopdf) 

    pdfkit.from_url('http://google.com', 'Report.pdf',options=options,configuration=config)) 

結果のPDFは次のとおりです。私が必要とするのは、これ以上の行はフッターだけです。 The Resulting PDF

は、以下のサイトにによると、私は属性footer-lineを使用してフッターの上にフッタ行を追加することができますが、私は、Python

https://wkhtmltopdf.org/usage/wkhtmltopdf.txt

でそれを実装する方法の構文を理解していませんよ

ブリーフ

での質問はどのようfooter-lineを含めるようにoptions属性を変更しますか?

options = { 
     'page-size': 'Letter', 
     'margin-top': '0.5in', 
     'margin-right': '0.75in', 
     'margin-bottom': '0.5in', 
     'margin-left': '0.75in', 
     'encoding': "UTF-8", 
     'footer-left': "This is a footer", 
     'footer-font-size':'7', 
     'footer-right': '[page] of [topage]', 

     'custom-header' : [ 
      ('Accept-Encoding', 'gzip') 
     ], 
     'no-outline': None 
    } 

答えて

0

どうやらあなただけの属性を追加し、あなただけの'footer-line':'' を追加属性空のパラメータそうoptions

を渡すだから、なりよりよいがある場合

 options = { 
     'page-size': 'Letter', 
     'margin-top': '0.5in', 
     'margin-right': '0.75in', 
     'margin-bottom': '0.5in', 
     'margin-left': '0.75in', 
     'encoding': "UTF-8", 
     'footer-left': "This is a footer", 
     'footer-line':'', 
     'footer-font-size':'7', 
     'footer-right': '[page] of [topage]', 

     'custom-header' : [ 
      ('Accept-Encoding', 'gzip') 
     ], 
     'no-outline': None 
    } 

次それを行う方法は私に知らせてください。

関連する問題