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

Error using ODT and HTML styling to generate PDF #685

Open
rodneicouto opened this issue Jul 26, 2024 · 2 comments
Open

Error using ODT and HTML styling to generate PDF #685

rodneicouto opened this issue Jul 26, 2024 · 2 comments

Comments

@rodneicouto
Copy link

rodneicouto commented Jul 26, 2024

xdocreport version is 2.1.0

When attempting to generate a PDF using ODT, Freemarker and HTML with the example below, I encounter an error because the intermediate ODT file generated has a <text:p> tag that is not properly closed.

<h2>Lorem ipsum dolor sit <em>amet, consectetur adipiscing</em> elit </h2><p>laborum.
</p><p></p><p></p><h2>Cláusula de (<em>livre preenchimento</em>)</h2>

The attached project reproduces this behavior.

The incorrect tag can be seen highlighted in the attached image.

Screenshot from 2024-07-26 16-19-06

bug_report.zip

the stack error is:

Fatal Error] :1:5465: The element type "text:p" must be terminated by the matching end-tag "</text:p>".
jul. 26, 2024 4:38:38 PM org.odftoolkit.odfdom.pkg.OdfFileDom initialize
SEVERE: null
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 5465; The element type "text:p" must be terminated by the matching end-tag "</text:p>".
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
	at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
	at org.odftoolkit.odfdom.pkg.OdfFileDom.initialize(OdfFileDom.java:142)
	at org.odftoolkit.odfdom.dom.OdfContentDom.initialize(OdfContentDom.java:55)
	at org.odftoolkit.odfdom.pkg.OdfFileDom.<init>(OdfFileDom.java:87)
	at org.odftoolkit.odfdom.dom.OdfContentDom.<init>(OdfContentDom.java:45)
	at org.odftoolkit.odfdom.pkg.OdfFileDom.newFileDom(OdfFileDom.java:110)
	at org.odftoolkit.odfdom.pkg.OdfPackageDocument.getFileDom(OdfPackageDocument.java:281)
	at org.odftoolkit.odfdom.dom.OdfSchemaDocument.getFileDom(OdfSchemaDocument.java:312)
	at org.odftoolkit.odfdom.dom.OdfSchemaDocument.getContentDom(OdfSchemaDocument.java:190)
	at fr.opensagres.odfdom.converter.pdf.PdfConverter.processStyles(PdfConverter.java:104)
	at fr.opensagres.odfdom.converter.pdf.PdfConverter.doConvert(PdfConverter.java:62)
	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)
	at fr.opensagres.xdocreport.document.AbstractXDocReport.convert(AbstractXDocReport.java:710)
	at my.example.ODTHTMLFreemarker.main(ODTHTMLFreemarker.java:43)

fr.opensagres.xdocreport.converter.XDocConverterException: fr.opensagres.odfdom.converter.core.ODFConverterException: java.lang.ClassCastException: Insertion of illegal Element: 12
	at fr.opensagres.xdocreport.converter.odt.odfdom.itext.ODF2PDFViaITextConverter.convert(ODF2PDFViaITextConverter.java:66)
	at fr.opensagres.xdocreport.document.AbstractXDocReport.convert(AbstractXDocReport.java:710)
	at my.example.ODTHTMLFreemarker.main(ODTHTMLFreemarker.java:43)
Caused by: fr.opensagres.odfdom.converter.core.ODFConverterException: java.lang.ClassCastException: Insertion of illegal Element: 12
	at fr.opensagres.odfdom.converter.pdf.PdfConverter.doConvert(PdfConverter.java:94)
	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)
	... 2 more
Caused by: java.lang.ClassCastException: Insertion of illegal Element: 12
	at com.lowagie.text.Phrase.add(Unknown Source)
	at fr.opensagres.xdocreport.itext.extension.ExtendedParagraph.addElement(ExtendedParagraph.java:63)
	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.processParagraphOrHeading(ElementVisitorForIText.java:392)
	at fr.opensagres.odfdom.converter.pdf.internal.ElementVisitorForIText.visit(ElementVisitorForIText.java:330)
	at org.odftoolkit.odfdom.dom.element.text.TextPElement.accept(TextPElement.java:1681)
	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.processParagraphOrHeading(ElementVisitorForIText.java:392)
	at fr.opensagres.odfdom.converter.pdf.internal.ElementVisitorForIText.visit(ElementVisitorForIText.java:322)
	at org.odftoolkit.odfdom.dom.element.text.TextHElement.accept(TextHElement.java:1794)
	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)
	... 5 more
@angelozerr
Copy link
Member

Any contribution are welcome!

@rodneicouto
Copy link
Author

In the tests I conducted, the error occurs when there is more than one header and <em> or <i> tags are used within them

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

2 participants