[
https://issues.apache.org/jira/browse/PDFBOX-2544?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14998957#comment-14998957
]
Benjamin Podszun commented on PDFBOX-2544:
------------------------------------------
I understand this ticket is closed and the ant build deprecated - even removed
from 2.0, but this bug was the only reasonable hit in a search for this
problem. I hope it's not considered bad form to leave the solution here, for
other interested parties.
The given error happens, because ikvm literally emits a
throw new NoClassDefFoundError("org.apache.commons.logging.LogFactory");
in the static constructor of the CMap class. It does _that_ (and warns about
it, in the output/logs), because there's no reference to that class during
compilation.
The solution is trivial: Build FontBox _after_ commons.logging and add a
reference to the resulting commons.logging assembly in bin\ to the FontBox ikvm
arguments . See pdfbox\build.xml:451ff
Works For Me™ with 1.8.10 now.
> Building pdfbox 1.8.6 or 1.8.7 using IKVM
> -----------------------------------------
>
> Key: PDFBOX-2544
> URL: https://issues.apache.org/jira/browse/PDFBOX-2544
> Project: PDFBox
> Issue Type: Bug
> Components: .NET, FontBox, Text extraction
> Affects Versions: 1.8.6, 1.8.7
> Environment: Windows 8.1 Pro, IKVM 8.0.5415 or IKVM 7.2.4630.5, JDK 7
> (or 8) 64 bit, .NET 4.0
> Reporter: Marian Mar
> Labels: .NET, IKVM, build, c#
>
> I tried to build pdfbox 1.8.6 (and 1.8.7) using IKVM according to
> [this|http://stackoverflow.com/questions/8441991/how-to-build-pdfbox-for-net
> instructions] instructions. Everything went fine, but If I tested this code
> below on some pdf (e.g.
> [PDF|http://www.energy.umich.edu/sites/default/files/pdf-sample.pdf]) I get
> exception on line with writeText. If I tested the same with pdfbox 1.8.5 I
> had no problems.
> {code}
> class MyPDFTextStripper : PDFTextStripper {
> ...
> java.io.StringWriter outputStream = new java.io.StringWriter();
> writeText(document, outputStream); // Exception
> ...
> }
> {code}
> {code}
> Exception:
> An unhandled exception of type 'System.TypeInitializationException'
> occurred in pdfbox-1.8.7.dll
> Additional information: The type initializer for
> 'org.apache.fontbox.cmap.CMap' threw an exception.
> {code}
> {code}
> Stack trace:
> at org.apache.fontbox.cmap.CMap..ctor()
> at org.apache.fontbox.cmap.CMapParser.parse(String resourceRoot,
> InputStream input)
> at org.apache.pdfbox.pdmodel.font.PDFont.parseCmap(String cmapRoot,
> InputStream cmapStream)
> at org.apache.pdfbox.pdmodel.font.PDSimpleFont.extractToUnicodeEncoding()
> at org.apache.pdfbox.pdmodel.font.PDSimpleFont.determineEncoding()
> at org.apache.pdfbox.pdmodel.font.PDType1Font.determineEncoding()
> at org.apache.pdfbox.pdmodel.font.PDFont..ctor(COSDictionary
> fontDictionary)
> at org.apache.pdfbox.pdmodel.font.PDSimpleFont..ctor(COSDictionary
> fontDictionary)
> at org.apache.pdfbox.pdmodel.font.PDType1Font..ctor(COSDictionary
> fontDictionary)
> at org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(COSDictionary
> dic)
> at org.apache.pdfbox.pdmodel.PDResources.getFonts()
> at org.apache.pdfbox.util.PDFStreamEngine.getFonts()
> at org.apache.pdfbox.util.operator.SetTextFont.process(PDFOperator
> operator, List arguments)
> at org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFOperator
> operator, List arguments)
> at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(COSStream )
> at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDPage aPage,
> PDResources resources, COSStream cosStream)
> at org.apache.pdfbox.util.PDFStreamEngine.processStream(PDPage aPage,
> PDResources resources, COSStream cosStream)
> at org.apache.pdfbox.util.PDFTextStripper.processPage(PDPage page,
> COSStream content)
> at org.apache.pdfbox.util.PDFTextStripper.processPages(List pages)
> at org.apache.pdfbox.util.PDFTextStripper.writeText(PDDocument doc, Writer
> outputStream)
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]