简体   繁体   中英

Generate HTML reports containing info stored in pdf files

I would like to generate an html report containing some outputs (graphs, statistics from R). The graphs are saved in pdf files.

My option : perl script that will generate the html report( by converting the pdf into jpeg)

What other options would be ideal in this case?

I am working in UNIX environment.

If you are familiar with R, you can probably look at the knitr package . R2HTML is based on Sweave, which is not quite extensible, and knitr is fully extensible and supports HTML naturually; see a minimal example with source .

You have many choices on how to save R graphics (pdf, png, jpeg, ...); see the dev option (graphical device). So there is no need for conversion from PDF to other bitmap formats on R's side.

You said you had Ruby and C output as well; I'm not sure how you are going to deal with them: do you want to generate the output dynamically (literate programming) or insert them manually? For the former, you can probably use the R function system() to run external programs (eg call C to generate PDF and call perl to convert). You can also define knitr hooks to do these jobs, but you may need to more to learn how hooks work in knitr .

Another approach is to convert your PDF output with a batch job, and modify the HTML code, eg replace <img src='foobar.pdf' /> with <img src='foobar.jpeg' /> in HTML after you have converted all PDF files to JPEG. This should easier.

If you have control over the how the graphs and statistics are created in R, your easiest approach would probably be using the R2HTML package to generate the HTML directly. This would include an sweave-like approach which would substitute R output in appropriate places in an HTML template.

Also, R can create jpeg files (or gif's) for graphs as easily as it creates PDF's, so that conversion step can be avoided entirely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM