2016-07-10 9 views
0

印刷されたドキュメントにhtmlを使用しようとしています。私はChromeの自身の印刷ダイアログ内からこれをプレビューする場合、それはかなり私が意図する方法を探しますカップのxhtmltopdfフィルターはどのような印刷媒体で使用できますか?

<style type="text/css"> 
    @media print { 
    div.header { 
     position: fixed; 
     width: 100%; 
     top: 0; 
    } 
    #student_name, #date_submitted { 
     background: transparent; 
     border: none; 
     border-bottom: 1px solid #000000; 
     width: 55%; 
    } 
    } 
    div.twocol { 
    width: 50%; 
    float: left; 
    } 
    div.problem { 
    display: inline-block; 
    width: 5.5em; 
    font: 300% monospace; 
    text-align: right; 
    margin: 2.5em 0 2.5em 0; 
    } 
    div.operand2, div.operation { 
    float: right; 
    border-bottom: 0.1em black solid; 
    } 
    } 
</style> 
</head> 
<body> 
<div class="header"> 
    <div class="twocol"> 
    <label class="student_name" for="student_name">Name</label> 
    <input class="student_name" type="text" id="student_name"></input> 
    </div> 
    <div class="twocol"> 
    <label class="date_submitted" for="date_submitted">Date</label> 
    <input class="date_submitted" type="text" id="date_submitted"></input> 
    </div> 
</div> 
<div class="problem"> 
    <div class="operand1"></div> 
    <div class="operand2"></div> 
    <div class="operation">+</div> 
</div> 

:私は、私はすべての印刷ページに表示するヘッダを持っている、と私は、次のコードを使用しています。また、Chromeの印刷ダイアログ(プレビューと同じですが、少なくとも私の眼球と同じです)から印刷された場合は正しく表示されます。

これをCUPSのxhtmltopdfフィルタ(印刷をシミュ​​レートするため)で実行すると、いくつかの欠陥が表示されます。

ヘッダーは最初のページで正しく表示されますが、Chromeの独自の印刷ダイアログのように後続のページには表示されません。これは、それがスタイリングであることを証明しますメディア印刷セレクタからのものです。そうでなければ、普通の入力が見えます。これはまったくメディアプリントセレクタには問題がありますか、または位置固定と関係していますか?

第2の問題は、他の要素(クラス「問題」)がxhtmltopdfからChromeの印刷ダイアログよりもはるかに大きくレンダリングされることです。

From ChromeFrom xhtmltopdf

これはまた、CSSの問題、またはCUPSから独特の何かか?私はこれについてはまったく分かりませんが、私は何年か前から、いくつかのブラウザーが少なくともquirksモードでは要素のデフォルトスタイルを持っていたことを覚えているようです。 Chromeにxhtmltopdfが逃しているようなスタイルがありますか?他に何か起こっていますか?

john$ cupsfilter /mnt/Linkstation/Documents/Education/\!Curricula/Arithmetic/Arithmetic\ -\ g1\ -\ Addition\,\ no\ carrying.html > test2.pdf 
DEBUG: argv[0]="cupsfilter" 
DEBUG: argv[1]="1" 
DEBUG: argv[2]="john" 
DEBUG: argv[3]="Arithmetic - g1 - Addition, no carrying.html" 
DEBUG: argv[4]="1" 
DEBUG: argv[5]="" 
DEBUG: argv[6]="/mnt/Linkstation/Documents/Education/!Curricula/Arithmetic/Arithmetic - g1 - Addition, no carrying.html" 
DEBUG: envp[0]="<CFProcessPath>" 
DEBUG: envp[1]="CONTENT_TYPE=text/html" 
DEBUG: envp[2]="CUPS_DATADIR=/usr/share/cups" 
DEBUG: envp[3]="CUPS_FONTPATH=/usr/share/cups/fonts" 
DEBUG: envp[4]="CUPS_SERVERBIN=/usr/libexec/cups" 
DEBUG: envp[5]="CUPS_SERVERROOT=/private/etc/cups" 
DEBUG: envp[6]="LANG=en_US.UTF8" 
DEBUG: envp[7]="PATH=/usr/libexec/cups/filter:/usr/bin:/usr/sbin:/bin:/usr/bin" 
DEBUG: envp[8]="PPD=/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/Resources/Generic.ppd" 
DEBUG: envp[9]="PRINTER_INFO=cupsfilter" 
DEBUG: envp[10]="PRINTER_LOCATION=Unknown" 
DEBUG: envp[11]="PRINTER=cupsfilter" 
DEBUG: envp[12]="RIP_MAX_CACHE=128m" 
DEBUG: envp[13]="USER=john" 
DEBUG: envp[14]="CHARSET=utf-8" 
DEBUG: envp[15]="FINAL_CONTENT_TYPE=application/pdf" 
INFO: xhtmltopdf (PID 29607) started. 
DEBUG: Page = 612x792; 17,19 to 595,773 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: Invalid Connection ID 0 
DEBUG: Loading "file:///mnt/Linkstation/Documents/Education/!Curricula/Arithmetic/Arithmetic%20-%20g1%20-%20Addition,%20no%20carrying.html" 
DEBUG: Waiting for HTML file to load, 10% 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. 
Jul 10 16:42:57 cupsfilter[29607] <Warning>: CGSConnectionByID: 0 is not a valid connection ID. 
DEBUG: Waiting for HTML file to load, 50% 
DEBUG: Waiting for HTML file to load, 50% 
DEBUG: Page title="Basic Addition, No Carrying" 
DEBUG: Bounds of document are [0.0 0.0 579.0 2608.0] 
DEBUG: Starting page 1: [0.0 0.0 578.8 681.0] 
DEBUG: Starting page 2: [0.0 681.0 578.8 754.8] 
DEBUG: Starting page 3: [0.0 1435.8 578.8 685.2] 
DEBUG: Starting page 4: [0.0 2121.0 578.8 754.8] 
INFO: xhtmltopdf (PID 29607) exited with no errors. 

答えて

0

私は「CUPS」xhtmltopdf」が何であるかを知らない(クイック検索が便利な情報を見つけることができませんでした:これは、私はカップフィルタからの出力を含むてるのを助ける場合

わかりません)あなたのPDF作成にはpaged mediaを使用する方が良いと思っています。

現代のブラウザでは、プレビューにCSSルールが適用されないことがあるので、PrinceXML、PDFReactor、wkhtmltopdfなどのソリューションが必要です。あなたはあなたが望むものを達成するために特定のCSSルールを使うことができます。

例:

@page { 

    @top-left { 
     content: Name __________________; 
     font-size: 9pt; 
     color: #333; 
    } 

    @top-right { 
     content: Date __________________; 
     font-size: 9pt; 
     color: #333; 
    } 
} 
+0

これは私の質問に答えていません。 CUPSはMac OSXとほとんどのLinuxシステム上のプリンタシステムです。 –

関連する問題