Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ppt slide number not equal to index #12

Closed
alexhli opened this issue May 9, 2017 · 5 comments
Closed

ppt slide number not equal to index #12

alexhli opened this issue May 9, 2017 · 5 comments
Labels

Comments

@alexhli
Copy link

alexhli commented May 9, 2017

Hello,

I am reading in a ppt presentation created using ReporteRs, and am trying to add internal links within the presentation. I have noticed that the slide index is not always equal to the slide number, is this expected?

doc <- on_slide(doc, index=5)
slide_summary(doc)
Source: local data frame [5 x 7]
type id offx offy cx cy text
(chr) (chr) (int) (int) (int) (int) (chr)
title 1 NA NA NA NA blahblah
body 2 1371600 1371600 2743200 2743200
body 3 5029200 1371600 2743200 2743200
sldNum 2 NA NA NA NA 13
ftr 3 NA NA NA NA 2017-05-08number

@davidgohel
Copy link
Owner

Can you make a reproducible example and the sessionInfo()?

@alexhli
Copy link
Author

alexhli commented May 9, 2017

Here's a simple example. The footer of every slide in the slideshow "myoutput2.pptx" should be a link back to slide #2; instead they all link to slide #10.

#====Create presentation using ReporteRs
template_path<-"mytemplate.pptx" 
output_path1<-"myoutput1.pptx"
today <- Sys.Date()
mydoc <- pptx(template=template_path)
slide.layouts(mydoc)

mydoc = addSlide(mydoc, "Title Slide" )  #pick the slide format from the template parameter
mytitle<-paste("Main Title")

for (i in 1:20){
  mydoc = addSlide(mydoc, "Title and Content" )  #pick the slide format from the template parameter
  mydoc = addTitle(mydoc, paste("Title", i))
  slidetext = c( "test")
  mydoc <-addParagraph( mydoc, value = slidetext )
  mydoc = addPageNumber( mydoc )
  mydoc = addFooter( mydoc, today)
}
writeDoc( mydoc, output_path1 )


#====Add internal links using officeR
doc <- read_pptx(output_path1)
doc_nslides<-length(doc)
for(i in 3:doc_nslides){
  doc <- on_slide(doc, index=i)
  doc <- ph_slidelink(doc, type = "ftr", slide_index = 2)#takes user to slide #2
}
print(doc, target = "myoutput1.pptx")

And here is the session info:

> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.5 (unknown)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] VennDiagram_1.6.17  GGally_1.3.0        stringr_1.0.0       scales_0.4.1        gridExtra_2.0.0     xtable_1.8-0        gplots_2.17.0       raster_2.4-18       sp_1.1-1           
[10] png_0.1-7           ReporteRs_0.8.2     ReporteRsjars_0.0.2 extrafont_0.17      qqman_0.1.2         futile.logger_1.4.1 progress_1.0.2      officer_0.1.1       plotly_4.5.6       
[19] ggplot2_2.2.0       rJava_0.9-7        

loaded via a namespace (and not attached):
 [1] gtools_3.5.0         purrr_0.2.2          reshape2_1.4.1       lattice_0.20-31      colorspace_1.2-6     htmltools_0.3.5      viridisLite_0.1.3    yaml_2.1.13         
 [9] base64enc_0.1-3      R.oo_1.21.0          DBI_0.3.1            R.utils_2.5.0        gdtools_0.1.4        RColorBrewer_1.1-2   lambda.r_1.1.7       plyr_1.8.3          
[17] munsell_0.4.2        gtable_0.2.0         R.methodsS3_1.7.1    htmlwidgets_0.8      caTools_1.17.1       labeling_0.3         parallel_3.2.1       Rttf2pt1_1.3.3      
[25] Rcpp_0.12.10         KernSmooth_2.23-14   gdata_2.17.0         jsonlite_1.1         digest_0.6.8         stringi_0.5-5        dplyr_0.4.3          tools_3.2.1         
[33] bitops_1.0-6         magrittr_1.5         lazyeval_0.2.0       tibble_1.2           futile.options_1.0.0 extrafontdb_1.0      tidyr_0.6.0          xml2_1.1.1          
[41] prettyunits_1.0.2    assertthat_0.1       reshape_0.8.5        httr_1.2.1           R6_2.1.2       

@alexhli alexhli closed this as completed May 9, 2017
@davidgohel
Copy link
Owner

That's because you're working with an old version, update the package from CRAN and things will be ok

@alexhli
Copy link
Author

alexhli commented May 9, 2017

updating to the new version 0.1.3 seems to have resolved this issue. Thanks!

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants