Posts

Showing posts with the label utility

Converting MS Documents to PDF using LibreOffice

I've been a long time user of LibreOffice . I first started with StarOffice , before moving to  OpenOffice , and finally the latest incarnation,  LibreOffice . While I use office suites less, preferring Wiki 's and if a versioned document is required, LaTeX , I still on occasion receive MS documents. Rather than reading these documents in MS-Word or MS-PowerPoint formats I prefer to convert to a PDF. Here is how to do that. The following shows how to convert a presentation to a PDF. It is a headless operation that works just as well over a set of documents. loimpress --headless --convert-to pdf presentation.pptx Similarly, lowriter --headless --convert-to pdf document.doc

Render R markdown to PDF from command line

I have been using Makefiles where command line tools for building a project are not generally available. This includes LaTeX documents and recently R projects. So here is an R script that can be used to render R markdown to PDF. #!/usr/bin/env R # Render R markdown to PDF. # Invoke with: # > R -q -f make.R --args my_report.Rmd # load packages require ( rmarkdown ) # require a parameter naming file to render if ( length ( args ) == 0 ) { stop ( "Error: missing file operand" , call. = TRUE ) } else { # read report to render from command line for ( rmd in commandArgs ( trailingOnly = TRUE )) { # render Rmd to PDF if ( grepl ( " \\ .Rmd$" , rmd ) && file.exists ( rmd )) { render ( rmd , pdf_document ()) } else { print ( paste ( "Ignoring: " , rmd )) } } } It will process Rmd files listed after the --args parameter. This script can t...