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

hubeny

Members
  • Posts

    10
  • Joined

  • Last visited

hubeny's Achievements

Apprentice

Apprentice (3/14)

  • First Post Rare
  • Collaborator Rare
  • Conversation Starter Rare
  • Week One Done
  • One Month Later

Recent Badges

0

Reputation

  1. Hi, we developed a jasperstudio plugin in the past. The plugin was developed for Jasper Studio version 6.3.0. During development of this plugin we followed this instructions https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-source-build-guide/v630/tibco-jaspersoft-studio-source-build In order to run the plugin in Eclipse IDE for RCP and RAP developers we try to download actual target platform (jss-environment). For the Jasper Studio version 6.3.0 it was available on the link https://sourceforge.net/projects/jasperstudio/files/DevelopersInfo/jss-environment/ It is no more available there and we cannot found its actual location. Could you please navigate me, 1) where to download actual jasper studio target platform - jss-evironment? or 2) Where are actual instruction how to build plugis for JasperStudio in Eclipse? I know about these instructions https://community.jaspersoft.com/wiki/contributing-tibco-jaspersoft-studio-and-building-sources https://community.jaspersoft.com/documentation/tibco-jaspersoft-studio-source-build-guide/v630/tibco-jaspersoft-studio-source-build Thank you in advance, Jan Hubeny
  2. Hi, I have asked the community in this thread http://jasperforge.org/plugins/espforum/view.php?group_id=102&forumid=103&topicid=85759 with the similar question and nobody replies too. Honza Hubeny
  3. Hello, Short question: Is there a way to have something like dynamic sized page footer with Jasper Reports 3.0.0? i.e. printed on the bottom of every page with stretching enabled. Longer question with particular problem description: I have a simple master -detail report. The are several rows in the detail dataset (pssibly printed over several pages) for each row of master dataset . Some records from the master dataset row shoud be printed in the page header and some in the page footer. The page should have following design (see the attachment for one page pdf): PAGE HEADER master data PAGE HEADER detail data detail data ... PAGE FOOTER master data PAGE FOOTER I have implemented this design in following way: Master dataset is the data source of the main report. Each row in this dataset has its own group. The page header is generated with group header band (print on each page is selected) and the page footer is generated with page footer band. The problem is that I need some fields (field Poznámka and PatÅ™í do in the attachment) to stretch with overflow in the page footer. However pagefooter band has fixed size. The group footer band cannot be used for page footer too, because it is printed only on the last page and it is printed after the detail band immidiately. So is there a way to design the report (similar to the pdf in attachment) having dynamic size page footer? With regards, Jan Hubeny Post Edited by hubeny at 03/31/2011 04:20
  4. Changing "Times New Roman" to "Times.ttf" in style element does not make any change. The Java VM still cannot find the Times font and it still silently replace the Times font with first font available. Futher, I have tried experiments with custom class loader and url handler factory set via REPORT_CLASS_LOADER REPORT_URL_HANDLER_FACTORY, but without any valuable results. The classloader or url factory methods are not called for the font resource. so the question remains the same: Please, give me an advice how to force the application to use my ttf fonts in the JRViewer and for printing. Thank you, Honza Hubeny
  5. The Telos's solution works fine with report export to pdf. But it does not work in the JRViewer I made a simple test. 1) I delete the Times.ttf font from the system font directory. 2) I made a jar which contains this font in the default package 3) I add the style line Code: <style name="Roman" isDefault="false" fontName="Times New Roman" fontSize="48" pdfFontName="Times.ttf" pdfEncoding="Cp1250" isPdfEmbedded="true" > to the jrxml file.4) start the application The results are following. The application cannot find the font "Times New Roman" and it silently replace this font with some default font and use this default font in the JRViewer and for printing. On the other side the export to pdf works, the exporter uses the correct Times.ttf font. Please, give me an advice how to force the application to use my ttf fonts in the JRViewer and for printing. Thank you, Honza Hubeny
  6. Hello, we are developing a desktop application which uses JasperReports for report generation and printing. So far the Jasper reports works well for us. However, we have noticed, that the reports are sometimes are not the same when generated on linux or windows machine. Further, we have noticed that is due to different versions of true type fonts on different machines. Therefore, we have an simple idea to distribute a font set (e.g. Arial Times and Courier) together with our application and force our application to use only th ese fonts for report generation. But, I don't know how to do it. I have read lot of articles in this forum and the only solution I had found was --" Create a jar file with your fonts and put it on the classpath", I tried it but without succ ess. I suppose that I have missed some simple thing. Therefore, my question is: In the .jrxml file is the style section where I define that the style uses the font with name "Arial". How can I force the application to load the font file 'arial.ttf' from my jar file (or database blob field or whatever...) and use it for the report filling instead of the system font 'arial.ttf' loaded by the Java VM from some system locati on (e.g. /usr/share/fonts/ttf/ ). Any advice or link to soulition will be helpful. Honza Hubeny
  7. Hello, thank you for your advice. It helps a lot. I implement the findResource() method in the class loader, add two new classes -- URL StreamHandler and URLConnection and now I can compile reports with scriptlet classes dynamicaly loaded from database. Thanks a lot! Honza Hubeny added code:... Code: @Override protected URL findResource(String name) { URL retVal = null; if (name.endsWith(".class"«»)) { try { name = name.replace(".class", ""«»); if (SRptUtils.isScriptletInDB(name)) { retVal = new URL("isdb", SRptDBURLStreamHandler.SCRIPTLET_CLASS, -1 , name, new SRptDBURLStreamHandler()); } } catch (MalformedURLException ex) { System.out.println(ex.getMessage()); Exceptions.printStackTrace(ex); } catch (SQLException ex) { System.out.println(ex.getMessage()); Exceptions.printStackTrace(ex); } } return retVal; }[/code] Code: public class SRptDBURLStreamHandler extends URLStreamHandler {public static final String SCRIPTLET_CLASS="ScriptletClass"; @Override protected URLConnection openConnection(URL u) throws IOException { return new SRptDBURLConnection(u); }}[/code] and Code: public class SRptDBURLConnection extends URLConnection { public SRptDBURLConnection(URL url) { super(url); } @Override public void connect() throws IOException { } @Override public InputStream getInputStream() throws IOException { InputStream retVal = null; if (SDatabase.checkNullAndActive(false)) { if (url.getHost().equals(SRptDBURLStreamHandler.SCRIPTLET_CLASS)) { retVal = SRptReportLoader.readReportScriptletToISFromDB(url.getFile() , SRptConst.REPORT_TYPES.SCRIPTLET_BIN); } } return retVal; }}[/code]
  8. Hello, I have an compilation problem of .jrxml report source files to the binary .jasper format. The problem description: Simple jrxml report design (testReport.jrxml) is readed (JRXmlLoader) and compiled with the built-in jasper compiler (e.g. the JRJdtCompiler).The report uses a scriptlet. The scriptlet class (PerformanceScriptlet) file is stored in the blob in a database. Therefore I use my class loader in order to load the scriptlet class. The class is successfully read from the database, however the compilation fails with following error: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. PerformanceScriptlet cannot be resolved to a type value = (java.lang.String)(((PerformanceScriptlet)parameter_REPORT_SCRIPTLET.getValue()).toString());//$JR_EXPR_ID=8$ <------------------> 2. PerformanceScriptlet cannot be resolved to a type value = (java.lang.String)(((PerformanceScriptlet)parameter_REPORT_SCRIPTLET.getValue()).toString());//$JR_EXPR_ID=8$ <------------------> 3. PerformanceScriptlet cannot be resolved to a type value = (java.lang.String)(((PerformanceScriptlet)parameter_REPORT_SCRIPTLET.getValue()).toString());//$JR_EXPR_ID=8$ <------------------> 3 errors at net.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:193) at compilationerror.Main.main(Main.java:28) Thank you in advance for any help. Honza Hubeny I made an example NetBeans project in order to simulate this error. It is attached to this post in a zip file. The class loader in my simulation read the class file from the disk, from path which is not in the CLASSPATH variable. the simulation program expects that the files and directories will have following structure / --- testReport.jrxml | --- hidden/classes/PerformanceScriptlet.class Code listing is as follows: The Main class: Code: package compilationerror;import java.util.logging.Level;import java.util.logging.Logger;import net.sf.jasperreports.engine.JRException;import net.sf.jasperreports.engine.JasperReport;import net.sf.jasperreports.engine.design.JRCompiler;import net.sf.jasperreports.engine.design.JRJdtCompiler;import net.sf.jasperreports.engine.design.JasperDesign;import net.sf.jasperreports.engine.xml.JRXmlLoader;/** * * @author hubeny */public class Main { public static void main(String[] args) { try { MyClassLoader cl = MyClassLoader.getInstance(); JasperDesign design = JRXmlLoader.load("testReport.jrxml"«»); JRCompiler compiler = new JRJdtCompiler(); Thread.currentThread().setContextClassLoader(cl); JasperReport report = compiler.compileReport(design); } catch (JRException ex) { Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex); } }}[/code] My class loader Code: package compilationerror;import java.io.File;import java.io.FileInputStream;import java.io.IOException;import java.io.InputStream;import java.util.logging.Level;import java.util.logging.Logger;/** * * @author hubeny */public class MyClassLoader extends ClassLoader { private final static MyClassLoader instance = new MyClassLoader(); private static final String MY_CLASS_PATH = "hidden/classes/"; protected MyClassLoader() { super(MyClassLoader.class.getClassLoader()); } public static MyClassLoader getInstance() { return instance; } private byte[] getClassImplFromDataBase(String className) { System.out.println(" >>>>>> Fetching scriptlet class implementation..." + className); byte[] retVal = null; File classFile = new File(MY_CLASS_PATH + className + ".class"«»); try { retVal = getBytesFromFile(classFile); } catch (IOException ex) { Logger.getLogger(MyClassLoader.class.getName()).log(Level.SEVERE, null, ex); } return retVal; } @Override protected synchronized Class<?> findClass(String name) throws ClassNotFoundException { Class result; byte classData[]; classData = getClassImplFromDataBase(name); if (classData == null) { throw new ClassNotFoundException(); } /* Define it (parse the class file) */ result = defineClass(name, classData, 0, classData.length); if (result == null) { throw new ClassFormatError(); } return result; } public static byte[] getBytesFromFile(File file) throws IOException { InputStream is = new FileInputStream(file); // Get the size of the file long length = file.length(); if (length > Integer.MAX_VALUE) { // File is too large } // Create the byte array to hold the data byte[] bytes = new byte[(int) length]; // Read in the bytes int offset = 0; int numRead = 0; while (offset < bytes.length && (numRead = is.read(bytes, offset, bytes.length - offset)) >= 0) { offset += numRead; } // Ensure all the bytes have been read in if (offset < bytes.length) { throw new IOException("Could not completely read file " + file.getName()); //NOI18N } // Close the input stream and return bytes is.close(); return bytes; }}[/code] [file name=CompilationError.gz size=10857]
  9. Hello, Our company is developing a desktop application which serves as a rich client for database access. We use the JasperReports for the reports generation. We store the report .jrxml source files as well as report binaries .jasper in the database. We also store the scriptlets source code and scriptlets compiled class in the database. Further, we want to be able to compile the scriptlet source code on the fly -- that is the source code is loaded from database to memory and compiled in memory without storing the source or the resulting class byte code to the disk. We use the JRJdtCompiler for this task. Everything works fine, but the only problem is that the compilation fails when the scriptlet belongs to some package. The detailed description follows: The scriptlet on the fly compilation is achieved with following classes: Code: public class SRptOnTheFlyJdtCompiler implements SRptOnTheFlyCompiler { private SRptJRJdtCompiler compiler = null; public SRptOnTheFlyJdtCompiler() { compiler = new SRptJRJdtCompiler(); } public byte[] compileClass(String className, String classSrc, String classPath) throws JRException { SRptCompilationSourceCode csc = new SRptCompilationSourceCode(classSrc); JRCompilationUnit cus[] = {new JRCompilationUnit(className, csc, null, null)}; byte[] retVal = null; String problems = compiler.compileUnits(cus, classPath, null); if (problems != null) { throw new JRException("Scriptlet compilation failed:n" + problems); } else { retVal = (byte[]) cus[0].getCompileData(); } return retVal; } } Code:[code] public class SRptCompilationSourceCode implements JRCompilationSourceCode { String code = null; SRptCompilationSourceCode(String srcCode) { code = srcCode; } public void setCode(String code) { this.code = code; } public String getCode() { return code; } public JRExpression getExpressionAtLine(int line) { return null; } } Code:[code] public class SRptJRJdtCompiler extends JRJdtCompiler{ public SRptJRJdtCompiler() { super(); } @Override public String compileUnits(final JRCompilationUnit[] units, String classpath, File tempDirFile) { return super.compileUnits(units, classpath, tempDirFile); } @Override protected Map getJdtSettings() { final Map settings = super.getJdtSettings(); settings.put(CompilerOptions.OPTION_Source, CompilerOptions.versionFromJdkLevel(CompilerOptions.JDK1_5)); return settings; } } The scriptlet is compiled with following code Code:[code] String scriptletSrc = ...; String scriptletName = ...; SRptOnTheFlyJdtCompiler compiler = new SRptOnTheFlyJdtCompiler(); byte[] scriptletByteCode = compiler.compileClass (scriptletName,scriptletSrc,null); The following example scriptlet code is compiled with no errors: Code:[code] import net.sf.jasperreports.engine.JRAbstractScriptlet; public class TestScriptlet extends JRAbstractScriptlet { ... } But the following code cannot be compiled Code:[code] package cz.soma.infosys.reporting.scriptlets; import net.sf.jasperreports.engine.JRAbstractScriptlet; public class TestScriptlet extends JRAbstractScriptlet { ... } The compilation produce following error: net.sf.jasperreports.engine.JRException: Scriptlet compilation failed: 1. The declared package does not match the expected package package cz.soma.infosys.reporting.scriptlets; <----------------------------------> 1 errors at cz.soma.infosys.reporting.compiler.SRptOnTheFlyJdtCompiler.compileClass(SRptOnTheFlyJdtCompiler.java:38) The error is produced by the JRJdtCompiler. My question is: Can we somehow modificate our code in order assign the scriptlet to package, which is not the default package? Thank you in advance, Honza Hubeny
×
×
  • Create New...