per_jansson
per_jansson

Reputation: 2189

SmartGWT pdf export

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.

Upvotes: 3

Views: 2745

Answers (2)

Meindert
Meindert

Reputation: 384

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 :-)

Upvotes: 1

Charles Kendrick
Charles Kendrick

Reputation: 2059

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.

Upvotes: 0

Related Questions