【问题标题】:Run pdftk in JSP在 JSP 中运行 pdftk
【发布时间】:2015-04-07 04:17:19
【问题描述】:

我有将 pdf 文件名存储在 jsp 页面 print.jsp 中的数组值 我想在打印之前合并 pdf。

这是我的代码:

<%
    try
    {
        String[] ids=request.getParameterValues("list");
        for (String id:ids)
        {
            System.out.print(id);
        }

        //Runtime.getRuntime().exec("pdftk" +id+ "cat output output.pdf");
    }
    catch(Exception e)
    {
        System.out.println("fail");
    }
%>

如何写入数组值来填充 pdftk 命令。请帮帮我。

【问题讨论】:

    标签: javascript arrays jsp pdftk


    【解决方案1】:

    我想这就是你需要的......

    try {
        String[] ids = request.getParameterValues("list");
        StringBuilder sb = new StringBuilder();
        for (String id : ids) {
            sb.append(" "+id);
            System.out.print(id);
        }
    
        Runtime.getRuntime().exec("pdftk" + sb.toString() + " cat output output.pdf");
    } catch (Exception e) {
        System.out.println("PDF fail to merge");
    }
    

    【讨论】:

    • 确实有效,需要在 'sb.append(" "+id)' 中添加一些修正空间。谢谢你帮助我。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 2020-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多