据我了解,索引是用户为幻灯片上的位置提供的,并layout_properties
显示实际的幻灯片布局。我不相信那里的任何东西都对应于索引位置。
例如:
doc <- read_pptx() %>%
add_slide(layout = "Two Content", master = "Office Theme") %>%
ph_with_text(type = "body", str = "body (index 1) is text") %>%
ph_with_text(type = "body", str = "body (index 2) is also text")
print(doc, target = "C:/Foo/doc_1.pptx") # Since type is not unique, both are body, they get printed as if they are the same, at the same index position on top of each other.
> layout_properties(doc)
master_name name type id ph_label offx offy cx cy
1 Office Theme Section Header body 3 Text Placeholder 2 0.7899311 3.1788200 8.500000 1.6406245
2 Office Theme Comparison body 5 Text Placeholder 4 5.0798611 1.6788200 4.420139 0.6996522
3 Office Theme Comparison body 6 Content Placeholder 5 5.0798611 2.3784722 4.420139 4.3211811
4 Office Theme Comparison body 4 Content Placeholder 3 0.5000000 2.3784722 4.418403 4.3211811
5 Office Theme Title and Content body 3 Content Placeholder 2 0.5000000 1.7500000 9.000000 4.9496533
6 Office Theme Two Content body 3 Content Placeholder 2 0.5000000 1.7500000 4.416667 4.9496533
7 Office Theme Two Content body 4 Content Placeholder 3 5.0833333 1.7500000 4.416667 4.9496533
8 Office Theme Comparison body 3 Text Placeholder 2 0.5000000 1.6788200 4.418403 0.6996522
9 Office Theme Title Slide dt 4 Date Placeholder 3 0.5000000 6.9513889 2.333333 0.3993056
10 Office Theme Title and Content dt 4 Date Placeholder 3 0.5000000 6.9513889 2.333333 0.3993056
11 Office Theme Title Only dt 3 Date Placeholder 2 0.5000000 6.9513889 2.333333 0.3993056
12 Office Theme Two Content dt 5 Date Placeholder 4 0.5000000 6.9513889 2.333333 0.3993056
13 Office Theme Section Header dt 4 Date Placeholder 3 0.5000000 6.9513889 2.333333 0.3993056
14 Office Theme Comparison dt 7 Date Placeholder 6 0.5000000 6.9513889 2.333333 0.3993056
15 Office Theme Blank dt 2 Date Placeholder 1 0.5000000 6.9513889 2.333333 0.3993056
16 Office Theme Two Content ftr 6 Footer Placeholder 5 3.4166667 6.9513889 3.166667 0.3993056
17 Office Theme Title Slide ftr 5 Footer Placeholder 4 3.4166667 6.9513889 3.166667 0.3993056
18 Office Theme Comparison ftr 8 Footer Placeholder 7 3.4166667 6.9513889 3.166667 0.3993056
19 Office Theme Blank ftr 3 Footer Placeholder 2 3.4166667 6.9513889 3.166667 0.3993056
20 Office Theme Title Only ftr 4 Footer Placeholder 3 3.4166667 6.9513889 3.166667 0.3993056
21 Office Theme Title and Content ftr 5 Footer Placeholder 4 3.4166667 6.9513889 3.166667 0.3993056
22 Office Theme Section Header ftr 5 Footer Placeholder 4 3.4166667 6.9513889 3.166667 0.3993056
23 Office Theme Comparison sldNum 9 Slide Number Placeholder 8 7.1666667 6.9513889 2.333333 0.3993056
24 Office Theme Title Only sldNum 5 Slide Number Placeholder 4 7.1666667 6.9513889 2.333333 0.3993056
25 Office Theme Title and Content sldNum 6 Slide Number Placeholder 5 7.1666667 6.9513889 2.333333 0.3993056
26 Office Theme Section Header sldNum 6 Slide Number Placeholder 5 7.1666667 6.9513889 2.333333 0.3993056
27 Office Theme Title Slide sldNum 6 Slide Number Placeholder 5 7.1666667 6.9513889 2.333333 0.3993056
28 Office Theme Blank sldNum 4 Slide Number Placeholder 3 7.1666667 6.9513889 2.333333 0.3993056
29 Office Theme Two Content sldNum 7 Slide Number Placeholder 6 7.1666667 6.9513889 2.333333 0.3993056
30 Office Theme Title Only title 2 Title 1 0.5000000 0.3003478 9.000000 1.2500000
31 Office Theme Title and Content title 2 Title 1 0.5000000 0.3003478 9.000000 1.2500000
32 Office Theme Two Content title 2 Title 1 0.5000000 0.3003478 9.000000 1.2500000
33 Office Theme Section Header title 2 Title 1 0.7899311 4.8194444 8.500000 1.4895833
34 Office Theme Comparison title 2 Title 1 0.5000000 0.3003478 9.000000 1.2500000
35 Office Theme Title Slide ctrTitle 2 Title 1 0.7500000 2.3298611 8.500000 1.6076389
36 Office Theme Title Slide subTitle 3 Subtitle 2 1.5000000 4.2500000 7.000000 1.9166667
doc <- doc %>% ph_with_text(type = "body", str = " text at real index 2", index = 2)
print(doc, target = "C:/Foo/doc_2.pptx") # Using the same pptx layout, adds text at index = 2.
> layout_properties(doc) # Comparing them, they don't appear to have new text placeholder entries.
master_name name type id ph_label offx offy cx cy
1 Office Theme Section Header body 3 Text Placeholder 2 0.7899311 3.1788200 8.500000 1.6406245
2 Office Theme Comparison body 5 Text Placeholder 4 5.0798611 1.6788200 4.420139 0.6996522
3 Office Theme Comparison body 6 Content Placeholder 5 5.0798611 2.3784722 4.420139 4.3211811
4 Office Theme Comparison body 4 Content Placeholder 3 0.5000000 2.3784722 4.418403 4.3211811
5 Office Theme Title and Content body 3 Content Placeholder 2 0.5000000 1.7500000 9.000000 4.9496533
6 Office Theme Two Content body 3 Content Placeholder 2 0.5000000 1.7500000 4.416667 4.9496533
7 Office Theme Two Content body 4 Content Placeholder 3 5.0833333 1.7500000 4.416667 4.9496533
8 Office Theme Comparison body 3 Text Placeholder 2 0.5000000 1.6788200 4.418403 0.6996522
9 Office Theme Title Slide dt 4 Date Placeholder 3 0.5000000 6.9513889 2.333333 0.3993056
10 Office Theme Title and Content dt 4 Date Placeholder 3 0.5000000 6.9513889 2.333333 0.3993056
11 Office Theme Title Only dt 3 Date Placeholder 2 0.5000000 6.9513889 2.333333 0.3993056
12 Office Theme Two Content dt 5 Date Placeholder 4 0.5000000 6.9513889 2.333333 0.3993056
13 Office Theme Section Header dt 4 Date Placeholder 3 0.5000000 6.9513889 2.333333 0.3993056
14 Office Theme Comparison dt 7 Date Placeholder 6 0.5000000 6.9513889 2.333333 0.3993056
15 Office Theme Blank dt 2 Date Placeholder 1 0.5000000 6.9513889 2.333333 0.3993056
16 Office Theme Two Content ftr 6 Footer Placeholder 5 3.4166667 6.9513889 3.166667 0.3993056
17 Office Theme Title Slide ftr 5 Footer Placeholder 4 3.4166667 6.9513889 3.166667 0.3993056
18 Office Theme Comparison ftr 8 Footer Placeholder 7 3.4166667 6.9513889 3.166667 0.3993056
19 Office Theme Blank ftr 3 Footer Placeholder 2 3.4166667 6.9513889 3.166667 0.3993056
20 Office Theme Title Only ftr 4 Footer Placeholder 3 3.4166667 6.9513889 3.166667 0.3993056
21 Office Theme Title and Content ftr 5 Footer Placeholder 4 3.4166667 6.9513889 3.166667 0.3993056
22 Office Theme Section Header ftr 5 Footer Placeholder 4 3.4166667 6.9513889 3.166667 0.3993056
23 Office Theme Comparison sldNum 9 Slide Number Placeholder 8 7.1666667 6.9513889 2.333333 0.3993056
24 Office Theme Title Only sldNum 5 Slide Number Placeholder 4 7.1666667 6.9513889 2.333333 0.3993056
25 Office Theme Title and Content sldNum 6 Slide Number Placeholder 5 7.1666667 6.9513889 2.333333 0.3993056
26 Office Theme Section Header sldNum 6 Slide Number Placeholder 5 7.1666667 6.9513889 2.333333 0.3993056
27 Office Theme Title Slide sldNum 6 Slide Number Placeholder 5 7.1666667 6.9513889 2.333333 0.3993056
28 Office Theme Blank sldNum 4 Slide Number Placeholder 3 7.1666667 6.9513889 2.333333 0.3993056
29 Office Theme Two Content sldNum 7 Slide Number Placeholder 6 7.1666667 6.9513889 2.333333 0.3993056
30 Office Theme Title Only title 2 Title 1 0.5000000 0.3003478 9.000000 1.2500000
31 Office Theme Title and Content title 2 Title 1 0.5000000 0.3003478 9.000000 1.2500000
32 Office Theme Two Content title 2 Title 1 0.5000000 0.3003478 9.000000 1.2500000
33 Office Theme Section Header title 2 Title 1 0.7899311 4.8194444 8.500000 1.4895833
34 Office Theme Comparison title 2 Title 1 0.5000000 0.3003478 9.000000 1.2500000
35 Office Theme Title Slide ctrTitle 2 Title 1 0.7500000 2.3298611 8.500000 1.6076389
36 Office Theme Title Slide subTitle 3 Subtitle 2 1.5000000 4.2500000 7.000000 1.9166667
doc <- read_pptx() %>%
add_slide(layout = "Two Content", master = "Office Theme") %>%
ph_with_text(type = "body", str = "A first text", index = 1) %>%
ph_with_text(type = "body", str = "A second text", index = 2) %>%
ph_with_text(type = "title", str = "A title")
print(doc, target = "C:/Foo/doc_3.pptx") # Add index values for the two "body" types, and they'll print in your supplied order/place.
doc4 <- read_pptx() %>%
add_slide(layout = "Two Content", master = "Office Theme") %>%
ph_with_text(type = "body", str = "body (index 1) is text") %>%
ph_add_text(str = "Bullet text") %>%
ph_add_par(level = 1) %>%
ph_add_text(str = "Bullet text 2") %>%
ph_add_par(level = 2) %>%
ph_add_text(str = "Lower level text 2")
print(doc4, target = "C:/Foo/doc_4.pptx")
layout_properties(doc4) # Looks the same