Skip to content

Embedding PDF into RTF document via R language

2 messages · Dennis Fisher, Bert Gunter

#
R 3.4.1
OS X and Windows

Colleagues

I have a complicated problem that includes several components:
	R
	RTF
	PDF

Using R (and a slew of RTF commands), I assemble a text document with an RTF extension.  The document contains text, tables, and images (JPEG format, previously created with R).  
To ?import? the JPEG images into the document, I use the following R code:
	cat("\\pard\\qc {\\pict\\jpegblip\n", file=TEMPREPORT, append=T)
	cat(toupper(readBin(IMAGEFILE, "raw", 10000000)), fill=64, sep="",file=TEMPREPORT, append=T)
	cat("\n}\\par\\ql", file=TEMPREPORT, append=T)
The critical text is:
	jpegblip ? which presumably informs the RTF reader that what follows is a JPEG 
	readBin ? which reads the JPEG file

When the JPEG images are created, I also create identical PDF versions.  I would like, if possible, to ?import? the PDF versions (instead of the JPEG versions) into the RTF document.
I see two issues:
1.  It is not obvious what should replace the jpegblip command
2.  Is readBin the appropriate command to embed the PDF

I realize that this is not strictly an R issue but support for R is far better than that for RTF.

Any help would be appreciated.

Dennis


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone / Fax: 1-866-PLessThan (1-866-753-7784)
www.PLessThan.com
#
An obvious question is: why mess with RTF at all, as R and RStudio provide
support for document creation with embedded R content (i.e. through knitr
and associated)?

But be that as it may (i.e. don't answer that), have you tried posting on:

https://stackoverflow.com/      ?

Seems like this sort of question might fit better there.

Cheers,
Bert



Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Fri, Sep 22, 2017 at 10:21 AM, Fisher Dennis <fisher at plessthan.com>
wrote: