锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
鏈榪戝湪欏圭洰寮鍙戣繃紼嬩腑錛屽鎴瘋姹傜敤Crystal Reports鐢熸垚pdf鏍煎紡鐨勬姤琛紝騫跺疄鐜拌嚜鍔ㄦ墦鍗板姛鑳姐?/FONT>
[瀹炴柦绱㈠紩]
1銆佸垱寤烘按鏅舵姤琛紱
2銆丣ava涓埄鐢ㄦ姤琛ㄧ粍浠跺寘灝嗘姤琛ㄧ粨鏋滅敓鎴恜df錛?/FONT>
3銆佸畬鎴愯嚜鍔ㄦ墦鍗板姛鑳姐?/FONT>
[璇︾粏姝ラ]
1銆佸垱寤烘按鏅舵姤琛?/FONT>
濡傛灉涓氬姟瑕佹眰姣旇緝澶嶆潅錛岃鍏堝垱寤轟復鏃惰〃鍜屽瓨鍌ㄨ繃紼嬶紝鍋囪DB鏄疧RACLE銆?/FONT>
1.1銆佸垱寤轟復鏃惰〃
CREATE global TEMPORARY TABLE table_name_temporary
( ......... ) on commit preserve rows;
娉細榪欑鏂瑰紡紜繚session涔嬮棿錛屾暟鎹簰涓嶅共鎵般?/FONT>
1.2銆佸垱寤哄瓨鍌ㄨ繃紼?/FONT>
鍒涘緩鍖呬綋錛屽寘浣撳唴澹版槑娓告爣銆?/FONT>
鏍規嵁涓氬姟閫昏緫錛屽皢鏁版嵁淇濆瓨鍦ㄤ復鏃惰〃涓紝榪斿洖姘存櫠鎶ヨ〃鎵闇瑕佺殑緇撴灉闆嗐?/FONT>
1.3銆佸垱寤烘按鏅舵姤琛?/FONT>
浠ュ瓨鍌ㄨ繃紼嬪仛涓烘暟鎹簮錛屽垱寤烘按鏅舵姤琛ㄣ?/FONT>
2銆丣ava涓埄鐢ㄦ姤琛ㄧ粍浠跺寘灝嗘姤琛ㄧ粨鏋滅敓鎴恜df
涓昏姝ラ濡備笅錛?/FONT>
錛?錛夌櫥褰旵rystalEnterprise錛?/FONT>
錛?錛夎緗畆eport鍙傛暟錛屾绱eport錛?/FONT>
錛?錛夌櫥褰旸B Server錛?/FONT>
錛?錛夎緭鍑虹粨鏋滃埌pdf銆?/FONT>
涓昏浠g爜濡備笅錛?/FONT>
IEnterpriseSession enterpriseSession = null;
ReportClientDocument clientDoc = null;
ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
enterpriseSession = sessionMgr.logon(
RAS_ADMINISTRATOR,
RAS_ADMIN_PWD, RASServer,
RAS_SEC);
IInfoStore iStore = (IInfoStore) enterpriseSession
.getService(EAPTPrintConstants.RAS_INFOSTORE);
IReportAppFactory reportAppFactory = (IReportAppFactory) enterpriseSession
.getService(EAPTPrintConstants.RAS_REPORT_FACTORY);
String query = "Select SI_ID From CI_INFOOBJECTS Where SI_NAME = '"
+ reportname + "' And SI_INSTANCE = 0 ";
IInfoObjects result = null;
try {
result = iStore.query(query);
} catch (SDKException e) {
e.printStackTrace();
}
IInfoObject firstResult = (IInfoObject) result.get(0);
clientDoc = reportAppFactory.openDocument(firstResult, 0,
Locale.ENGLISH);
//logon to DataBase
DatabaseController db = clientDoc.getDatabaseController();
// need to transfer arguments
db.logonEx(dbServer, sid, username,
password);
clientDoc.refreshReportDocument();
this.setParameters(clientDoc, map);
ByteArrayInputStream byteIS = (ByteArrayInputStream) clientDoc
.getPrintOutputController().export(ReportExportFormat.PDF);
byte byteArray[] = new byte[byteIS.available()];
FileOutputStream fileOS = new FileOutputStream(filename);
ByteArrayOutputStream byteOS = new ByteArrayOutputStream(byteIS
.available());
int x = byteIS.read(byteArray, 0, byteIS.available());
byteOS.write(byteArray, 0, x);
byteOS.writeTo(fileOS);
byteOS.close();
fileOS.close();
3銆佸畬鎴愯嚜鍔ㄦ墦鍗板姛鑳?/FONT>
(1) 鍒╃敤Itext鎶鏈噸鏂板鐞唒df錛屽湪宸茬敓鎴愮殑pdf閲屽姞涓婁互涓嬩唬鐮侊細
String js = "var pp = this.getPrintParams();\n";
js = js + "var fv = pp.constants.flagValues;\n";
js = js + "pp.flags = fv.setPageSize;\n";
js = js + "pp.interactive = pp.constants.interactionLevel.automatic;\n";
js = js + "pp.printerName = \"" + printer + "\";\n";
js = js + "this.print(pp);\n";
(2)jsp涓渶瑕両Frame鏍囩錛岀劧鍚庤嚜鍔ㄨ皟鐢⊿ervlet錛屽湪servlet閲屽皢pdf杈撳嚭鏉ワ紝鐩存帴杈撳嚭鍒版墦鍗版満涓娿?/FONT>