Convert a file into an image (magick image) where the pages are arranged in rows, each row can contain one to several pages.
The result can be saved as a png file.
Usage
to_miniature(
filename,
row = NULL,
ncol = NULL,
ncol_landscape = NULL,
width = NULL,
border_color = "#ccc",
border_geometry = "2x2",
dpi = 150,
fileout = NULL,
timeout = 120,
...
)Arguments
- filename
input filename, supported documents are 'Microsoft Word', 'Microsoft PowerPoint', 'RTF' and 'PDF' document.
- row
row index for every pages. 0 are to be used to drop the page from the final minature. If both
rowandncolare provided,rowtakes precedence and a warning is issued.c(1, 1)is to be used to specify that a 2 pages document is to be displayed in a single row with two columns.c(1, 1, 2, 3, 3)is to be used to specify that a 5 pages document is to be displayed as: first row with pages 1 and 2, second row with page 3, third row with pages 4 and 5.c(1, 1, 0, 2, 2)is to be used to specify that a 5 pages document is to be displayed as: first row with pages 1 and 2, second row with pages 4 and 5.
- ncol
number of pages per row. When set, pages are automatically arranged with
ncolpages per row. Ignored ifrowis also provided.- ncol_landscape
number of landscape-oriented pages per row. When set, portrait pages use
ncolper row and landscape pages usencol_landscapeper row. Requiresncol.- width
width of a single image, recommanded values are:
650 for docx files
750 for pptx files
- border_color
border color, see
magick::image_border().- border_geometry
border geometry to be added around images, see
magick::image_border().- dpi
resolution (dots per inch) to use for images, see
pdftools::pdf_convert().- fileout
if not NULL, result is saved in a png file whose filename is defined by this argument.
- timeout
timeout in seconds that libreoffice is allowed to use in order to generate the corresponding pdf file, ignored if 0.
- ...
arguments used by webshot2 when HTML document.
Value
a magick image object as returned by magick::image_read().
Examples
library(locatexec)
docx_file <- system.file(
package = "doconv",
"doc-examples/example.docx"
)
if(exec_available("word"))
to_miniature(docx_file)
pptx_file <- system.file(
package = "doconv",
"doc-examples/example.pptx"
)
if(exec_available("libreoffice") && check_libreoffice_export())
to_miniature(pptx_file)
#> The following command failed: /usr/bin/soffice --version
#> with following log:
#> /usr/lib/libreoffice/program/soffice.bin: error while loading shared libraries: libreglo.so: cannot open shared object file: No such file or directory
