0

I have a custom PPT template that I am using successfully to display all sort of information - I m now trying to format the color of some of the text based on specific rules. I haven't included the rules here. I have followed some examples : https://stackoverflow.com/a/63366352/5029248 and able to reproduce, for instance using the default placeholder 'title' however I can't seem to figure out a way to format the font in an existing custom placeholder.

doc_1 <- read_pptx("Template.pptx")
Layout<-'Login_funnel_color'
Layout_properties<-layout_properties ( x = doc_1,layout=Layout )
Layout_properties

Below are the placeholder that I have customised in my template

       master_name               name type  id                ph_label                                                            ph      offx     offy         cx
544 Content Slides Login_funnel_color body 108    Text Placeholder 107 <p:ph type="body" sz="quarter" idx="27" hasCustomPrompt="1"/> 0.8361100 5.689304  0.3801170
545 Content Slides Login_funnel_color body   2             Rectangle 1                                                          <NA> 0.0000000 0.000000 13.3333333
548 Content Slides Login_funnel_color body  65            Rectangle 64                                                          <NA> 0.2083333 4.468800  0.9472222
549 Content Slides Login_funnel_color body  66            Rectangle 65                                                          <NA> 0.2083333 4.788193  0.9303740
551 Content Slides Login_funnel_color body  10      Text Placeholder 9 <p:ph type="body" sz="quarter" idx="10" hasCustomPrompt="1"/> 0.2083333 1.402778  1.9166667
552 Content Slides Login_funnel_color body  18     Text Placeholder 17 <p:ph type="body" sz="quarter" idx="12" hasCustomPrompt="1"/> 0.2083333 3.095487  1.9166667
553 Content Slides Login_funnel_color body  22     Text Placeholder 21 <p:ph type="body" sz="quarter" idx="13" hasCustomPrompt="1"/> 0.2083333 3.532987  1.9166667
554 Content Slides Login_funnel_color body  24     Text Placeholder 23 <p:ph type="body" sz="quarter" idx="14" hasCustomPrompt="1"/> 0.2083333 4.789931  0.9319444
555 Content Slides Login_funnel_color body  28     Text Placeholder 27 <p:ph type="body" sz="quarter" idx="15" hasCustomPrompt="1"/> 0.2083333 5.227431  0.9319444
556 Content Slides Login_funnel_color body  31     Text Placeholder 30 <p:ph type="body" sz="quarter" idx="16" hasCustomPrompt="1"/> 0.2083333 6.484376  1.9166667
557 Content Slides Login_funnel_color body  34     Text Placeholder 33 <p:ph type="body" sz="quarter" idx="17" hasCustomPrompt="1"/> 0.2083333 6.913194  1.9166667
558 Content Slides Login_funnel_color body  73            Rectangle 72                                                          <NA> 1.1555556 4.467065  0.9694444
559 Content Slides Login_funnel_color body  74            Rectangle 73                                                          <NA> 1.1444444 4.781300  0.9784722
560 Content Slides Login_funnel_color body  78     Text Placeholder 77 <p:ph type="body" sz="quarter" idx="18" hasCustomPrompt="1"/> 1.1423611 4.790678  0.9805556
561 Content Slides Login_funnel_color body  80     Text Placeholder 79 <p:ph type="body" sz="quarter" idx="19" hasCustomPrompt="1"/> 1.1444444 5.228178  0.9805556
562 Content Slides Login_funnel_color body  82         Arrow: Right 81                                                          <NA> 0.9184175 3.273607  0.4747496
563 Content Slides Login_funnel_color body  83         Arrow: Right 82                                                          <NA> 0.9184175 1.579979  0.4747496
564 Content Slides Login_funnel_color body  87     Text Placeholder 86 <p:ph type="body" sz="quarter" idx="20" hasCustomPrompt="1"/> 0.2274311 2.300348  0.6579856
565 Content Slides Login_funnel_color body  88              TextBox 87                                                          <NA> 0.9833333 2.244792  0.2388889
566 Content Slides Login_funnel_color body  89              TextBox 88                                                          <NA> 0.9833333 3.923314  0.2388889
567 Content Slides Login_funnel_color body  90              TextBox 89                                                          <NA> 0.6352581 5.596222  0.2388889
568 Content Slides Login_funnel_color body  92     Text Placeholder 91 <p:ph type="body" sz="quarter" idx="21" hasCustomPrompt="1"/> 1.3298611 2.312500  0.6666667
569 Content Slides Login_funnel_color body  94     Text Placeholder 93 <p:ph type="body" sz="quarter" idx="22" hasCustomPrompt="1"/> 0.2083333 3.989583  0.8611111
570 Content Slides Login_funnel_color body  98     Text Placeholder 97 <p:ph type="body" sz="quarter" idx="23" hasCustomPrompt="1"/> 1.3298611 3.989583  0.7829867
571 Content Slides Login_funnel_color body 106    Text Placeholder 105 <p:ph type="body" sz="quarter" idx="26" hasCustomPrompt="1"/> 0.2274311 5.684028  0.5918307
572 Content Slides Login_funnel_color body 111    Text Placeholder 110 <p:ph type="body" sz="quarter" idx="28" hasCustomPrompt="1"/> 1.2743898 5.671233  0.4089425
573 Content Slides Login_funnel_color body 113    Text Placeholder 112 <p:ph type="body" sz="quarter" idx="29" hasCustomPrompt="1"/> 1.8121982 5.687216  0.3891328
574 Content Slides Login_funnel_color body 114             TextBox 113                                                          <NA> 1.5446883 5.590103  0.2961581
575 Content Slides Login_funnel_color body 115        Arrow: Right 114                                                          <NA> 0.9312653 4.966865  0.4747496
576 Content Slides Login_funnel_color  pic 117 Picture Placeholder 116                      <p:ph type="pic" sz="quarter" idx="30"/> 3.0277778 1.513520 10.0781255
577 Content Slides Login_funnel_color  pic 119 Picture Placeholder 118                      <p:ph type="pic" sz="quarter" idx="31"/> 3.0277767 5.402778 10.0781245
578 Content Slides Login_funnel_color body 121             TextBox 120                                                          <NA> 3.2673021 2.974061  6.7083333
579 Content Slides Login_funnel_color  pic   8   Picture Placeholder 7                      <p:ph type="pic" sz="quarter" idx="32"/> 3.0277778 3.588542 10.0781255
580 Content Slides Login_funnel_color body   6   Content Placeholder 5             <p:ph sz="quarter" idx="33" hasCustomPrompt="1"/> 0.2083333 1.850694  1.9045144

adding a slide based on my layout

doc_1 <- add_slide(doc_1,layout=Layout, master='Content Slides')

Then creating the text element. Here I m trying to place the text in any of the placeholder type I have on my template

slide_text <- ftext("tt",fp_text(color = "black", font.size = 18, bold = TRUE))
doc_1 <- ph_with(x = doc_1, value = fpar(slide_text ),location =  ph_location_type(ph_label = "Text Placeholder 112"))
doc_1 <- ph_with(x = doc_1, value = fpar(slide_text ),location =  ph_location_type(ph_label = "TextBox 120"))
doc_1 <- ph_with(x = doc_1, value = fpar(slide_text ),location =  ph_location_type(ph_label = "Picture Placeholder 7"))
doc_1 <- ph_with(x = doc_1, value = fpar(slide_text ),location =  ph_location_type(ph_label = "Content Placeholder 5"))

print(doc_1, target="temp.pptx")

However, none of the text are placed within the placeholders selected, they all end up somewhere in the middle of the page at the same location. I m not sure what to do.

Text placed in the middle of the slide rather than on the box

stefan
  • 90,330
  • 6
  • 25
  • 51

0 Answers0