使用jspdf n GWT

使用jspdf n GWT,gwt,jspdf,Gwt,Jspdf,我正在尝试从客户端获取GWT中的PDF 我使用jspdf来实现这一点 这是我在GWT客户端onModuleLoad中的代码 public void onModuleLoad() { Button btn = new Button("click"); RootPanel.get().add(btn); btn.addClickHandler(new ClickHandler(){ @Override public void onC

我正在尝试从客户端获取GWT中的PDF 我使用jspdf来实现这一点

这是我在GWT客户端onModuleLoad中的代码

    public void onModuleLoad() {

    Button btn = new Button("click");
    RootPanel.get().add(btn);
    btn.addClickHandler(new ClickHandler(){

        @Override
        public void onClick(ClickEvent event) {
            callJs();
        }});

}

public native void callJs() /*-{
    var doc = new jsPDF();
    doc.text(20, 20, 'Hello world.');
    doc.save('Test.pdf');

}-*/;
}

在my project.html文件中, 我在标题中添加了这些

          <script type="text/javascript" src="examples/js/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="jspdf.js"></script>
<script type="text/javascript" src="jspdf.plugin.standard_fonts_metrics.js"></script>
<script type="text/javascript" src="jspdf.plugin.split_text_to_size.js"></script>
<script type="text/javascript" src="jspdf.plugin.from_html.js"></script>
<script type="text/javascript" src="FileSaver.js"></script>
请说明我遗漏了什么

注意:如果我在project.html页面中使用上述相同的代码 它很好用 但是当我在JSNI方法中放入相同的代码时,它就不起作用了

看起来您的浏览器404?还没有加载该代码


确保jspdf.js文件是您的根目录。war with your project.html

not get 404..我与project.html…FileSaver.js jquery-2.1.0.min.js jspdf.js jspdf.plugin.addimage.js jspdf.plugin.autoprint.jspdf.plugin.cell.jspdf.plugin.from_html.jspdf.plugin.javascript.js.jsjspdf.plugin.png_support.js jspdf.plugin.sillysvgrender.jspdf.plugin.split_text_to_size.js jspdf.plugin.standard_font_metrics.js jspdf.plugin.total_pages.js和库:base64.js sprintf.js如果我将此javascript代码放入project.html中。。我得到一个不同的错误。saveAs未定义我们是否需要添加一些依赖项或war,或者其他我已经有的东西我已经测试了你的js代码,一切都正常。您的jspdf.js可能已损坏。我更改了var doc=new jspdf;至var doc=$jsPDF;它开始工作了。。。
                 jsPDF is not defined