2012-01-20 89 views
3

有沒有人成功使用SmartGWT 3.x pdf導出?SmartGWT pdf導出

我的客戶端代碼如下所示:

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

RPCManager.exportContent(table, requestProperties); 

當代碼運行沒有任何反應。我必須做任何服務器端?

我可以只添加我的應用程序成功地使用列表網格中的SmartGWT excel導出。

回答

0

您的問題的答案是肯定的:無數的開發者已經成功地使用了SmartGWT的PDF導出。現在請給我分;)

要排除故障,查看您的服務器日誌中的錯誤。

+1

謝謝,但是你是否知道任何指定了服務器端需要做什麼的文檔?在web.xml中聲明特定的servlet還是自己實際執行pdf生成? –

+0

服務器端不需要做任何事情,它全部是自動的。但是,這裏是涉及自動行爲的服務器端類,它們有一些代碼示例用於執行相關的事情(例如將生成的.pdf保存到磁盤)http://www.smartclient.com/smartgwtee-latest/ server/javadoc/com/isomorphic/contentexport/PdfExport.html –

1

我也徒然試圖找到關於此的文檔。但並不難。你的代碼看起來不錯,已經添加了一個畫布來打印和行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); 

我加入從smartgwtEE lib文件夾下面的jar文件(在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"/> 

而這一切,這是它:-)

+0

這裏是所有docd在這裏:http://www.smartclient.com/smartgwtee-latest/javadoc/com/smartgwt/client/docs/JavaModuleDependencies.html注意正如文檔所說,你應該需要包含Flying Saucer的core-renderer.jar,據推測你的項目已經擁有了它。 –