我有荷兰的点的
pdf image of the netherlands with dots
当我尝试将此pdf转换为png图片时,请使用pdftools
和png
,如下所示:
library(png)
library(pdftools)
bitmap <- pdf_render_page("netherlands.pdf", page = 1, dpi = 300)
png::writePNG(bitmap, "netherlands.png"))
结果如下:
图片没有 pdf版本中显示的点。
我该如何解决这个问题?
这是我的sessioninfo:
R version 3.3.2 (2016-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server 2008 R2 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252
[4] LC_NUMERIC=C LC_TIME=Dutch_Netherlands.1252
attached base packages:
[1] grid stats graphics grDevices utils datasets methods base
other attached packages:
[1] png_0.1-7 pdftools_1.4 psych_1.6.9 psy_1.1 maptools_0.8-41
[6] rgeos_0.3-21 rgdal_1.2-5 sp_1.2-4 tagcloud_0.6 Rcpp_0.12.12
[11] wordcloud_2.5 directlabels_2015.12.16 extrafont_0.17 haven_1.0.0 tm_0.6-2
[16] NLP_0.1-9 qdap_2.2.5 RColorBrewer_1.1-2 qdapTools_1.3.1 qdapRegex_0.6.0
[21] qdapDictionaries_1.0.6 tidyr_0.6.1 dplyr_0.5.0 readxl_1.0.0 reshape2_1.4.2
[26] Hmisc_4.0-2 Formula_1.2-1 survival_2.40-1 lattice_0.20-34 knitr_1.15.1
[31] ggthemes_3.4.0 ggplot2_2.2.1 rmarkdown_1.4
loaded via a namespace (and not attached):
[1] splines_3.3.2 gender_0.5.1 gtools_3.5.0 assertthat_0.1 latticeExtra_0.6-28 xlsxjars_0.6.1
[7] cellranger_1.1.0 yaml_2.1.14 slam_0.1-40 Rttf2pt1_1.3.4 backports_1.0.4 quadprog_1.5-5
[13] extrafontdb_1.0 chron_2.3-48 digest_0.6.12 colorspace_1.3-2 htmltools_0.3.5 Matrix_1.2-7.1
[19] plyr_1.8.4 XML_3.98-1.5 scales_0.4.1 gdata_2.17.0 htmlTable_1.7 tibble_1.2
[25] openNLP_0.2-6 reports_0.1.4 nnet_7.3-12 lazyeval_0.2.0 mnormt_1.5-5 magrittr_1.5
[31] evaluate_0.10 foreign_0.8-67 tools_3.3.2 data.table_1.10.0 stringr_1.1.0 xlsx_0.5.7
[37] munsell_0.4.3 cluster_2.0.5 plotrix_3.6-4 RCurl_1.95-4.8 igraph_1.0.1 labeling_0.3
[43] bitops_1.0-6 base64enc_0.1-3 venneuler_1.1-0 gtable_0.2.0 DBI_0.5-1 R6_2.2.0
[49] gridExtra_2.2.1 openNLPdata_1.5.3-2 rprojroot_1.1 rJava_0.9-8 stringi_1.1.2 parallel_3.3.2
[55] rpart_4.1-10 acepack_1.4.1
答案 0 :(得分:0)
更新:PDF格式在MacOS上展示正常(见下文)。我认为问题是pdf文件使用Windows上没有的字体。在Windows上我看到:
> pdf_fonts("~/../Downloads/netherlands_pdf.pdf")
Warning: error: Couldn't find a font for 'ZapfDingbats', subst is 'Helvetica'
name type embedded file
1 ZapfDingbats type1 FALSE C:\\Windows\\Fonts\\arial.ttf
渲染PDF时,我看到:
> bitmap <- pdf_render_page("~/../Downloads/netherlands_pdf.pdf")
Warning: error: No display font for 'ArialNarrow'
Warning: error: No display font for 'ArialNarrow,Bold'
Warning: error: No display font for 'ArialNarrow,Italic'
Warning: error: No display font for 'ArialNarrow,BoldItalic'
Warning: error: No display font for 'ArialNarrow-Bold'
Warning: error: No display font for 'ArialNarrow-Italic'
Warning: error: No display font for 'ArialNarrow-BoldItalic'
Warning: error: No display font for 'HelveticaNarrow'
Warning: error: No display font for 'HelveticaNarrow,Bold'
Warning: error: No display font for 'HelveticaNarrow,Italic'
Warning: error: No display font for 'HelveticaNarrow,BoldItalic'
Warning: error: No display font for 'HelveticaNarrow-Bold'
Warning: error: No display font for 'HelveticaNarrow-Italic'
Warning: error: No display font for 'HelveticaNarrow-BoldItalic'
Warning: error: No display font for 'BookAntiqua'
Warning: error: No display font for 'BookAntiqua,Bold'
Warning: error: No display font for 'BookAntiqua,Italic'
Warning: error: No display font for 'BookAntiqua,BoldItalic'
Warning: error: No display font for 'BookAntiqua-Bold'
Warning: error: No display font for 'BookAntiqua-Italic'
Warning: error: No display font for 'BookAntiqua-BoldItalic'
Warning: error: No display font for 'ArialUnicode'
所以我怀疑这些圆点实际上是用字体(可能是dingbat)打印的,但如果这个字体不可用则无法渲染。
在OSX上没有这样的警告,输出似乎是正确的:
但是我不确定为什么pdf在Windows上的Chrome中正确显示。也许铬包括额外的字体?