私はJava Swingアプリケーションからレポートを作成しようとしています。ジャスパーレポートやその他のツールを試しましたが、正しく使用する方法がわかりません。ITextスタンダードのアンラインライン特有のテキスト
私はitextを試してみましたが、実際にはこのようなものがあります。
public void createPDF(){
try {
PdfReader reader = new PdfReader("pdf/watermark.pdf"); // input PDF
PdfStamper stamper = new PdfStamper(reader,new FileOutputStream("C:\\Users\\FIREFENIX\\Documents\\NetBeansProjects\\Java\\PDFCreator\\src\\pdf\\watermarkFinal.pdf")); // output PDF
BaseFont bfArialPlain = BaseFont.createFont("/font/arial.ttf",BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
BaseFont bfArialBold = BaseFont.createFont("/font/arialbd.ttf",BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
BaseFont bfArialBlack = BaseFont.createFont("/font/ariblk.ttf",BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
for (int i=1; i<=reader.getNumberOfPages(); i++){
PdfContentByte over = stamper.getOverContent(i);
//TOP LEFT
over.beginText();
over.setFontAndSize(bfArialBold, 9);
over.setTextMatrix(040, 670);
over.showText("Registry Date: "); //<-----That field/line/text
over.endText();
over.beginText();
over.setFontAndSize(bfArialPlain, 9);
over.setTextMatrix(115, 670);
over.showText("21/07/2016");
over.endText();
over.beginText();
over.setFontAndSize(bfArialBold, 9);
over.setTextMatrix(040, 660);
over.showText("Validation Date: "); //<-----And that one
over.endText();
over.beginText();
over.setFontAndSize(bfArialPlain, 9);
over.setTextMatrix(115, 660);
over.showText("21/07/2016");
over.endText();
//TOP RIGHT...
//...
//...
}
File myFile = new File("C:\\Users\\FIREFENIX\\Documents\\NetBeansProjects\\Java\\PDFCreator\\src\\pdf\\watermarkFinal.pdf");
Desktop.getDesktop().open(myFile);
//////////PRINT DISABLED////////Desktop.getDesktop().print(myFile);
stamper.close();
reader.close();
} catch (IOException | DocumentException ex) {
Logger.getLogger(PDFCreator.class.getName()).log(Level.SEVERE, null, ex);
}
}
私は2行に下線を付ける必要があります。
どうすればいいですか?
私はこの簡単なことができます他の方法はありますか?
ありがとうございました。
お返事ありがとうございます。私もitext 5とitext 7の間にライブラリの競合がありましたが、これはv7とv5では動作しませんが、5.5をダウンロードして完全に動作します。 –
あなたはiText 5コードを提示したので、私はiText 5コードで答えました: 'PdfStamper'はiText 7に存在しなくなりました。新しい質問 –
@JesúsSuárezBorrellとして投稿してください。 7は下位互換性がありません。 itext 7はiText5の機能を一から書き直したものです。 –