0

To convert docx to pdf, I want to do it with the latest method. I get help from this website.

https://simplesolution.dev/java-convert-docx-file-to-pdf-file-using-xdocreport/

I add the library to my project and test the code example. Finally I get this warning :

WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.lowagie.text.pdf.MappedRandomAccessFile$1 (file:/C:/Users/ToOpbOoy/.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

I did not find anything about this warning on the Internet. What is this warning and how can it be solved?

I did the conversion with apache poi and itext libraries. But it does not convert correctly.

Hooman
  • 1
  • 3
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 28 '23 at 15:43
  • If you google `WARNING: An illegal reflective access operation has occurred` - you will get 1.25m matches. First one is https://stackoverflow.com/questions/50251798/what-is-an-illegal-reflective-access – PJ Fanning Mar 01 '23 at 15:29

1 Answers1

0

I think you can try the Spire.Doc for java component.Spire.Doc for Java can be applied easily to convert Word to PDF in high quality.Last but not least it is very easy to operate.Please visit this link to explore more about for Spire.Doc for Java. Here is part of the codeis:

        //Load a sample Word document
        doc.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.docx");

        //Create a ToPdfParameterList instance
        ToPdfParameterList ppl=new ToPdfParameterList();

        //Embed all fonts in the PDF document 
        ppl.isEmbeddedAllFonts(true);

        //Remove the hyperlinks and keep the character formats
        ppl.setDisableLink(true);

        //Set the output image quality as 40% of the original image. 80% is the default setting.
        doc.setJPEGQuality(40);

        //Save the document as PDF
        doc.saveToFile("output/ToPDF.pdf", ppl);