FlowingCode / GridExporterAddon

Apache License 2.0
10 stars 9 forks source link

Exported pdf is 0 bytes #136

Open drewharvey opened 2 weeks ago

drewharvey commented 2 weeks ago

Describe the bug

I am able to download the PDF file but it is 0 bytes and fails to open. All other file types download/open correctly.

files

Expected behavior

PDF should have content and open as expected.

Minimal reproducible example

var grid = new Grid<String>();
grid.addColumn(String::toString).setHeader("Name");
grid.addColumn(String::toString).setHeader("Email");

grid.setItems("A", "B", "C");

var exporter = GridExporter.createFor(grid);
exporter.setTitle("Grid Export Title");
exporter.setFileName("GridExport_" + new SimpleDateFormat("yyyyddMM").format(Calendar.getInstance().getTime()));
exporter.setAutoAttachExportButtons(true);

add(grid);

Add-on Version

2.3.2

Vaadin Version

24.4.3

Additional information

Chrome (latest)

mlopezFC commented 2 weeks ago

Hi @drewharvey ! ... thanks for the issue! When one of the downloaded files is 0 bytes, that usually mean that a problem happened when generating the file. We have to fix this known issue (the exception logging is not correctly implemented), but can you add a breakpoint and debug this method to see if the generation happens correctly or there is an exception being hidden?

drewharvey commented 2 weeks ago

Problem occurs here: https://github.com/FlowingCode/GridExporterAddon/blob/ec5d5ad7bda3d1509a95c3af7a2daac17b3c7521/src/main/java/com/flowingcode/vaadin/addons/gridexporter/PdfInputStreamFactory.java#L62

Here the stacktrace:

Exception in thread "Thread-83" java.lang.NoClassDefFoundError: javax/xml/bind/ValidationEventHandler
    at com.flowingcode.vaadin.addons.gridexporter.PdfInputStreamFactory$1.run(PdfInputStreamFactory.java:63)
    at java.base/java.lang.Thread.run(Thread.java:1570)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.ValidationEventHandler
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
    ... 2 more
mlopezFC commented 2 weeks ago

Maybe this can also work for this issue, can you give it a try?