JasperReports / JasperServer 向けバーコード
- 1D、2D、郵便系を含む 80+ のバーコード シンボル体系をレンダリング
- Java SE (J2SE) 5+ で JasperReports / JasperServer と連携
- 出力形式: PNG、JPEG、TIFF、BMP、GIF、EXIF、さらに SVG と EMF
JasperReports テンプレートにバーコードを追加
// Build report from JRXML + export to PDF (minimal example)
ReportBuilder rb = new ReportBuilder(); rb.setPatternFilePath(path + "builder-params1.jrxml"); rb.addReportParameter("barcode-title1", "EAN14");
BarcodeAttributesGroup g = new BarcodeAttributesGroup("barcode-attributes1");
g.addBarcodeAttribute(BarcodeAttributeName.CodeText, "EAN14");
g.addBarcodeAttribute(BarcodeAttributeName.EncodeType, EncodeTypes.EAN_14);
rb.addBarcodeAttributesGroup(g);
JasperPrint jp = rb.compileReport().getJasperPrint();
JRPdfExporter ex = new JRPdfExporter();
ex.setExporterInput(new SimpleExporterInput(jp));
ex.setExporterOutput(new SimpleOutputStreamExporterOutput(new FileOutputStream(out + "builder-params1.pdf")));
ex.exportReport();
JasperReports のワークフローに合うバーコード出力
Aspose.BarCode for JasperReports は、単一 JAR としてデプロイできる純 Java の拡張です。別途レンダリング サービスを構築せずに、レポート作成者がレポートにバーコードを配置できます。請求書、配送ラベル、チケット、社内フォームなど、バーコードのサイズと鮮明さが重要な場面で役立ちます。
単一 JAR でデプロイ
JasperReports または JasperServer の所定の場所に 1 つの JAR をコピーしてデプロイします。環境をまたいでもセットアップがシンプルです。
レポートのレンダリング時にバーコード生成
レポート データセットのフィールドやパラメータにバーコード値をバインドします。バーコードは通常のエクスポート/印刷ワークフローの一部としてレンダリングされます。
印刷向けの出力形式
一般的なエクスポート向けにラスター画像を生成するか、印刷レイアウトで鮮明にスケーリングしたい場合は SVG と EMF を使用できます。
幅広いシンボル体系
QR Code、Data Matrix、PDF417、Code 128 など、同じレポーティング基盤で一般的な 1D/2D 形式を利用できます。
規格?もちろん対応。
Aspose.BarCode for JasperReports SVG や EMF などのベクター形式を含む主要な画像形式と PDF に対応しています。当社 API を使えば [files] を認識できます( https://docs.aspose.com/barcode/jasperreports/supported-file-formats/ ) (スキャナーやカメラからでも簡単)。以下は対応するバーコードのシンボル体系(1D、2D、郵便、複合タイプを含む)です。対応プラットフォームすべてで生成と認識が可能です。
マトリクス / 2D コード
- QR Code, MicroQR, rMQR
- Data Matrix, Industrial Data Matrix (DPM)
- Aztec
- Han Xin
- MaxiCode
- DotCode
リニア / 1D コード
- UPCA, UPCE
- EAN13, EAN14, EAN8
- Code 128
- DataBar
- ITF
- Postal
業界向け & 複合コード
- GS1
- ECI
- Composite barcodes
- HIBC
- SwissQR
- Royal Mailmark
システム要件とデプロイオプション
Aspose.BarCode for JasperReports は Java SE (J2SE) 5.0 以上で動作し、JasperReports および JasperServer と統合します。製品ドキュメントでは JasperReports 2.0+ および 3.0+ の互換性が記載されています。依存関係管理には Maven を利用するか、JAR パッケージをダウンロードして JasperReports / JasperServer のインストールにデプロイできます。
コード例:JasperReports のパラメータ駆動バーコードスタイル
バーコード内容と見た目の属性を再利用可能なグループとして定義し、レポート パラメータ経由で値を渡し、JRXML テンプレートをコンパイルして、完成度の高い PDF をエクスポートします。Aspose.BarCode for JasperReports を使ったクリーンなコードファーストのワークフローです。
// Input JRXML template path + output PDF path
String patternFilePath = path + "builder-params1.jrxml";
String reportFilePath = out + "builder-params1.pdf";
// Create ReportBuilder (main entry point for assembling the report)
ReportBuilder reportBuilder = new ReportBuilder();
// Define a reusable barcode attributes group (styling + barcode content settings)
BarcodeAttributesGroup attributesGroup = new BarcodeAttributesGroup("barcode-attributes1");
attributesGroup.addBarcodeAttribute(BarcodeAttributeName.CodeText, "EAN14");
attributesGroup.addBarcodeAttribute(BarcodeAttributeName.EncodeType, EncodeTypes.EAN_14);
attributesGroup.addBarcodeAttribute(BarcodeAttributeName.ForeColor, new Color(85, 107, 47));
attributesGroup.addBarcodeAttribute(BarcodeAttributeName.BackColor, new Color(245, 245, 220));
attributesGroup.addBarcodeAttribute(BarcodeAttributeName.BorderColor, new Color(39, 64, 139));
attributesGroup.addBarcodeAttribute(BarcodeAttributeName.BorderVisible, true);
attributesGroup.addBarcodeAttribute(BarcodeAttributeName.BorderWidth, 2);
attributesGroup.addBarcodeAttribute(BarcodeAttributeName.BorderDashStyle, DashStyle.Solid);
// Attach the barcode attributes group + provide report parameters used by the template
reportBuilder.addBarcodeAttributesGroup(attributesGroup);
reportBuilder.addReportParameter("barcode-title1", "Barcode for EAN14");
reportBuilder.addReportParameter("report-title", "Example of ReportBuilder with customer's parameters");
reportBuilder.addReportParameter("author", "Report prepared By Alex");
reportBuilder.setPatternFilePath(patternFilePath);
// Compile the template and get JasperPrint (ready-to-export report instance)
JasperPrint jasperPrint = reportBuilder.compileReport().getJasperPrint();
// Configure PDF exporter (input JasperPrint + PDF settings)
JRPdfExporter exporter = new JRPdfExporter();
ExporterInput exporterInput = new SimpleExporterInput(jasperPrint);
exporter.setExporterInput(exporterInput);
PdfExporterConfiguration pdfExporterConfiguration = new SimplePdfExporterConfiguration();
exporter.setConfiguration(pdfExporterConfiguration);
// Prepare output stream and run export to PDF file
File saveToFile = new File(reportFilePath);
OutputStream outputStream = new FileOutputStream(saveToFile);
SimpleOutputStreamExporterOutput outputStreamExporterOutput = new SimpleOutputStreamExporterOutput(outputStream);
exporter.setExporterOutput(outputStreamExporterOutput);
exporter.exportReport();
請求・物流・運用向けレポートのバーコード
JasperReports は、運用システムを流れるドキュメントの生成に使われることがよくあります。バーコードを追加すれば、これらのドキュメントをスキャン可能にし、手入力を減らせます。
- 請求書・明細: ドキュメント ID や顧客参照をエンコード
- 配送ラベル・納品書: 追跡コードや社内ルーティング ID を含める
- チケット・パス: コンパクトなペイロード向けに 2D バーコードを生成
- 資産・在庫レポート: 照合ワークフロー向けにスキャン可能な識別子を追加
- エクスポート対応の画像: PNG、JPEG、TIFF、BMP、GIF、EXIF、さらに SVG と EMF
JasperReports チーム向けに設計
単一 JAR として提供される純 Java 拡張
JasperReports のフィールド/パラメータでバーコード値を制御
一般的なラスター形式と印刷向けベクター形式に出力
JasperReports / JasperServer のデプロイに対応
1D、2D、郵便系にまたがる 80+ のバーコード シンボル体系
レポート統合とセットアップの例/ガイド