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

illegal reflective access while using default example #641

Open
BishopWolf opened this issue Mar 12, 2024 · 1 comment
Open

illegal reflective access while using default example #641

BishopWolf opened this issue Mar 12, 2024 · 1 comment

Comments

@BishopWolf
Copy link

BishopWolf commented Mar 12, 2024

I am using fr.opensagres.poi.xwpf.converter.pdf version 2.0.4 with apache poi 5.2.5

This is the error I am getting

Converting DOCX to PDF...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.lowagie.text.pdf.MappedRandomAccessFile$1 (file:/~/.m2/repository/com/lowagie/itext/2.1.7/itext-2.1.7.jar) to method java.nio.DirectByteBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of com.lowagie.text.pdf.MappedRandomAccessFile$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Failed to generate PDF

I could change the dependency to fr.opensagres.poi.xwpf.converter.pdf.itext5

but then I am getting Class not Found PdfConverter

This is my code example

/**
     * Converts a DOCX file to PDF using XDocReport API.
     * 
     * @param inputFileName The input file name (full path).
     */
    static public void convertToPDF(String inputFileName, String outputFileName) {
        // Set the output file names
        String outputNamePDF = changeFileExtension(outputFileName, "pdf");

        try ( // Open the input file
                InputStream docStream = new FileInputStream(new File(inputFileName));
                // Create a new DOCX document from the input stream
                XWPFDocument document = new XWPFDocument(docStream);
                // Create an output stream for the ODT file
                FileOutputStream pdfStream = new FileOutputStream(new File(outputNamePDF));) {

            // Convert the DOCX to PDF
            IJ.log("Converting DOCX to PDF...");
            // Instantiate the converter options
            PdfOptions optionsPDF = PdfOptions.create();
            // Instantiate the converter
            IXWPFConverter<PdfOptions> converter = PdfConverter.getInstance();
            // Convert the document to PDF
            converter.convert(document, pdfStream, optionsPDF);
        } catch (Exception e) {
            IJ.log("Failed to generate PDF: " + outputNamePDF);
            IJ.log(e.getMessage());
        }
    }

Am I doing something wrong or is this a bug??

@BishopWolf
Copy link
Author

Changing the dependency to fr.opensagres.poi.xwpf.converter.pdf.openpdf it works for template files (no images nor tables)
But it shows java.lang.NullPointerException on final reports. That's it, nothing more in the log file even when I log all exceptions.

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

1 participant