-1

I have these message on all converted files to PDF via Docx4j.

TO HIDE THESE MESSAGES, TURN OFF log4j debug level logging fororg.docx4j.convert.out.pdf .viaXSLFO

Is it possible to hide it? I found some solution here on Stack but It didn't help me because my application is simple. I used this code and put it in my application.

long start = System.currentTimeMillis();

    // 1) Load DOCX into WordprocessingMLPackage
File file = new File(sFiles.getAbsolutePath());

InputStream is = new FileInputStream(file);
String name=file.getName();
String destination= file.getAbsolutePath();
String outDestination=file.getParent();
String fileType=FilenameUtils.getExtension(destination);
        String name1=name.replaceAll(fileType, "");

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
                .load(is);

System.out.println(name);
// 2) Prepare Pdf settings
PdfSettings pdfSettings = new PdfSettings();

// 3) Convert WordprocessingMLPackage to Pdf

wordName=outDestination+"\\"+name1+"pdf";
FileOutputStream out = new FileOutputStream(wordName);
PdfConversion converter = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(
            wordMLPackage);
converter.output(out, pdfSettings);

System.err.println("Generate pdf/Resume.pdf with "
            + (System.currentTimeMillis() - start) + "ms");
MiOnIs
  • 125
  • 12

1 Answers1

1

As it says, TURN OFF log4j debug level logging for org.docx4j.convert.out.pdf .viaXSLFO. In other words, set the logging to level INFO or WARN, say.

Judging from https://github.com/plutext/docx4j/blob/master/src/samples/_resources/log4j.xml#L98 it looks like you might need to do that for "org.docx4j.convert.out.common.writer.AbstractMessageWriter" as well or instead.

And these days, docx4j uses slf4j. So that assumes you're using log4j as your logging implementation. In which case you can configure it with https://github.com/plutext/docx4j/blob/master/src/samples/_resources/log4j.xml

Otherwise, configure logging using your chosen logging implementation.

JasonPlutext
  • 15,352
  • 4
  • 44
  • 84
  • i don't have that xml to my project i only have class which i represent. I really don't understand what i need to do :/ What this message mean for there? Why is it here? -.- – MiOnIs Aug 27 '16 at 01:13
  • The messages warn you if there is some content which can't be converted to PDF using the viaXSLFO implementation. If the messages are turned off, that content will be silently dropped. – JasonPlutext Aug 27 '16 at 01:31