2017-09-16 32 views
1

OMRシートを作成しようとしています。そのためには以下のようなデザインが必要です。私はhtmlの& cssで作った。ItextSharpで中央揃えの円を作成する方法

enter image description here

しかしiTextSharpで、それはブラウザにhtmlとしては動作しません。

<td style="border-width:0 2px 0 4px; border-style:solid; border-color:white; padding:0 20px;"> 
    <div style="height:17px; width:25px; padding:2px; float:left;">1</div> 
    <div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">A</div> 
    <div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">B</div> 
    <div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">C</div> 
    <div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">D</div> 
</td> 

ボーダー&ボーダー半径は

がどのように私はすべてのアイデアことを解決することができます動作しません。 おかげ

+0

あなたのコードは表示されないため、使用しているiTextのバージョンを確認することはできません。これを動作させるには、iText 7 + pdfHTMLアドオンを使用する必要があります。ボーダーとボーダー半径が機能しないと主張する場合は、古いバージョンを使用している可能性があります。 –

+0

@BrunoLowagieはい私はiText 5を使用しています。 –

答えて

2

私はこのコードを試してみました:

public static final String SRC = "circle.html"; 
public static final String DEST = "circle.pdf"; 

public static void main(String[] args) throws IOException { 
    LicenseKey.loadLicenseFile(System.getenv("ITEXT7_LICENSEKEY") + "/itextkey-html2pdf_typography.xml");   
    Alignment app = new Alignment(); 
    app.createPdf(SRC, DEST); 
} 

public void createPdf(String src, String dest) throws IOException { 
    HtmlConverter.convertToPdf(new File(src), new File(dest)); 
} 

ファイルcircle.pdfは、この(私は境界線の色としてwhiteを削除、または境界が不可視であったであろうことに注意してください)のようになります。

<table> 
<tr> 
<td style="border-width:0 2px 0 4px; border-style:solid; padding:0 20px;" colspan="3"> 
    <div style="height:17px; width:25px; padding:2px; float:left;">1</div> 
    <div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">A</div> 
    <div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">B</div> 
    <div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">C</div> 
    <div style="height:17px; width:18px; padding:2px; margin:5px 2px; float:left; text-align:center; border-radius:50px; border:1px solid black;">D</div> 
</td> 
</tr> 
</table> 

結果は次のようになります。

enter image description here

私は、これは、多かれ少なかれOKに見えると言うが、したい:

  • あなたはこの結果を取得しない場合、あなたはiTextのの古いバージョンを使用している、アップグレード(以前のバージョンのiTextではこの機能をサポートしていなかったため、これらの古いバージョンを更新するつもりはありません)
  • iText 7 + pdfHTMLを使用するようにアップグレードすると、 「サークル」の描き方は、サークルを作成するための回避策がかなり悪いことを認めてください。これを行う他の方法があります。円形のコーナーで作業する代わりにコンテンツの周りに実際の円を描くためにITagWorkerの独自の実装を作成するか、円を必要とする限られた文字セットがある場合は、グリフに既に円が付いているフォントを使用します。
関連する問題