Comments (13)
Hi
I can't reproduce the issue, sorry. All is OK for me
from officer.
I'm experiencing the same issue. For me, it has to do with a non-default pptx template. I don't know what it is about the template that causes this, but the default for adding text using officer is bold (note that when adding a text box directly in powerpoint, however, the default text is not bold) and it is not overridden by using fp_text(bold = FALSE)
.
from officer.
For a little more detail, I have a slide for which the master is just a header and no content. I first add a header to the slide. Then I add a custom element to the slide using ph_empty_at()
. If I leave the content of this blank and view the result, it shows that it is a placeholder for another header. Using ph_add_par(... type = "body")
on this element doesn't make it act like a body element which doesn't have bold styling, it stays bold even when I explicitly use fp_text(bold = FALSE)
. Is there any way to make ph_empty_at()
be able to specify which type of element it is creating?
from officer.
Oh sorry I think it looks like you just fixed this here: #47
from officer.
This is the code I used to test this case:
library(magrittr)
library(officer)
style_txt <- fp_text(font.size = 16, bold = FALSE,
font.family = "Calibri", vertical.align = 'baseline')
my_pres <- read_pptx() %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_empty(type = "body") %>%
ph_add_par() %>%
ph_add_text(str = "Title - text", type = "body", style = style_txt) %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_empty_at(left = 1, top = 2, width = 5, height = 4, template_type = "body") %>%
ph_add_par() %>%
ph_add_text(str = "Title - text", type = "body", style = style_txt)
print(my_pres, target = "test.pptx")
Could you show me the code you are using?
from officer.
Yes sorry I meant to say by my last comment that your latest commit fixed this for me. The ability to specify template_type = "body"
solves the problem, as before then it was using the title template. Although it would seem like fp_text()
should be able to override the boldness of a title template as well.
from officer.
Although it would seem like fp_text() should be able to override the boldness of a title template as well.
Really sorry, I don't understand. The following code works for me, I made the text red and bold:
library(magrittr)
library(officer)
style_txt <- fp_text(font.size = 16, bold = TRUE, color = "red",
font.family = "Calibri", vertical.align = 'baseline')
my_pres <- read_pptx() %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_empty(type = "body") %>%
ph_add_par() %>%
ph_add_text(str = "Title - text", type = "body", style = style_txt) %>%
add_slide(layout = "Title and Content", master = "Office Theme") %>%
ph_empty_at(left = 1, top = 2, width = 5, height = 4, template_type = "title") %>%
ph_add_par() %>%
ph_add_text(str = "Title - text", type = "title", style = style_txt)
print(my_pres, target = "test.pptx")
Don't you get the same result?
test.pptx
from officer.
I saw this chain is old, but I'm still having the same issue. Here is the code that should reproduce the issue. Use any template that uses bold face font in the title placeholder. When I add a new text placeholder, all of the other control works except for "bold=False".
my_pres <- read_pptx("test_template.pptx")
mytmp <- layout_summary(my_pres)[[2]][1]
style_txt <- fp_text(font.size = 16, bold = FALSE, color = "red",
font.family = "Calibri")
my_pres <- my_pres %>%
add_slide(layout = "Title and Content", master = mytmp) %>%
ph_with("Bold as expected", location=ph_location_type("title")) %>%
ph_empty(location = ph_location(left = 1, top = 2, width = 5, height = 2, label = "new")) %>%
ph_add_par(ph_label = "new") %>%
ph_add_text(str = "shouldn't be bold", ph_label = "new", style = style_txt)
print(my_pres, target = "test.pptx")
Is there anything wrong with the code? Thanks.
from officer.
I don't think I ever got that bold function to disable properly...
from officer.
I think it is solved now:
library(officer)
library(magrittr)
my_pres <- read_pptx()
style_bold <- fp_text(font.size = 16, bold = TRUE, color = "red",
font.family = "Calibri")
style_notbold <- fp_text(font.size = 16, bold = FALSE, color = "red",
font.family = "Calibri")
my_pres <- my_pres %>%
add_slide(layout = "Title and Content") %>%
ph_with(empty_content(), location = ph_location(left = 1, top = 2, width = 5, height = 2, newlabel = "new") ) %>%
ph_add_par(ph_label = "new") %>%
ph_add_text(str = "should be bold", ph_label = "new", style = style_bold) %>%
ph_add_par(ph_label = "new") %>%
ph_add_text(str = "shouldn't be bold", ph_label = "new", style = style_notbold)
print(my_pres, target = "test.pptx")
from officer.
Hi, I came across the same issue (working with officer 0.3.8). Your example above is working perfectly, but if I use my own template (attached), both text are bold and I can't figure out how to input no bold text without creating predefined placeholder in the template.
I figured out that this behaviour is emerging when the titles in presentation template are set to bold (same issue as JW900 was reporting earlier in this thread)
`my_pres <- read_pptx("PATH_TO_MY_TEMPLATE_PPTX")
layout_summary(my_pres)
style_bold <- fp_text(font.size = 16, bold = TRUE, color = "red",
font.family = "Calibri")
style_notbold <- fp_text(font.size = 16, bold = FALSE, color = "red",
font.family = "Calibri")
my_pres <- my_pres %>%
add_slide(layout = "title and graph", master = "My template") %>%
ph_with(empty_content(), location = ph_location(left = 1, top = 2, width = 5, height = 2, newlabel = "new") ) %>%
ph_add_par(ph_label = "new") %>%
ph_add_text(str = "should be bold", ph_label = "new", style = style_bold) %>%
ph_add_par(ph_label = "new") %>%
ph_add_text(str = "shouldn't be bold", ph_label = "new", style = style_notbold)
print(my_pres, target = "test.pptx")`
from officer.
I have the same issue as @matyas-k. If the title in the layout is set to bold, the bold setting for any text paragraphs could not be overwritten, all texts are bold.
I have investigated the issue a bit. Looks like bold = FALSE
option doesn't have any effect on a:rPr
node of the paragraph and the bold setting is inherited from the a:defRPr
node from the layout. For example:
(slide)
<p:txBody>
<a:bodyPr/>
<a:lstStyle/>
<a:p>
<a:pPr algn="l" marL="0" marR="0">
<a:spcBef>
<a:spcPts val="0"/>
</a:spcBef>
<a:spcAft>
<a:spcPts val="0"/>
</a:spcAft>
<a:buNone/>
</a:pPr>
<a:r>
<a:rPr cap="none" sz="1000">
<a:solidFill>
<a:srgbClr val="070707">
<a:alpha val="100000"/>
</a:srgbClr>
</a:solidFill>
<a:latin typeface="Calibri"/>
<a:cs typeface="Calibri"/>
</a:rPr>
<a:t>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</a:t>
</a:r>
</a:p>
</p:txBody>
(layout)
<p:txBody>
<a:bodyPr wrap="square" anchor="t">
<a:spAutoFit/>
</a:bodyPr>
<a:lstStyle>
<a:lvl1pPr>
<a:lnSpc>
<a:spcPct val="80000"/>
</a:lnSpc>
<a:defRPr sz="2400" b="1">
<a:solidFill>
<a:schemeClr val="accent6"/>
</a:solidFill>
</a:defRPr>
</a:lvl1pPr>
</a:lstStyle>
<a:p>
<a:r>
<a:rPr dirty="0"/>
<a:t>Title</a:t>
</a:r>
</a:p>
</p:txBody>
The result is b="1"
is inherited from the layout. The strange thing is this property is always inherited from the title (the first text chunk in the layout?) and not following text paragraphs, but I'm not good in OOXML so let it be.
But when bold = TRUE
the b="1"
attribute is added to the a:rPr
node and all is fine. May be it is possible to force set b="0"
when bold = FALSE
?
(slide)
<p:txBody> ... <a:r> <a:rPr cap="none" sz="1000" b="1"> ... </a:rPr> <a:t>Lorem ipsum ...</a:t> </a:r> </a:p> </p:txBody>
from officer.
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.
from officer.
Related Issues (20)
- body_add_docx() doesn't work if file path for src contains & HOT 2
- `fp_text_lite()` doesn't work with `shading.color` HOT 1
- `cursor_bookmark` is no longer working as expected for inserting text in tables HOT 10
- PPTX get_shape_id identifying wrong ID HOT 3
- docx_comments bugs HOT 2
- Have body_replace_img_at_bkm use image size in document, not from external_img HOT 3
- Quarto rendering problem due to check of `tbl-cap` as cell option HOT 3
- Style = "centered" not supported anymore, was it removed? HOT 3
- Trying to follow solution from #484 but get Error: $ operator is invalid for atomic vectors
- Saving files fails if officer is installed read-only HOT 5
- Installation fails: Error in parse(outFile) : {INSTALL_DIR}/officer/R/docx_comments.R:52:44: unexpected input
- Read_docx does not respect embedded fonts HOT 3
- Saving pptx files fails if officer is installed read-only HOT 5
- `ph_with.gg` does not add an `alt_text=` to pptx HOT 1
- body_add_docx workaround for fast generation of large documents doesn't work anymore HOT 2
- It is hoped that `block_pour_docx()` can work in bookdown::word_document2 HOT 4
- how to add hyperlink for embedded image in PPT. HOT 1
- remove_slide doesn't remove images from ppt/media HOT 4
- Add comment to an existing paragraph HOT 3
- Add fixed = TRUE argument to cursor_reach HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from officer.