Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用LaTex模板和Java创建PDF文件_Java_Templates_Latex_Pdf Generation - Fatal编程技术网

使用LaTex模板和Java创建PDF文件

使用LaTex模板和Java创建PDF文件,java,templates,latex,pdf-generation,Java,Templates,Latex,Pdf Generation,我需要使用LaTex模板和类似Java的编程语言创建一个报告系统。我使用JLR库,但它是免费软件,这是我的代码: File workingDirectory = new File("./config/output"); File desktop = new File("./config/desktop"); File invoice1 = new File("./config/templates/template1.tex"); File invoice2 = n

我需要使用LaTex模板和类似Java的编程语言创建一个报告系统。我使用JLR库,但它是免费软件,这是我的代码:

    File workingDirectory = new File("./config/output");
    File desktop = new File("./config/desktop");
    File invoice1 = new File("./config/templates/template1.tex");
    File invoice2 = new File("./config/templates/template2.tex");
    JLRGenerator pdfGen = new JLRGenerator();

    pdfGen.deleteTempTexFile(false);

    if (!pdfGen.generate(invoice1, desktop, workingDirectory)) { 
        System.out.println(pdfGen.getErrorMessage());
    }

    JLROpener.open(pdfGen.getPDF());

    if (!pdfGen.generate(invoice2, desktop, workingDirectory)) {
        System.out.println(pdfGen.getErrorMessage());
    }

    JLROpener.open(pdfGen.getPDF());
在网上搜索我找到了JLatexMath,但据我所知,它只生成LaTex中的方程,而不是整个PDF。你知道Java中有一个库使用LaTex模板生成整个PDF文件吗

更新:我使用Runtime.getRuntime().exec(“pdflatex.exe…”)命令执行de.tex文件。但是我没有保存PDF文件


提前感谢

我想我已经找到了解决方案,下面是代码:

public void generateReport()
{
Process p;
try {
    p = Runtime.getRuntime().exec("C:\\pdflatex.exe -synctex=1 -interaction=nonstopmode ./config/log/document.tex");
    p.waitFor();
} catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
} catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}
}


它会在.tex文件的同一位置生成.PDF和.dvi文件。非常感谢您的帮助:)

这不是代码编写服务。您已经说明了需要,然后询问是否存在解决方案。当然,解决方案是存在的!你希望别人为你工作。请展示你的工作,或者问一个更具体的技术问题。谢谢你,鲍勃,我很抱歉我的问题,我不想让任何人做我的工作。我会试着更好地解释我自己。