2004 IR Help Posted September 2, 2006 Share Posted September 2, 2006 By: navy - navydhc why my report so bad? 2004-08-23 23:00 I make a report with iReport 0.3.2 ,the code is : <%@ page contentType="application/pdf;chaset=GBK"%> <%@ page import="dori.jasper.engine.*" %> <%@ page import="dori.jasper.engine.util.*" %> <%@ page import="dori.jasper.engine.export.*" %> <%@ page import="java.util.*" %> <%@ page import="java.io.*" %> <%@ page import="java.sql.*" %> <%@ page import="com.utils.*" %> <html> <head> navy is good! </head> <body> <% File reportFile = new File(application.getRealPath("jsp/report/reportComFeeMonCompare.jasper")); Map parameters = new HashMap(); parameters.put("arg_bumen", "1"); ConnectSybdb mydb=new ConnectSybdb(); mydb.Connectdb(); Connection conn=mydb.getConnection(); byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),parameters,conn); response.setContentType("application/pdf;charset=GBK"); //response.setContentLength(bytes.length); response.setBufferSize(bytes.length); ServletOutputStream ouputStream = response.getOutputStream(); ouputStream.write(bytes, 0, bytes.length); ouputStream.flush(); ouputStream.close(); mydb.DisConnect(); System.out.println("the program is finished! "); %> </body> </html> but when I use IE output this ,the output is : navy is good! %PDF-1.4 %忏嫌 6 0 obj <> stream x溑澩?GV卥|熲汚_?2"?$>偲浓a磎 ?-?锷?沅韶;O絙痵OFnY矞U+*矩iG~秊u幺就駗楌穙碜o欲_m?2名奎|{荥?窕焠馹o岿芹晓鰉婋鞼婑}圇_?o?抯>朳`颿田S貇丰GM艔渨藒輶?穇???饔?褡??6V?蜔a瀘{O篼mZ?護N?mX>ng橋噺 濒1Lr傫?|?笞'b逨叡7?嗝GH堼榷杩尫闊?字赜?c ?榷L'焋n絹窵?幀q倱吡抂颼Y鵺pd? '焋j絻%?冁 謘鵆j^>隌??>?l?厅鼜l?澦?侵滔?牲Ck南?鶙s?)耋?睲.付?嶞鼜l?>?存?F~礼渡O|凎熀>oVx鼭>}せb?域[?譼靠}鰰摦L鶮逵?屶嫇頒蚣 ,毒7抃氥:[?剰qV蜷6m?睲鲔渠饲椺艨[?枙?俧汫樋Lgam絽i溥聭ma?N>聗g?D?賸呗DG??冁马'!掇聹pd嵎p鲞H??剻 G鲫#ぶ[? G鲡#? ?h? ?J丘K浴?鵈?~??0ょ疩囍???晷鼔灴FZ恄攷嘧??骻z?uh}喁V犵疩囍?橹噛v?H縆軱?太?穣冼婧鮍瀖鸞曛嵌幈骏j}<瑉筑鎓隿芍?^羸?寓t#蔸袄?J丘K浴?鵈?~??0ょ疩囍???晷鼔灴FZ恄攷嘧??骻z?uh}喁V犵疩囍??橹噛v?H縆軭?太?穣冼坪鮍瀖麤胫嵌幈抗j}<瑉筑唂隿Z芍谴^羸?訣?6cx麅襋?uh}@t 縁Z?殷专C???晷鼔灴FZ惪(茂Q囍嫦酎5晷_瑻蟔??萠敭?鰃逕?疫唎跓y鯗c?邤胫Gy俄o╗?掐啰躐瓣I麤r初眪o"oa帪:=偝欗3弚W忾軫@篸螡97J> >> /MediaBox [0 0 842 1190] >> endobj 12 0 obj [1 0 R /XYZ 0 1202 0] endobj 13 0 obj [8 0 R /XYZ 0 1202 0] endobj 14 0 obj [10 0 R /XYZ 0 1202 0] endobj 15 0 obj <> /Descent -120 /FontBBox [-25 -254 1000 880] /StemV 93 /Ascent 880 /FontName /STSong-Light /ItalicAngle 0 >> endobj 16 0 obj <> /FontDescriptor 15 0 R /BaseFont /STSong-Light /Subtype /CIDFontType0 /W [15[238]17 26 462] >> endobj 3 0 obj <> endobj 4 0 obj <> /Widths [278 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 556 556 556 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 556 0 0 0 556 278 556 0 0 0 0 0 0 0 556] >> endobj 5 0 obj <> /Widths [250 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 500 500 500 500 500 500 0 0 0 500 278 0 0 0 0 0 0 722 0 667 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 556 611 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 444 0 500 0 0 0 0 0 0 0 0 0 0 0 0 0 500] >> endobj 2 0 obj <> endobj 7 0 obj <> endobj 17 0 obj <> endobj 18 0 obj <> endobj 19 0 obj <> endobj 20 0 obj <> endobj xref 0 21 0000000000 65535 f 0000008225 00000 n 0000019714 00000 n 0000018719 00000 n 0000018854 00000 n 0000019249 00000 n 0000000015 00000 n 0000019810 00000 n 0000016864 00000 n 0000008425 00000 n 0000017993 00000 n 0000017064 00000 n 0000018195 00000 n 0000018233 00000 n 0000018271 00000 n 0000018310 00000 n 0000018517 00000 n 0000019879 00000 n 0000019987 00000 n 0000020022 00000 n 0000020085 00000 n trailer <<7e4d80c20fb11f065cab308abe1ce01b>] /Root 19 0 R /Size 21 /Info 20 0 R >> startxref 20230 %%EOF why why I am chinese !? help me ,I am very hurry! By: Brett Sutton - sbrettsutton RE: why my report so bad? 2004-08-26 04:27 This looks like an HTML issue not a jasper issue. Someone correct me if I'm wrong but I don't believe that you can embed a PDF file inside an HTML file. I don't do JSP but I suspect that if you remove all of the HTML tags the browser may correctly render the page. Note: I.E. generally ignores the content type and looks at the content of the page. So it will be seeing HTML and trying to render the page as HTML. By: Andrew McLaughlin - pik0 RE: why my report so bad? 2004-08-26 10:04 Nope, no browser supports PDF data in place of the HTML contents. It's either receiving text/html or application/pdf. Hybrids are not supported... :) Piko By: Juan Ara - fi2net@Spain - laureke RE: why my report so bad? 2004-09-02 00:25 I don't encourage you to print an array of bytes in jsp, use a servlet instead. If you use jsp, the line break within <%@ page contentType="application/pdf;chaset=GBK"%> and <%@ page import="dori.jasper.engine.*" %> is sent to out, so you'll really need to reset response before starting to send the data. Before doing anything with response and withing jsp scriptlet, use response.reset(); Remove all HTML things and that should work: <%@ page contentType="application/pdf;chaset=GBK"%> <%@ page import="dori.jasper.engine.*" %> <%@ page import="dori.jasper.engine.util.*" %> <%@ page import="dori.jasper.engine.export.*" %> <%@ page import="java.util.*" %> <%@ page import="java.io.*" %> <%@ page import="java.sql.*" %> <%@ page import="com.utils.*" %> <% response.reset(); //Clear all line breaks from imports and jsp directives. File reportFile = new File(application.getRealPath("jsp/report/reportComFeeMonCompare.jasper")); Map parameters = new HashMap(); parameters.put("arg_bumen", "1"); ConnectSybdb mydb=new ConnectSybdb(); mydb.Connectdb(); Connection conn=mydb.getConnection(); byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(),parameters,conn); response.setContentType("application/pdf;charset=GBK"); //response.setContentLength(bytes.length); response.setBufferSize(bytes.length); ServletOutputStream ouputStream = response.getOutputStream(); ouputStream.write(bytes, 0, bytes.length); ouputStream.flush(); ouputStream.close(); mydb.DisConnect(); System.out.println("the program is finished! "); %> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now