I am trying to parse the existing PDF and it is failing with DamagedFontException.
I looked at the PDF and it is using Arial font. So I am trying right now to add Arial font and this is the error I am getting now.
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fontbox/ttf/TTFParser
at org.apache.pdfbox.pdmodel.font.PDType0Font.load(PDType0Font.java:147)
at org.apache.pdfbox.examples.interactive.form.FillFormField.main(FillFormField.java:54)
Caused by: java.lang.ClassNotFoundException: org.apache.fontbox.ttf.TTFParser
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 2 more
I modified the existing FillFormField class in PDFBox examples and added the Arial text field to the test PDF and was able to reproduce the error.
Here is the code which I added:
PDAcroForm acroForm = pdfDocument.getDocumentCatalog().getAcroForm();
acroForm.getDefaultResources().put(
COSName.getPDFName("Arial"),
PDType0Font.load(pdfDocument, new File("src/main/resources/org/apache/pdfbox/Arial.ttf")));
What I am doing wrong? My main goal is to just fill the form in the document, and that's it.
UPDATE:
The DamageFontException happens when I just modify existing PDF in the example
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/fontbox/type1/DamagedFontException
at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:76)
at org.apache.pdfbox.pdmodel.PDResources.getFont(PDResources.java:143)
at org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.validateAndEnsureAcroFormResources(AppearanceGeneratorHelper.java:150)
at org.apache.pdfbox.pdmodel.interactive.form.AppearanceGeneratorHelper.<init>(AppearanceGeneratorHelper.java:111)
at org.apache.pdfbox.pdmodel.interactive.form.PDTextField.constructAppearances(PDTextField.java:261)
at org.apache.pdfbox.pdmodel.interactive.form.PDTerminalField.applyChange(PDTerminalField.java:210)
at org.apache.pdfbox.pdmodel.interactive.form.PDTextField.setValue(PDTextField.java:218)
at org.apache.pdfbox.examples.interactive.form.FillFormField.main(FillFormField.java:87)
Caused by: java.lang.ClassNotFoundException: org.apache.fontbox.type1.DamagedFontException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 8 more
Related
Im using Gson for some Jayway code that Im writing:
private static final Configuration JACKSON_CONFIGURATION = Configuration
.builder()
.mappingProvider(new GsonMappingProvider())
.jsonProvider(new GsonJsonProvider())
.build();
but when I run it (Trying to apply some criteria for selection of elements inside the JSON), this exception occurred:
Exception in thread "main" java.lang.NoClassDefFoundError: net/minidev/json/writer/JsonReaderI
at com.jayway.jsonpath.internal.DefaultsImpl.<init>(DefaultsImpl.java:17)
at com.jayway.jsonpath.internal.DefaultsImpl.<clinit>(DefaultsImpl.java:15)
at com.jayway.jsonpath.Configuration.getEffectiveDefaults(Configuration.java:48)
at com.jayway.jsonpath.Configuration.access$000(Configuration.java:34)
at com.jayway.jsonpath.Configuration$ConfigurationBuilder.build(Configuration.java:229)
at com.jayway.jsonpath.internal.filter.ValueNode$PathNode.evaluate(ValueNode.java:778)
at com.jayway.jsonpath.internal.filter.RelationalExpressionNode.apply(RelationalExpressionNode.java:37)
at com.jayway.jsonpath.Criteria.apply(Criteria.java:57)
at com.jayway.jsonpath.internal.path.PredicatePathToken.accept(PredicatePathToken.java:75)
at com.jayway.jsonpath.internal.path.PredicatePathToken.evaluate(PredicatePathToken.java:59)
at com.jayway.jsonpath.internal.path.PathToken.handleObjectProperty(PathToken.java:81)
at com.jayway.jsonpath.internal.path.PropertyPathToken.evaluate(PropertyPathToken.java:77)
at com.jayway.jsonpath.internal.path.PathToken.handleArrayIndex(PathToken.java:133)
at com.jayway.jsonpath.internal.path.ArrayPathToken.evaluateIndexOperation(ArrayPathToken.java:63)
at com.jayway.jsonpath.internal.path.ArrayPathToken.evaluate(ArrayPathToken.java:52)
at com.jayway.jsonpath.internal.path.PathToken.handleObjectProperty(PathToken.java:81)
at com.jayway.jsonpath.internal.path.PropertyPathToken.evaluate(PropertyPathToken.java:77)
at com.jayway.jsonpath.internal.path.RootPathToken.evaluate(RootPathToken.java:62)
at com.jayway.jsonpath.internal.path.CompiledPath.evaluate(CompiledPath.java:53)
at com.jayway.jsonpath.internal.path.CompiledPath.evaluate(CompiledPath.java:61)
at com.jayway.jsonpath.JsonPath.read(JsonPath.java:187)
at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:164)
at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:151)
at com.wfx.wte.Test.fn(Test.java:44)
at com.wfx.wte.Test.main(Test.java:32)
Caused by: java.lang.ClassNotFoundException: net.minidev.json.writer.JsonReaderI
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 25 more
It seems to be looking up some net.minidev classes. Any clues?
add net.minidev.json-smart to the classpath
if needed,add net.mimidev.asm to the classpath
We are using java Cristal report for printing.
We have a problem in printing from label printers.
it throws,
Caused by: com.crystaldecisions.sdk.occa.report.lib.ReportSDKPrinterException: Report could not be printed.
at com.businessobjects.crystalreports.printer.bean.Printer.X(Unknown Source) ~[CrystalReportsRuntime-12.2.216.2042.jar:12.2.216.2042]
at com.businessobjects.crystalreports.printer.bean.ReportPrinter.print(Unknown Source) ~[CrystalReportsRuntime-12.2.216.2042.jar:12.2.216.2042]
at com.businessobjects.crystalreports.printer.bean.ReportPrinter.print(Unknown Source) ~[CrystalReportsRuntime-12.2.216.2042.jar:12.2.216.2042]
at com.crystaldecisions.sdk.occa.report.application.PrintOutputController.printReport(SourceFile:711) ~[CrystalReportsRuntime-12.2.216.2042.jar:12.2.216.2042]
... 161 common frames omitted
Caused by: java.awt.print.PrinterException: Paper's imageable width is too small.
this is the code use for printing
printerJob.printDialog();
reportClientDocument.getPrintOutputController().printReport(printerJob, null);
can any one know why this happens ?
hey i've tried this in netbeans but it won't work it gives me the same error no matter what i do! can anyone help?
JWNL.initialize(new FileInputStream("C:\\Users\\Desktop\\file_properties.xml"));
wordnet = Dictionary.getInstance();
IndexWord word = wordnet.getIndexWord(POS.VERB,"run");
Synset[] senses = word.getSenses();
for (int i = 0; i < senses.length; i++)
{
System.out.println(word + ": " + senses[i].getGloss());
}
and getting missing file exception :
Exception in thread "main" net.didion.jwnl.JWNLException: Unable to install net.didion.jwnl.dictionary.FileBackedDictionary
at net.didion.jwnl.util.factory.Element.install(Element.java:34)
at net.didion.jwnl.JWNL.initialize(JWNL.java:169)
at testss.Testss.main(Testss.java:43)
Caused by: net.didion.jwnl.JWNLException: The properties file must specify a dictionary path
at net.didion.jwnl.util.factory.AbstractValueParam.create(AbstractValueParam.java:34)
at net.didion.jwnl.dictionary.FileBackedDictionary.install(FileBackedDictionary.java:111)
at net.didion.jwnl.util.factory.Element.install(Element.java:32)
... 2 more
Caused by: net.didion.jwnl.JWNLException: Could not create a file manager of type class net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile
at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.create(FileManagerImpl.java:98)
at net.didion.jwnl.util.factory.AbstractValueParam.create(AbstractValueParam.java:32)
... 4 more
Caused by: java.io.FileNotFoundException: C:\Program Files\WordNet\2.1\dict\index.adv (The system cannot find the file specified)
at java.io.RandomAccessFile.open(Native Method)
at java.io.RandomAccessFile.<init>(RandomAccessFile.java:241)
at net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile.openFile(PrincetonRandomAccessDictionaryFile.java:76)
at net.didion.jwnl.dictionary.file.AbstractDictionaryFile.open(AbstractDictionaryFile.java:58)
at net.didion.jwnl.dictionary.file.DictionaryCatalog.open(DictionaryCatalog.java:45)
at net.didion.jwnl.dictionary.file.DictionaryCatalogSet.open(DictionaryCatalogSet.java:34)
at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.<init>(FileManagerImpl.java:71)
at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.create(FileManagerImpl.java:96)
... 5 more
Update Wordnet db version being used in jwnlProperties.xml
<version publisher="Princeton" number="3" language="en"/>
File names in db have changed over versions, and JWNL supports them.
This should solve your problem, discussed in other places as well.
http://sourceforge.net/p/jwordnet/discussion/106153/thread/5ccfc039/
Same issues was faced by me. And i solved it adding some missing files in dict folder.
net.didion.jwnl.JWNLException: Unable to install net.didion.jwnl.dictionary.FileBackedDictionary
at net.didion.jwnl.util.factory.Element.install(Element.java:34) at net.didion.jwnl.JWNL.initialize(JWNL.java:157) at getHypernyms.main(getHypernyms.java:27)
Caused by: net.didion.jwnl.JWNLException: The properties file must specify a dictionary path at net.didion.jwnl.util.factory.AbstractValueParam.create(AbstractValueParam.java:34) at net.didion.jwnl.dictionary.FileBackedDictionary.install(FileBackedDictionary.java:100) at net.didion.jwnl.util.factory.Element.install(Element.java:32) ... 2 more Caused by: net.didion.jwnl.JWNLException: Could not create a file manager of type class
net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.create(FileManagerImpl.java:71) at net.didion.jwnl.util.factory.AbstractValueParam.create(AbstractValueParam.java:32) ... 4 more Caused by: java.io.FileNotFoundException: E:\WordNet\WordNet-2.0\dict\adj.dat
(The system cannot find the file specified) at java.io.RandomAccessFile.open0(Native Method) at java.io.RandomAccessFile.open(RandomAccessFile.java:316) at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243) at net.didion.jwnl.princeton.file.PrincetonRandomAccessDictionaryFile.openFile(PrincetonRandomAccessDictionaryFile.java:76) at net.didion.jwnl.dictionary.file.AbstractDictionaryFile.open(AbstractDictionaryFile.java:58) at net.didion.jwnl.dictionary.file.DictionaryCatalog.open(DictionaryCatalog.java:46) at net.didion.jwnl.dictionary.file.DictionaryCatalogSet.open(DictionaryCatalogSet.java:34) at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.<init>(FileManagerImpl.java:54) at net.didion.jwnl.dictionary.file_manager.FileManagerImpl.create(FileManagerImpl.java:69) ... 5 more
And i just copied the existing files and rename it to desired name. And re-run the program and it work perfectly. Missing Files are adj.dat, noun.dat, adj.dat and .idx etc.
Example: Existing file name is data.verb ==> copy and paste it and rename it verb.dat, same with other files. and for index.adj rename to adj.idx.
For any query u can ping me. anysocialmedia/nabilraza456
Here is the output
I'm using JasperSoft Studio 5.1.0 for creating my report. This is library I used so far
commons-beanutils-1.8.3.jar commons-collections.jar
commons-digester-1.7.jar commons-javaflow-20060411.jar
commons-logging-1.1.3.jar groovy-all-1.7.5.jar itext-2.1.7.jar
jasperreports-5.1.0.jar
I'm trying using parameter and it's not showing any error when I see the preview on JasperSoft Studio, but when I try to print from my Java program it's show an error like this:
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : new java.lang.Integer(1)
the code I use on my program for action performed is like this
try
{
String NamaFile = "src/Laporan Penawaran.jasper";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection konek = Koneksi.getKoneksi();
HashMap hash = new HashMap();
hash.put("param1",no_tender.getText());
File file = new File(NamaFile);
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(file.getPath());
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, hash,konek);
JasperViewer.viewReport(jasperPrint);
} catch(Exception ex) {
System.out.println(ex);
}
I just wondering maybe my jasper file is error, but when I try to erase all field and using only static text the error still exist. What am I supposed to do?
well I'm just trying to update groovy-all to version 2. And after that there's no problem at all and work smoothly :)
note: make sure you are using a specific version for each library, somehow the new one it's not always match for your report
FIX for me:
i changed type of fields from java.math.BigInteger to java.math.BigDecimal
Below is whole stack trace by which I was able to identify the issue.
net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : new java.lang.Integer(1)
at net.sf.jasperreports.engine.fill.JRFillSubreport.prepare(JRFillSubreport.java:782)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:331)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:384)
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:358)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillBandNoOverflow(JRVerticalFiller.java:458)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnHeader(JRVerticalFiller.java:502)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:284)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:151)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:932)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:845)
at net.sf.jasperreports.engine.fill.JRFillSubreport.fillSubreport(JRFillSubreport.java:651)
at net.sf.jasperreports.engine.fill.JRSubreportRunnable.run(JRSubreportRunnable.java:59)
at net.sf.jasperreports.engine.fill.AbstractThreadSubreportRunner.run(AbstractThreadSubreportRunner.java:203)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : new java.lang.Integer(1)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:308)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluateEstimated(JRCalculator.java:582)
at net.sf.jasperreports.engine.fill.JRCalculator.estimateVariables(JRCalculator.java:181)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1234)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:1208)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1577)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:149)
... 8 more
Caused by: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/BytecodeInterface8
at ReconciliationDetail_UnclearedTxn_ChecksAndPayments_Count_1450338812203_279237.evaluateEstimated(calculator_ReconciliationDetail_UnclearedTxn_ChecksAndPayments_Count_1450338812203_279237:272)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluateEstimated(JREvaluator.java:295)
... 14 more
**Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.BytecodeInterface8**
at java.lang.ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 16 more
FIX Worked for me
I have updated all reports/subreports language property from "groovy" to "Java" and it's fixed .
Though it looks like workaround I suggest to update library which will include the missing class in jasperreports-5.1.2.jar.
I am trying to compress a graph using the WebGraph framework. I have set up the jars I need and I use the following code:
ImmutableGraph ig = ArcListASCIIGraph.load(BoldiTest.class.getResource("/citation-csconf-mult5-PaperJSON.graph.txt").getFile());
System.out.println(ig.numNodes()+" "+ig.numArcs());
ImmutableGraph.store(BVGraph.class, ig, "output");
The graph is loaded correctly but fails to be stored for the graph I am interested. For a much smaller graph (3 arcs) everything goes well so I guess the code is correct.
I provide the Stack Trace below. Any ideas? (the numbers are nodes and arcs)
124538 249755
Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at it.unimi.dsi.big.webgraph.ImmutableGraph.store(ImmutableGraph.java:623)
at it.unimi.dsi.big.webgraph.ImmutableGraph.store(ImmutableGraph.java:638)
at gr.di.uoa.a8.boldi.BoldiTest.main(BoldiTest.java:22)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at it.unimi.dsi.big.webgraph.ImmutableGraph.store(ImmutableGraph.java:619)
... 2 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at it.unimi.dsi.big.webgraph.BVGraph.updateBins(BVGraph.java:1701)
at it.unimi.dsi.big.webgraph.BVGraph.storeInternal(BVGraph.java:1808)
at it.unimi.dsi.big.webgraph.BVGraph.store(BVGraph.java:1650)
at it.unimi.dsi.big.webgraph.BVGraph.store(BVGraph.java:1678)
at it.unimi.dsi.big.webgraph.BVGraph.store(BVGraph.java:1690)
... 7 more
After eliminating the duplicate edges and sorting the input file I managed to store the graph.