Describe the bug
I'm getting this error when I try to use ITextRenderer.
I only apply the library to my project and use library documentation example.
org.openpdf.util.XRRuntimeException: Can't load the XML resource (using TrAX transformer). Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD
E at org.openpdf.resource.XMLResource$XMLResourceBuilder.transform(XMLResource.java:237)
E at org.openpdf.resource.XMLResource$XMLResourceBuilder.parse(XMLResource.java:204)
E at org.openpdf.resource.XMLResource$XMLResourceBuilder.createXMLResource(XMLResource.java:194)
E at org.openpdf.resource.XMLResource$XMLResourceBuilder.-$$Nest$mcreateXMLResource(Unknown Source:0)
E at org.openpdf.resource.XMLResource.load(XMLResource.java:90)
E at org.openpdf.pdf.ITextRenderer.parse(ITextRenderer.java:226)
E at org.openpdf.pdf.ITextRenderer.setDocumentFromString(ITextRenderer.java:217)
E at br.com.osnirmesquita.ordensdeservico.core.invoice.report.generator.HtmlPdfGenerator.generatePdf(HtmlPdfGenerator.kt:29)
E at br.com.osnirmesquita.ordensdeservico.core.invoice.report.DefaultInvoiceReportGenerator$generatePdf$1.invokeSuspend(InvoiceReportGenerator.kt:29)
E at br.com.osnirmesquita.ordensdeservico.core.invoice.report.DefaultInvoiceReportGenerator$generatePdf$1.invoke(Unknown Source:8)
E at br.com.osnirmesquita.ordensdeservico.core.invoice.report.DefaultInvoiceReportGenerator$generatePdf$1.invoke(Unknown Source:4)
E at kotlinx.coroutines.flow.SafeFlow.collectSafely(Builders.kt:57)
E at kotlinx.coroutines.flow.AbstractFlow.collect(Flow.kt:226)
E at br.com.osnirmesquita.ordensdeservico.features.main.MainActivity$onCreate$2.invokeSuspend(MainActivity.kt:54)
E at br.com.osnirmesquita.ordensdeservico.features.main.MainActivity$onCreate$2.invoke(Unknown Source:8)
E at br.com.osnirmesquita.ordensdeservico.features.main.MainActivity$onCreate$2.invoke(Unknown Source:4)
E at androidx.lifecycle.RepeatOnLifecycleKt$repeatOnLifecycle$3$1$1$1$1$1$1.invokeSuspend(RepeatOnLifecycle.kt:110)
E at androidx.lifecycle.RepeatOnLifecycleKt$repeatOnLifecycle$3$1$1$1$1$1$1.invoke(Unknown Source:8)
E at androidx.lifecycle.RepeatOnLifecycleKt$repeatOnLifecycle$3$1$1$1$1$1$1.invoke(Unknown Source:4)
E at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndspatched(Undispatched.kt:66)
E at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:43)
E at kotlinx.coroutines.CoroutineScopeKt.coroutineScope(CoroutineScope.kt:286)
E at androidx.lifecycle.RepeatOnLifecycleKt$repeatOnLifecycle$3$1$1$1$1.invokeSuspend(RepeatOnLifecycle.kt:110)
E at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
E at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:375)
E at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:26)
E at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:358)
E at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:134)
E at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:53)
E at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
E at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:44)
E at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
E at androidx.lifecycle.RepeatOnLifecycleKt$repeatOnLifecycle$3$1$1$1.onStateChanged(RepeatOnLifecycle.kt:107)
E at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.jvm.kt:313)
E at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.jvm.kt:251)
E at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.jvm.kt:288)
E at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.jvm.kt:135)
E at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.jvm.kt:119)
E at androidx.lifecycle.ReportFragment$Companion.dispatch$lifecycle_runtime_release(ReportFragment.android.kt:181)
E at androidx.lifecycle.ReportFragment$LifecycleCallbacks.onActivityPostResumed(ReportFragment.android.kt:119)
E at android.app.Activity.dispatchActivityPostResumed(Activity.java:1655)
E at android.app.Activity.performResume(Activity.java:9566)
E at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5904)
E at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:6007)
E at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57)
E at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:60)
E at android.app.servertransaction.TransactionExecutor.executeLifecycleItem(TransactionExecutor.java:225)
E at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:107)
E at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81)
E at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2895)
E at android.os.Handler.dispatchMessage(Handler.java:107)
E at android.os.Looper.loopOnce(Looper.java:257)
E at android.os.Looper.loop(Looper.java:342)
E at android.app.ActivityThread.main(ActivityThread.java:9634)
E at java.lang.reflect.Method.invoke(Native Method)
E at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:619)
E at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
E Caused by: java.lang.IllegalArgumentException: Not supported: http://javax.xml.XMLConstants/property/accessExternalDTD
E at org.apache.xalan.processor.TransformerFactoryImpl.setAttribute(TransformerFactoryImpl.java:580)
E at org.openpdf.resource.XMLResource$XMLResourceBuilder.transform(XMLResource.java:229)
E ... 56 more
To Reproduce
Code to reproduce the issue
val html = """
<html>
<head>
<style>
body { font-family: sans-serif; }
h1 { color: navy; }
</style>
</head>
<body>
<h1>Hello, World!</h1>
<p>This PDF was generated using openpdf-html.</p>
</body>
</html>
""".trimIndent()
FileOutputStream("/storage/emulated/0/Android/data/br.com.osnirmesquita.ordensdeservico.debug/cache/pdf_reports/openpdf-html-hello.pdf").use { outputStream ->
val renderer = ITextRenderer()
renderer.setDocumentFromString(html)
renderer.layout()
renderer.createPDF(outputStream)
}
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
System
(please complete the following information)
- OS: Android 35
- Used font:
- OpenPDF version: 3.0.0
Your real name
Osnir Mesquita
Additional context
Add any other context about the problem here.
Describe the bug
I'm getting this error when I try to use ITextRenderer.
I only apply the library to my project and use library documentation example.
To Reproduce
Code to reproduce the issue
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
System
(please complete the following information)
Your real name
Osnir Mesquita
Additional context
Add any other context about the problem here.