1

Flying-saucer を使用して xhtml を pdf に変換しています。テーブルが作成されるxhtmlがあります。テーブル コンテンツのフォント ファミリは courier として宣言されています。このxhtmlに空飛ぶ円盤を使ってpdfを生成します。生成された pdf では、表の内容が Courier フォントで表示されません。入力された xhtml と生成された pdf のスクリーンショットが添付されています。xhtml から pdf への変換に使用されるコードは次のとおりです。

    String inputFile = "samples/font.xhtml";
    String url = new File(inputFile).toURI().toURL().toString();
    String outputFile = "font.pdf";
    OutputStream os = new FileOutputStream(outputFile);
    ITextRenderer renderer = new ITextRenderer();
    renderer.setDocument(url);
    renderer.layout();
    renderer.createPDF(os);
    os.close();

テキストを Courier フォントで表示するにはどうすればよいですか?

HTML 入力

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
       <title>My First Document</title>
        <style type="text/css"> b { color: green; } </style>
    </head>
    <body>
        <table>
       <tr>
         <td style="font-family: courier;">Hello World</td>
       </tr>
        </table>
     </body>
 </html>

ここに画像の説明を入力

4

1 に答える 1

1

フォントの名前は大文字と小文字が区別されます。で動作しfont-family: Courierます。も使用できますfont-family: monospace

于 2013-06-06T07:48:07.247 に答える