Export image format PDF files with page break in Web reporting tool

Last Post 04 Oct 2009 05:18 AM by freezea. 0 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
New Member
New Member

04 Oct 2009 05:18 AM
In real application of web report, users often want to export report to PDF files. However, when users export web report to PDF file with API, there is usually no page break As a result, the exported PDF file may be very large, and the PDF file is of text mode.

RAQ Report is a Excel-like web-based Java reporting tool, and it provides a perfect solution to solve this problem.
With the API of RAQ Report, users can export web report as PDF file easily. Moreover, RAQ Report can export PDF files as image format with page break. As a result, the PDF file won't be very large.
The only thing users need to do is setting the page break mode and image format for exporting web report to PDF file. The codes are as follows:
import java.io.FileOutputStream;
import java.io.OutputStream;
import com.runqian.report4.model.ReportDefine;
import com.runqian.report4.model.engine.ExtCellSet;
import com.runqian.report4.usermodel.Context;
import com.runqian.report4.usermodel.Engine;
import com.runqian.report4.usermodel.IReport;
import com.runqian.report4.util.ReportUtils;
public class ExportToPdf {
public static void main(String[] args) {
String report = "D:/toExcel.raq"; //The location of report template
String pdfPath= "D:/test.pdf";
String licenceFile = "D:/2009-12-31V4.0Windows.lic"; //The location of authorization file
//Read report template
ReportDefine rd = (ReportDefine) ReportUtils.read( report );
//Second step: set report authorization file,and compute report.
ExtCellSet.setLicenseFileName( licenceFile );
Context context = new Context();
Engine enging = new Engine( rd, context);
IReport iReport = enging.calc();
}catch(Exception e){
}catch(Throwable t){
t.printStackTrace(); } }}
The parameters of function exportToPDF(pdfPath,iReport,true,true):
The first parameter pdfPath is the path of the PDF file.
The second parameter iReport is the object of the report.
The third parameter is the page break mode of the PDF file. True means page break, while false means no page break.
The fourth is the format of the PDF file. True means image, while false means text.
With this wonderful function, users can export perfect PDF file easily.

This post is from freezea's blog. You are welcome to cc it anywhere, and please indicate the source.

If you would like to read more articles about reporting tool, you are also welcome to refer to my blog.

Acceptable Use Policy