Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenPDF converter fails with java.lang.NoSuchFieldError: list #671

Open
andreldm opened this issue May 8, 2024 · 8 comments
Open

OpenPDF converter fails with java.lang.NoSuchFieldError: list #671

andreldm opened this issue May 8, 2024 · 8 comments

Comments

@andreldm
Copy link

andreldm commented May 8, 2024

Documents with lists are not properly converted by either PDF converters. The iText-based one will not render bullet points, even the characters as plain text are missing, I think this has been reported in the past. The one based on OpenPDF fails with java.lang.NoSuchFieldError: list, I can workaround this by replacing lists with bullet point characters but it's very annoying.

Sample document: sample.odt

@angelozerr
Copy link
Member

Any contribution are welcome!

@andreasrosdal
Copy link

Do you have a full stack trace for this error?
Which version of OpenPDF?

@andreldm
Copy link
Author

Do you have a full stack trace for this error?

Caused by: java.lang.NoSuchFieldError: list
	at fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableList.addElement(StylableList.java:185)
	at fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableList.addElement(StylableList.java:93)
	at fr.opensagres.odfdom.converter.pdf.internal.ElementVisitorForIText.addITextContainer(ElementVisitorForIText.java:848)
	at fr.opensagres.odfdom.converter.pdf.internal.ElementVisitorForIText.addITextContainer(ElementVisitorForIText.java:836)
	at fr.opensagres.odfdom.converter.pdf.internal.ElementVisitorForIText.visit(ElementVisitorForIText.java:606)
	at org.odftoolkit.odfdom.dom.element.text.TextListItemElement.accept(TextListItemElement.java:198)
	at fr.opensagres.odfdom.converter.core.ElementVisitorConverter.visit(ElementVisitorConverter.java:83)
	at fr.opensagres.odfdom.converter.pdf.internal.ElementVisitorForIText.addITextContainer(ElementVisitorForIText.java:845)
	at fr.opensagres.odfdom.converter.pdf.internal.ElementVisitorForIText.addITextContainer(ElementVisitorForIText.java:836)
	at fr.opensagres.odfdom.converter.pdf.internal.ElementVisitorForIText.visit(ElementVisitorForIText.java:595)
	at org.odftoolkit.odfdom.dom.element.text.TextListElement.accept(TextListElement.java:188)
	at fr.opensagres.odfdom.converter.core.ElementVisitorConverter.visit(ElementVisitorConverter.java:83)
	at org.odftoolkit.odfdom.dom.DefaultElementVisitor.visit(DefaultElementVisitor.java:2605)
	at fr.opensagres.odfdom.converter.pdf.internal.ElementVisitorForIText.visit(ElementVisitorForIText.java:258)
	at org.odftoolkit.odfdom.dom.element.office.OfficeTextElement.accept(OfficeTextElement.java:805)
	at fr.opensagres.odfdom.converter.pdf.PdfConverter.processBody(PdfConverter.java:138)
	at fr.opensagres.odfdom.converter.pdf.PdfConverter.doConvert(PdfConverter.java:66)
	at fr.opensagres.odfdom.converter.pdf.PdfConverter.doConvert(PdfConverter.java:44)
	at fr.opensagres.odfdom.converter.core.AbstractODFConverter.convert(AbstractODFConverter.java:42)
	at fr.opensagres.xdocreport.converter.odt.odfdom.itext.ODF2PDFViaITextConverter.convert(ODF2PDFViaITextConverter.java:62)

Which version of OpenPDF?

I'm using XDocReport 2.0.6 which I believe transitively brings in OpenPDF 1.3.18. The latest release which is compatible with XDocReport is 1.3.36, same error happens, the latest Java 8-compatible release is 1.3.43 but there are breaking changes.

@andreldm
Copy link
Author

andreldm commented May 13, 2024

That's really odd, while debugging it seems like the field exists and is accessible:
image

I have created an empty maven project in Intellij, the only dependencies are:

<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>xdocreport</artifactId>
  <version>2.0.6</version>
</dependency>

<dependency>
  <groupId>fr.opensagres.xdocreport</groupId>
  <artifactId>fr.opensagres.odfdom.converter.pdf.openpdf</artifactId>
  <version>2.0.6</version>
</dependency>

And the code is:

public class Main {
    public static void main(String[] args) throws Exception {
        InputStream in = Files.newInputStream(Paths.get("sample.odt"));
        OutputStream out = Files.newOutputStream(Paths.get("sample.pdf"));
        Options options = Options.getFrom(ODT).to(PDF);
        ConverterRegistry.getRegistry().getConverter(options).convert(in, out, options);
    }
}

I executed the application passing -verbose:class, there is only one com.lowagie.text.List class loaded and it comes from openpdf-1.3.18.jar.

@asolntsev
Copy link

@angelozerr @andreldm

I created a simple reproducible example for this problem: https://github.com/asolntsev/xdocreport-openpdf-demo

@andreasrosdal It doesn't depend on OpenPDF version.

@andreasrosdal
Copy link

Thank you for reporting and making the test case.
How can we solve this? Is the bug in OpenPDF or xdocreport?

@andreldm
Copy link
Author

andreldm commented Jul 3, 2024

@andreasrosdal I don't know, judging by the stack trace, it's more likely a xdocreport bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants