NPE when render pptx/xlsx as png with groupdocs-viewer version: 24.8 Java

Hello, could you please help me to solve this problem?

groupdocs-viewer version: 24.8
Java version: 21

pull GitHub - groupdocs-viewer/GroupDocs.Viewer-for-Java: GroupDocs.Viewer for Java examples, plugins and showcase and change the RenderDocumentWithNotes class as following:

package com.groupdocs.viewer.examples.advanced_usage.rendering.common_rendering_options;

import com.groupdocs.viewer.Viewer;
import com.groupdocs.viewer.examples.TestFiles;
import com.groupdocs.viewer.examples.Utils;
import com.groupdocs.viewer.options.HtmlViewOptions;
import com.groupdocs.viewer.options.PngViewOptions;

import java.nio.file.Path;

public class RenderDocumentWithNotes {

    /**
     * This example demonstrates how to render presentation with notes.
     */

    public static void run() {
        Path outputDirectory = Utils.getOutputDirectoryPath("RenderDocumentWithNotes");
        Path pageFilePathFormat = outputDirectory.resolve("page_{0}.html");

//        HtmlViewOptions viewOptions = HtmlViewOptions.forEmbeddedResources(pageFilePathFormat);
//        viewOptions.setRenderNotes(true);
        PngViewOptions viewOptions = new PngViewOptions(pageFilePathFormat);
        viewOptions.setMaxWidth(1024);

        try (Viewer viewer = new Viewer(TestFiles.PPTX_WITH_NOTES)) {
            viewer.view(viewOptions);
        }

        System.out.println(
                "\nSource document rendered successfully.\nCheck output in " + outputDirectory);
    }
}
package com.groupdocs.viewer.examples;

import com.groupdocs.viewer.examples.advanced_usage.rendering.common_rendering_options.RenderDocumentWithNotes;

import java.io.IOException;

public class RunExamples {

    /**
     * The main method.
     */
    public static void main(String[] args) throws IOException {

        System.out.println("Uncomment the example(s) that you want to run in RunExamples.java file.");
        System.out.println("=======================================================================");

        Utils.cleanOutputDirectory();


        RenderDocumentWithNotes.run();

        // endregion

        System.out.println();
        System.out.println("All done.");
    }
}

Run the above will get following error:

Exception in thread "main" java.lang.NullPointerException: Cannot invoke "com.groupdocs.viewer.internal.c.a.ms.System.Drawing.Bitmap.getWidth()" because "<parameter1>" is null
	at com.groupdocs.viewer.common.e.a(Unknown Source)
	at com.groupdocs.viewer.domain.documents.b.b.b.b(Unknown Source)
	at com.groupdocs.viewer.domain.documents.b.b.a.b(Unknown Source)
	at com.groupdocs.viewer.domain.documents.b.e.a(Unknown Source)
	at com.groupdocs.viewer.domain.d.e.closePageStream(Unknown Source)
	at com.groupdocs.viewer.domain.documents.converting.a.a(Unknown Source)
	at com.groupdocs.viewer.domain.documents.b.e.a(Unknown Source)
	at com.groupdocs.viewer.domain.e.b.a(Unknown Source)
	at com.groupdocs.viewer.domain.e.b.a(Unknown Source)
	at com.groupdocs.viewer.domain.e.b.a(Unknown Source)
	at com.groupdocs.viewer.Viewer.view(Unknown Source)
	at com.groupdocs.viewer.examples.advanced_usage.rendering.common_rendering_options.RenderDocumentWithNotes.run(RenderDocumentWithNotes.java:27)
	at com.groupdocs.viewer.examples.RunExamples.main(RunExamples.java:63)

thanks & Regards
Aray

Hello, @ArayCN !
I have verified and reproduced the issue, which is assigned the number VIEWERJAVA-3681. This problem occurs with Java versions newer than 15. I will investigate and resolve it.
As a temporary workaround, you can run the code using Java 15 or earlier.
Another way is to use next Java VM options (works for newer Java versions):

--add-opens java.desktop/sun.java2d=ALL-UNNAMED --add-opens java.desktop/sun.awt.image=ALL-UNNAMED

Thanks.

1 Like

Thanks @aleksey.permyakov

I added above VM options, it works for rendering PPTX file.

But for XLSX file, It still does NOT work.

@ArayCN which XLSX file did you use? I tried several and couldn’t reproduce the bug.

1 Like

Thanks!

I have just test sveral xlsx files. All worked but only one does not work. I think this file may be not a proper xlsx file.

Have a super ultra greate day(or night).

Regards
Aray

1 Like