diff --git a/deployment/pom.xml b/deployment/pom.xml index 5be0aab..d5c1e3f 100644 --- a/deployment/pom.xml +++ b/deployment/pom.xml @@ -25,6 +25,10 @@ io.quarkiverse.poi quarkus-poi-deployment + + io.quarkiverse.openpdf + quarkus-openpdf-deployment + io.quarkus quarkus-vertx-http-dev-ui-spi diff --git a/deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java b/deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java index fff45c1..25aee5b 100644 --- a/deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java +++ b/deployment/src/main/java/io/quarkiverse/jasperreports/deployment/JasperReportsProcessor.java @@ -162,13 +162,15 @@ void registerForReflection(CombinedIndexBuildItem combinedIndex, BuildProducer index) { - index.produce(new IndexDependencyBuildItem("com.github.librepdf", "openpdf")); - } - - @BuildStep - NativeImageEnableAllCharsetsBuildItem enableAllCharsetsBuildItem() { - return new NativeImageEnableAllCharsetsBuildItem(); - } - - @BuildStep - void registerOpenPdfFonts(BuildProducer nativeImageResourcePatterns) { - final NativeImageResourcePatternsBuildItem.Builder builder = NativeImageResourcePatternsBuildItem.builder(); - builder.includeGlob("**/pdf/fonts/**"); - builder.includeGlob("**/font-fallback/**"); - nativeImageResourcePatterns.produce(builder.build()); - } - - @BuildStep - void registerOpenPdfResources(BuildProducer resourceBundleBuildItem) { - // Register resource bundles - resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("com/lowagie/text/error_messages/en.lng")); - resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("com/lowagie/text/error_messages/nl.lng")); - resourceBundleBuildItem.produce(new NativeImageResourceBundleBuildItem("com/lowagie/text/error_messages/pt.lng")); - } - - /** - * Registers classes and packages that need to be initialized at runtime. - * - * @param runtimeInitializedPackages Producer for runtime initialized packages - */ - @BuildStep - void runtimeOpenPdfInitializedClasses(BuildProducer runtimeInitializedPackages) { - //@formatter:off - List classes = new ArrayList<>(); - classes.add(com.lowagie.text.pdf.PdfPublicKeySecurityHandler.class.getName()); - - Log.debugf("OpenPdf Runtime: %s", classes); - classes.stream() - .map(RuntimeInitializedPackageBuildItem::new) - .forEach(runtimeInitializedPackages::produce); - //@formatter:on - } - - @BuildStep - void registerOpenPdfForReflection(BuildProducer reflectiveClass, - CombinedIndexBuildItem combinedIndex) { - final List classNames = new ArrayList<>( - collectSubclasses(combinedIndex, com.lowagie.text.Image.class.getName())); - classNames.add(com.lowagie.text.PageSize.class.getName()); - classNames.add(com.lowagie.text.Utilities.class.getName()); - classNames.add(com.lowagie.text.pdf.PdfName.class.getName()); - - Log.debugf("OpenPdf Reflection: %s", classNames); - // methods and fields - reflectiveClass.produce( - ReflectiveClassBuildItem.builder(classNames.toArray(new String[0])).methods().fields().build()); - } - -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 1f629b3..296b386 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,7 @@ 3.15.1 2.1.0 + 3.1.0 7.0.1 @@ -53,6 +54,16 @@ quarkus-poi-deployment ${version.quarkus-poi} + + io.quarkiverse.openpdf + quarkus-openpdf + ${version.quarkus-openpdf} + + + io.quarkiverse.openpdf + quarkus-openpdf-deployment + ${version.quarkus-openpdf} + net.sf.jasperreports jasperreports @@ -132,4 +143,4 @@ - + \ No newline at end of file diff --git a/runtime/pom.xml b/runtime/pom.xml index 48f2503..e160631 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -26,6 +26,10 @@ io.quarkiverse.poi quarkus-poi + + io.quarkiverse.openpdf + quarkus-openpdf + org.jboss.logging commons-logging-jboss-logging @@ -92,6 +96,10 @@ commons-logging commons-logging + + com.github.librepdf + openpdf + diff --git a/runtime/src/main/java/io/quarkiverse/jasperreports/graal/FopGlyphProcessorSubstitution.java b/runtime/src/main/java/io/quarkiverse/jasperreports/graal/FopGlyphProcessorSubstitution.java deleted file mode 100644 index dff4460..0000000 --- a/runtime/src/main/java/io/quarkiverse/jasperreports/graal/FopGlyphProcessorSubstitution.java +++ /dev/null @@ -1,28 +0,0 @@ -package io.quarkiverse.jasperreports.graal; - -import java.io.UnsupportedEncodingException; -import java.util.Map; - -import com.lowagie.text.pdf.BaseFont; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; - -/** - * FOP is used for one minor feature of OpenPDF, and we don't want to bring in the FOP bloat for - * one small feature. I could be convinced otherwise in the future! - */ -@TargetClass(className = "com.lowagie.text.pdf.FopGlyphProcessor") -final class FopGlyphProcessorSubstitution { - - @Substitute - public static boolean isFopSupported() { - return false; - } - - @Substitute - public static byte[] convertToBytesWithGlyphs(BaseFont font, String text, String fileName, - Map longTag, String language) throws UnsupportedEncodingException { - throw new UnsupportedEncodingException( - "Quarkus OpenPDF does not support FOP. Report this to the extension if you do need this functionality."); - } -} \ No newline at end of file diff --git a/runtime/src/main/java/net/sf/jasperreports/pdf/classic/ClassicRadioCheckSubstitution.java b/runtime/src/main/java/net/sf/jasperreports/pdf/classic/ClassicRadioCheckSubstitution.java new file mode 100644 index 0000000..49da38f --- /dev/null +++ b/runtime/src/main/java/net/sf/jasperreports/pdf/classic/ClassicRadioCheckSubstitution.java @@ -0,0 +1,34 @@ +package net.sf.jasperreports.pdf.classic; + +import java.io.IOException; + +import com.lowagie.text.DocumentException; +import com.lowagie.text.pdf.PdfFormField; +import com.lowagie.text.pdf.RadioCheckField; +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +import net.sf.jasperreports.engine.JRRuntimeException; + +@TargetClass(className = "net.sf.jasperreports.pdf.classic.ClassicRadioCheck") +final class ClassicRadioCheckSubstitution { + + @Alias + ClassicPdfProducer pdfProducer; + @Alias + RadioCheckField radioCheckField; + + @Substitute + public void addToGroup() throws IOException { + PdfFormField radioGroup = this.pdfProducer.getRadioGroup(this.radioCheckField); + + try { + radioGroup.addKid(this.radioCheckField.getKidField()); + } catch (DocumentException var3) { + DocumentException e = var3; + throw new JRRuntimeException(e); + } + } + +}