如何在使用pictureGrob创建的PDF中创建可点击的图片? [英] How to have a clickable picture in a PDF created using pictureGrob?
本文介绍了如何在使用pictureGrob创建的PDF中创建可点击的图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个简单的阴谋,并且有一个图片实际上是一个SVG图标,如下所示:
library(ggplot2);库(网格); library(gridExtra)
facebookGrob< - gTree(children = gList(pictureGrob(readPicture(inst / svg / facebook2.svg))))
p1< --gGplot()+
ggplot2 :: annotation_custom(facebookGrob,xmin = 1.8,xmax = 3.2,ymin = -0.6,ymax = 1)
final < - arrangeGrob(p1 ,. ..,)
ggsave(filename ='output.pdf',plot = final,...)
有没有什么方法可以在最终PDF中的SVG图标之上生成可点击的链接? 解决方案
tikzDevice包允许你插入超链接作为节点,
library(tikzDevice)
tikz(annotation.tex ,width = 4,height = 4,standAlone = TRUE,
packages = c(getOption('tikzLatexPackages'),
\\usepackage {hyperref},
\ \ usetikzlibrary {positioning})
)
tg < - tikzNodeGrob(x = 0.5,y = 0.5,name ='google',
content ='\ \href {H ttp://www.google.com} {\\includegraphics [width = 1in] {google.png}}',
units =native)
qplot(1 :10,1:10)+
annotation_custom(grob = tg,xmin = 3,xmax = 3,ymin = 5,ymax = 5)
dev.off()
I create a simple plot and have a picture actually an SVG icon as follows:
library(ggplot2); library(grid); library(gridExtra)
facebookGrob <- gTree(children=gList(pictureGrob(readPicture("inst/svg/facebook2.svg"))))
p1 <- ggplot() +
ggplot2::annotation_custom(facebookGrob, xmin=1.8, xmax=3.2, ymin=-0.6, ymax=1)
final <- arrangeGrob(p1,...,)
ggsave(filename='output.pdf',plot=final,...)
Is there any way to generate a clickable link on top of this SVG icon in the final PDF?
解决方案
the tikzDevice package lets you insert hyperref links as nodes,
library(tikzDevice)
tikz("annotation.tex",width=4,height=4, standAlone = TRUE,
packages = c(getOption('tikzLatexPackages'),
"\\usepackage{hyperref}",
"\\usetikzlibrary{positioning}")
)
tg <- tikzNodeGrob(x = 0.5, y = 0.5, name = 'google',
content='\\href{http://www.google.com}{\\includegraphics[width=1in]{google.png}}',
units = "native")
qplot(1:10, 1:10) +
annotation_custom(grob = tg, xmin=3,xmax=3,ymin=5,ymax=5)
dev.off()
这篇关于如何在使用pictureGrob创建的PDF中创建可点击的图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文