3

Has anyone successfully used SmartGWT 3.x pdf export?

My client code looks like this:

DSRequest requestProperties = new DSRequest();
requestProperties.setExportFilename("File.pdf");
requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
requestProperties.setContentType("application/pdf");

RPCManager.exportContent(table, requestProperties);

When the code run nothing happens. Do I have to do anything server side?

I can just add that my application is successfully using the SmartGWT excel export from the list grid.

per_jansson
  • 2,103
  • 4
  • 29
  • 46

2 Answers2

1

I also tried in vain to find the documentation about this. But it's not that hard. Your code seems right, have added a canvas to print and the line requestProperties.setDownloadResult(true);

            final Canvas canvas = new Canvas();
            canvas.setWidth(300);
            canvas.setBorder("2px solid Red");
            DynamicForm formPrint = new DynamicForm();
            formPrint.setWidth(200);
            formPrint.setHeight(100);
            formPrint.setTop(20);
            formPrint.setLeft(50);
            formPrint.setBorder("2px solid Black");
            TextItem textItem = new TextItem();
            textItem.setName("NameBo");
            textItem.setTitle("Title");
            textItem.setValue("Value goes here...");
            formPrint.setFields(textItem);
            canvas.addChild(formPrint);
            canvas.draw();  // to view onscreen


            DSRequest requestProperties = new DSRequest();
            requestProperties.setExportFilename("File");
            requestProperties.setExportDisplay(ExportDisplay.DOWNLOAD);
            requestProperties.setContentType("application/pdf");
            requestProperties.setDownloadResult(true);
            RPCManager.exportContent(canvas, requestProperties);

I then added the following jars from the smartgwtEE lib folder (in eclipse .classpath)

<classpathentry kind="var" path="SGWTEE_HOME/lib/isomorphic_contentexport.jar"/>
<classpathentry kind="var" path="SGWTEE_HOME/lib/iText-2.0.8.jar"/>
<classpathentry kind="var" path="SGWTEE_HOME/lib/jtidy-r938.jar"/>

And that's all that was to it :-)

Meindert
  • 384
  • 2
  • 9
  • This is all doc'd here: http://www.smartclient.com/smartgwtee-latest/javadoc/com/smartgwt/client/docs/JavaModuleDependencies.html Note that, as the docs say, you should have needed to include Flying Saucer's core-renderer.jar, presumably your project already had it. – Charles Kendrick Apr 25 '13 at 18:36
0

The answer to your question is yes: countless developers have successfully used SmartGWT's PDF Export. Now gimme my points please ;)

To troubleshoot, look in your server logs for errors.

Charles Kendrick
  • 2,059
  • 13
  • 14
  • 1
    Thanks, but do you by any change know of any documentation that specifies what needs to be done server side? Declare a specific servlet in web.xml or actually perform the pdf generation myself? – per_jansson Jan 22 '12 at 21:52
  • Nothing needs to be done server-side, it's all automatic. However, here are the server-side classes involved in the automatic behavior, and they have some code samples for doing something related (such as saving a generated .pdf to disk) http://www.smartclient.com/smartgwtee-latest/server/javadoc/com/isomorphic/contentexport/PdfExport.html – Charles Kendrick Jun 07 '12 at 18:49