Jump to content
We've recently updated our Privacy Statement, available here ×

ojive

Members
  • Posts

    12
  • Joined

  • Last visited

ojive's Achievements

Apprentice

Apprentice (3/14)

  • One Month Later
  • One Year In
  • Week One Done
  • First Post Rare
  • Collaborator Rare

Recent Badges

0

Reputation

  1. How sweet is this. My original problem was that when i created a pdf file from the report (JRPdfExporter), it ignored the font completely. So i tried to send the report directly to printer, and failed (blank page). So i went back to the "first pdf, then print it"-solution that ignored the font and after a few hours of searching Lè G00glè, i found how to create a custom "fontmap" and add your own fonts to it. See code below. Note: I dont quite remember where "PDFPRintPage" came from, but it might've been from a jar called PDFRenderer that i found on the web. PDFFile seems to come from Sun itself. Code:HashMap fontMap = new HashMap(); fontMap.put(new FontKey("Arabic Typesetting", false, false),new PdfFont("fonts\\arabtype.ttf",BaseFont.IDENTITY_H,true)); exp.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, list); exp.setParameter(JRPdfExporterParameter.OUTPUT_FILE, new File("label.pdf")); exp.setParameter(JRPdfExporterParameter.PDF_VERSION, JRPdfExporterParameter.PDF_VERSION_1_7); exp.setParameter(JRPdfExporterParameter.FONT_MAP, fontMap); exp.exportReport();//********************************************************************************** // Create a PDFFile from a File reference File f = new File("label.pdf"); FileInputStream fis = new FileInputStream("label.pdf"); FileChannel fc = fis.getChannel(); ByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); PDFFile pdfFile = new PDFFile(bb); // Create PDF Print Page PDFPrintPage pages2 = new PDFPrintPage(pdfFile); // Create Print Job PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); Paper paper = new Paper(); paper.setSize(jasperPrint.getPageWidth(), jasperPrint.getPageHeight()); pf.setPaper(paper); pf.setOrientation(0); pjob.setJobName(f.getName()); pjob.setPrintable(pages2,pf); // Send print job to default printer if (pjob.printDialog()) { pjob.print(); }
  2. heya! I cant seem to be able to print my report. I have it compiled from jasperDesign, then filled, then i used the example from "demo/samples/printservice/src" and modified it to better match my task. I changed INPUT_FILE_NAME to JASPER_PRINT_LIST ( i have a list of JasperPrints in it). However, the page that prints is empty. I tried this method earlier but with PDFexporter, and the report that was generated (a PDF file) was just fine. Any ideas? This is driving me nuts, JasperReports is being advertised as "easy to print", but at the moment, in my case, it really isnt :p Code:PrintRequestAttributeSet printRequestAttributeSet = new HashPrintRequestAttributeSet();printRequestAttributeSet.add(MediaSizeName.ISO_A4);PrintServiceAttributeSet printServiceAttributeSet = new HashPrintServiceAttributeSet();JRPrintServiceExporter exporter = new JRPrintServiceExporter();exporter.setParameter(JRExporterParameter.JASPER_PRINT_LIST, list);exporter.setParameter(JRPrintServiceExporterParameter.PRINT_REQUEST_ATTRIBUTE_SET, printRequestAttributeSet);exporter.setParameter(JRPrintServiceExporterParameter.PRINT_SERVICE_ATTRIBUTE_SET, printServiceAttributeSet);exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);exporter.exportReport();
  3. you know what, im gonna bump this thread as JasperReports have not been anything else but endless streak of agony and frustrations. In your so called "batchexport sample", there are examples of how you can do it with "jrprint" files. But guess what, there is no, none, zero, zip documentation on how you would create those files. And before you voice your thought about "JasperFillManager.fillReport(jasperreport, params, con)", no, it DOES NOT create any "jrprint" files. So here I am, with "batchexport sample", no way of knowing how i would merge these reports, and im frustrated beyond any limits. edit: taking some of the above back. Make _damn_ sure your iReport and jasper jars are of the same version....version 4.0.0 actually produces ".jrprint" files when "fillReport" is used. You can then go: jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, con); list.add(jasperPrint); exp.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, list); exp.setParameter(JRPdfExporterParameter.OUTPUT_FILE, new File("test.pdf")); exp.exportReport(); This will export your report to a pdf. If you put this into a for-loop with a query that updates itself, and fills report with new "jasperParameter"s, you will get several pages in your "test.pdf", with one page pr element/query. I had it like this: Code:JRDesignQuery query = new JRDesignQuery();JasperPrint jasperPrint = null;Connection con = db.getConnection(); //my own class that creates a sql connectionList<Object> list = new ArrayList<Object>();JRPdfExporter exp = new JRPdfExporter();for(int k = 0; k < params.size(); k++){String query = "Select * from where somefield = ' " + params.get(k).get(3) + " ' ";query.setText (sqlQuery);JasperDesign jasperDesign = JRXmlLoader.load("GUI2.jrxml");jasperDesign.setQuery(query);jasperReport = JasperCompileManager.compileReport(jasperDesign); HashMap<String, String> jasperParameter = new HashMap<String, String>();jasperParameter.put("foo", params.get(k).get(2).toString()); //where "foo" is a field in your iReport .jrxml type file.jasperPrint = JasperFillManager.fillReport(jasperReport, jasperParameter, con);list.add(jasperPrint);exp.setParameter(JRPdfExporterParameter.JASPER_PRINT_LIST, list);exp.setParameter(JRPdfExporterParameter.OUTPUT_FILE, new File("test.pdf"));exp.exportReport(); Post Edited by ojive at 01/27/2011 13:11
  4. anyone? I highly doubt people are exporting 50 pdfs, merge them, and then print a 50 pages long report. There HAS to be a way to print a 50 pages long report by merging jasperPrint objects.
  5. Heya! I've finally managed to create, fill and view a report. I wish to have a "page" (probably a report) for each element. Let's say ive got a database of cards. So far i managed to print a report for a card. What i need is to create a report, but with multiple pages with 1x card pr 1x page in the SAME document. I am not interested in exporting the "card" to any file (yet), so what i want is to do it programatically, by using java objects. I've got iReport and i'm using Eclipse. I've looked at "demo\samples\batchexport" sample, and it only does it with actuall files in different formats. I need to do it "object"-wise in Java. Any suggestions? PS: Who's brilliant idea was it to limit a JasperPrint to one page pr object? Why is it so hard to go "printJob.addPage(thisFilledOutPage)" and have pages in one single Jasper Print object? :|
  6. bumping this one, as it's driving me utterly frustrated and slightly mental at this point.
  7. Problem is: I have a longblob with text that i need to read. Issue with that is: all i get is "23 12 21 24 65 23 78 34" (pure byte data). I need to convert that somehow. On another note: I spent some time creating the join statement and some of the fields are fine. Only problem is that longblob field that is not convertable atm :(
  8. Heya. I've made a report with a SQL query, and its all beautiful and pretty. Problem is i have several values that are sort of...ID's. Those ID's have to be "queried"(sp?) from another table. For instance name id = 2 corresponds to "Jasper" from "names" table. So instead of having IDs on my report, i need to query those back and forth a bit to get proper names instead of numbers. I have an ArrayList with local data i can use to replace fields with, but problem is i don't know how to do it? map.put("Name", "Steven"); does not really work. Any ideas?
  9. And award for Most useless answer 2011 goes tooooooo....*drumroll*...doelf! On a more serious note: I've done some digging and found a few examples, like this one for instance: http://www.devx.com/java/Article/29309/1954 Also, this one helped me too: http://jasperreports.sourceforge.net/api/index.html Thats the API of JasperReports. My problem is that for some reason "fillReport" ignores the content of Map, and simply filles out the report with the results of the SQL query, and not Map. edit: just follow the example from the first link and then you just go Map<String, Strin> params = new Map<String,String>(); map.put("Columnname", "Steven"); map.put("Columnname2", "Rolf"); etc. Post Edited by ojive at 01/21/2011 14:48
  10. I can't even create byte arrays in the Field Expression to be able to convert a byte[] to a string :/ I think it's so illogical that its "sooo easy" to convert a longblob to an Image, but converting a longblob to a String is completely unknown :|
  11. Greetings. I'm seriously frustrated with JasperReport and iReport tool. I've successfully created a report which im using in my Java application. I've spent days finding out how to display longblob images in my report, this is finally working. What i have issues with at the moment is reading text from a longblob field in my SQL database. It contains text (its a log). How do you do it in iReport? Field expression? Field config? I'm using iReport Designer 4.0.0. Code:<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="GUI2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="312"/> <queryString> <![CDATA[]]> </queryString> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="FIELDWITHBLOB" class="java.io.InputStream"/> <field name="Imagefield" class="java.io.InputStream"/> <field name="Imagefield2" class="java.io.InputStream"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.math.BigDecimal"/> <field name="foo" class="java.math.BigDecimal"/> <field name="foo" class="java.math.BigDecimal"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.Integer"/> <field name="foo" class="java.lang.String"/> <field name="foo" class="java.lang.String"/> <background> <band splitType="Stretch"/> </background> <detail> <band height="802" splitType="Stretch"> <textField> <reportElement x="0" y="100" width="182" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="286" y="180" width="143" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="180" width="286" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="0" width="125" height="40" forecolor="#000000" backcolor="#000000"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="386" y="259" width="169" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="-1" y="259" width="200" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="429" y="299" width="126" height="20"/> <textElement/> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="182" y="100" width="193" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="-1" y="60" width="555" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <image isUsingCache="true" onErrorType="Blank"> <reportElement x="309" y="645" width="246" height="139"/> <imageExpression class="java.io.InputStream"><![CDATA[$F{foo}]]></imageExpression> </image> <textField> <reportElement x="200" y="259" width="186" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="339" width="555" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="219" width="429" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <image isUsingCache="true" onErrorType="Blank"> <reportElement x="0" y="645" width="252" height="139"/> <imageExpression class="java.io.InputStream"><![CDATA[$F{foo}]]></imageExpression> </image> <textField> <reportElement x="342" y="20" width="213" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="379" width="555" height="126"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="429" y="180" width="126" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="286" y="299" width="143" height="20"/> <textElement/> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="286" y="140" width="269" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="125" y="20" width="217" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="375" y="100" width="180" height="20"/> <textElement/> <textFieldExpression class="java.lang.Integer"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="125" y="299" width="161" height="20"/> <textElement/> <textFieldExpression class="java.math.BigDecimal"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="140" width="286" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="429" y="220" width="126" height="20"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[$F{foo}]]></textFieldExpression> </textField> <textField> <reportElement x="0" y="782" width="100" height="20"/> <textElement/> <textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression> </textField> <textField evaluationTime="Report"> <reportElement x="454" y="782" width="100" height="20"/> <textElement/> <textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression> </textField> <staticText> <reportElement x="342" y="0" width="29" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="125" y="0" width="33" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="0" y="40" width="45" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="0" y="80" width="30" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="182" y="80" width="44" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="375" y="80" width="22" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="0" y="120" width="30" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="286" y="120" width="34" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="-1" y="160" width="39" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="286" y="160" width="38" height="20"/> <textElement/> <text><![CDATA[foo]]></text> </staticText> <staticText> <reportElement x="429" y="160" width="45" height="20"/> <textElement/> <text><![CDATA[foo]]></text> </staticText> <staticText> <reportElement x="0" y="200" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="429" y="199" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="0" y="239" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="200" y="239" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="386" y="240" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="126" y="279" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="286" y="279" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="429" y="279" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="-1" y="279" width="126" height="40"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="0" y="319" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="-1" y="359" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <staticText> <reportElement x="0" y="505" width="100" height="20"/> <textElement/> <text><![CDATA[foo:]]></text> </staticText> <textField> <reportElement x="0" y="545" width="554" height="81"/> <textElement/> <textFieldExpression class="java.lang.String"><![CDATA[""+$F{THISISMYBLOBFIELDTOREAD}]]></textFieldExpression> </textField> </band> </detail></jasperReport>
×
×
  • Create New...