Đầu ra mã vạch phù hợp workflow JasperReports

Aspose.BarCode for JasperReports là extension Java thuần, triển khai như một JAR duy nhất. Nó cho phép người tạo báo cáo chèn mã vạch vào báo cáo mà không cần xây một dịch vụ kết xuất riêng. Rất hữu ích cho hóa đơn, nhãn vận chuyển, vé và biểu mẫu nội bộ nơi kích thước và độ rõ của mã vạch rất quan trọng.

  • Triển khai một JAR

    Triển khai bằng cách sao chép một JAR vào đúng vị trí cho JasperReports hoặc JasperServer. Điều này giúp thiết lập đơn giản giữa các môi trường.

  • Mã vạch được tạo tại thời điểm kết xuất báo cáo

    Gắn giá trị mã vạch vào các trường và tham số trong dataset báo cáo. Mã vạch được kết xuất như một phần của workflow export và in bình thường.

  • Định dạng đầu ra thân thiện in ấn

    Kết xuất ảnh raster cho các bản export phổ biến, hoặc dùng SVG và EMF khi cần scale sắc nét cho layout in.

  • Phủ rộng hệ mã

    Dùng các định dạng 1D và 2D phổ biến trong cùng stack báo cáo, bao gồm QR Code, Data Matrix, PDF417 và Code 128.

Tiêu chuẩn? Đầy đủ.

Aspose.BarCode for JasperReports hỗ trợ tất cả các định dạng hình ảnh chính, bao gồm định dạng vector như SVG và EMF, cũng như PDF. Dùng API của chúng tôi để nhận dạng files từ máy quét hoặc máy ảnh một cách dễ dàng. Dưới đây là tất cả các hệ mã vạch được hỗ trợ, bao gồm 1D, 2D, bưu chính và tổng hợp. Mỗi loại đều có thể được tạo và nhận dạng trên mọi nền tảng được hỗ trợ.

Mã ma trận / 2D

  • QR Code, MicroQR, rMQR
  • Data Matrix, Industrial Data Matrix (DPM)
  • Aztec
  • Han Xin
  • MaxiCode
  • DotCode

Mã tuyến tính / 1D

  • UPCA, UPCE
  • EAN13, EAN14, EAN8
  • Code 128
  • DataBar
  • ITF
  • Postal

Mã ngành & tổng hợp

  • GS1
  • ECI
  • Composite barcodes
  • HIBC
  • SwissQR
  • Royal Mailmark

Yêu cầu hệ thống và tùy chọn triển khai

Aspose.BarCode for JasperReports chạy trên Java SE (J2SE) 5.0 trở lên và tích hợp với JasperReports và JasperServer. Tài liệu sản phẩm liệt kê khả năng tương thích JasperReports 2.0+ và 3.0+. Bạn có thể dùng Maven để quản lý dependency hoặc tải gói JAR và triển khai vào cài đặt JasperReports/JasperServer.

Microsoft Windows
Linux
macOS

Ví dụ code: Styling mã vạch theo tham số trong JasperReports

Định nghĩa nội dung mã vạch và thuộc tính hiển thị như một nhóm có thể tái sử dụng, truyền giá trị qua tham số báo cáo, biên dịch template JRXML và export PDF hoàn chỉnh — tất cả trong workflow code-first gọn gàng với 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();

Mã vạch trong báo cáo cho hóa đơn, logistics và vận hành

JasperReports thường được dùng để tạo tài liệu đi qua các hệ thống vận hành. Việc thêm mã vạch giúp tài liệu có thể quét và giảm nhập tay.

  • Hóa đơn và sao kê: mã hóa document ID và tham chiếu khách hàng
  • Nhãn vận chuyển và phiếu đóng gói: bao gồm mã theo dõi và internal routing ID
  • Vé và thẻ qua cổng: tạo mã vạch 2D cho payload gọn
  • Báo cáo tài sản và tồn kho: thêm định danh có thể quét cho workflow đối soát
  • Ảnh sẵn export: PNG, JPEG, TIFF, BMP, GIF, EXIF, cùng SVG và EMF

Thiết kế cho đội ngũ JasperReports

Feature icon

Java extension thuần được đóng gói trong một JAR

Feature icon

Dùng trường và tham số JasperReports để điều khiển giá trị mã vạch

Feature icon

Xuất ra raster phổ biến và vector cho in ấn

Feature icon

Hoạt động với triển khai JasperReports và JasperServer

Feature icon

80+ hệ mã vạch trên các nhóm 1D, 2D và bưu chính

Feature icon

Ví dụ và hướng dẫn tích hợp/cài đặt báo cáo