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

wim040

Members
  • Posts

    2
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by wim040

  1. @lucianc Thanks for the response! But sadly it does not work, I keep getting the following error messages: jdbc:mysql://127.0.0.1:3306/willem_bi Exception in thread "main" java.lang.NoClassDefFoundError: com/lowagie/text/pdf/FontMapper at net.sf.jasperreports.export.pdf.classic.ClassicPdfProducerFactory.createProducer(ClassicPdfProducerFactory.java:44) at net.sf.jasperreports.engine.export.JRPdfExporter.createPdfProducer(JRPdfExporter.java:902) at net.sf.jasperreports.engine.export.JRPdfExporter.initExport(JRPdfExporter.java:733) at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:694) at JasperReportHelloWorld.main(JasperReportHelloWorld.java:67) Caused by: java.lang.ClassNotFoundException: com.lowagie.text.pdf.FontMapper at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 5 more Greeings, Willem
  2. Hi all! New to Jaspersoft and Java, but I understand the basics. As the titles sugested, I want to export my .jasper while to .pdf, but i keep getting error messages and my pdf file won't open. Does anyone know, why the pdf export is not succesfull? Let me know if you need more information! import java.io.File;import java.io.FileOutputStream;import java.sql.Connection;import java.sql.DriverManager;import java.util.HashMap;import java.util.Map;import net.sf.jasperreports.engine.JasperCompileManager;import net.sf.jasperreports.engine.JasperExportManager;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.export.JRPdfExporter;import net.sf.jasperreports.export.ExporterInput;import net.sf.jasperreports.export.OutputStreamExporterOutput;import net.sf.jasperreports.export.SimpleExporterInput;import net.sf.jasperreports.export.SimpleOutputStreamExporterOutput;import net.sf.jasperreports.export.SimplePdfExporterConfiguration;import net.sf.jasperreports.view.JasperViewer;public class JasperReportHelloWorld { public static void main(String[] args) { try { Class.forName("com.mysql.cj.jdbc.Driver"); String dbURL; String username; String password; if (args.length != 0) { dbURL = "jdbc:mysql://" + args[0] + ":" + args[1] + "/" + args[2]; username = args[3]; password = args[4]; } else { dbURL = "jdbc:mysql://127.0.0.1:-/-"; username = "-"; password = "-"; } System.out.println(dbURL); Connection conn = DriverManager.getConnection(dbURL, username, password); String reportSrcFile = "C:\Users\-\-\-\.-\.JRS_project\" + args[5]; String reportCompiledFile = JasperCompileManager.compileReportToFile(reportSrcFile); Map<String, Object> parameters = new HashMap<String, Object>(); JasperPrint print = JasperFillManager.fillReport(reportCompiledFile, parameters, conn); JasperViewer.viewReport(print, true); // String pdfFileName = args[6]; // JasperExportManager.exportReportToPdfFile(print, pdfFileName); // File pdf = File.createTempFile("output.", ".pdf"); // JasperExportManager.exportReportToPdfStream(print, new FileOutputStream(pdf)); File pdf = File.createTempFile("output.", ".pdf"); FileOutputStream outputStream = new FileOutputStream(pdf); JRPdfExporter exporter = new JRPdfExporter(); exporter.setExporterInput((ExporterInput) new SimpleExporterInput(print)); // File pdf = File.createTempFile("output.", ".pdf"); // FileOutputStream outputStream = new FileOutputStream(pdf); exporter.setExporterOutput((OutputStreamExporterOutput) new SimpleOutputStreamExporterOutput(outputStream)); SimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration(); configuration.setMetadataAuthor("Willem"); exporter.setConfiguration(configuration); exporter.exportReport(); } catch (Exception e) { e.printStackTrace(); } }}[/code]Greetings, w.
×
×
  • Create New...