-1

I need to create a report system using LaTex templates and Java like programming language. I use JLR library but it's freeeware, this is my code:

    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());

Searching into the Web I find JLatexMath but, as far as I know, only generates equations in LaTex and not the entire PDF. Do you know a library in Java which generates an entire PDF file using a LaTex template?

Update: I execute de .tex file using Runtime.getRuntime().exec("pdflatex.exe...") command. But I don't achive save the PDF file.

Thanks in advance

2
  • 1
    This is not a code-writing service. You've stated a need and then asked if a solution exists. Of course, a solution exists! You want other people to do your work for you. Please show your work, or ask a more specific, technical question. Dec 11, 2015 at 12:14
  • 1
    Thank you Bob and I'm sorry for my question, I don't want to anyone do my job. I'll try to explain myself better.
    – Macarnis
    Dec 11, 2015 at 12:19

1 Answer 1

1

I think I have the solution, here is the code:

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();
}

}

It generates a .PDF and .dvi file in the same place of your .tex file. Thank you much for your help :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.