1

Using R 4.0.2, Officer 0.3.14

I produce docx files with landscape orientation using the code below

library(officer)
library(magrittr)

landscape_one_column <- block_section(
  prop_section(
    page_size = page_size(orient = "landscape"), type = "continuous",
    page_margins = page_mar(
      bottom = 0,
      top = 1,
      right = 0,
      left = 1,
      header = 0,
      footer = 0,
      gutter = 0
    )
  )
)

  my_doc <- read_docx()

  #page 1
  my_doc <- my_doc %>% 
  body_add_fpar(fpar(ftext(paste('Some Text'),
        fp_text(font.family = 'Calibri', font.size = 14, bold = TRUE)), fp_p  = fp_par(text.align = "left"))) %>% 
    body_end_block_section(value = landscape_one_column) %>% 
    body_add_break()

  #page 2
  my_doc <- my_doc %>% 
    body_add_fpar(fpar(ftext(paste('Some Other Text'),
                             fp_text(font.family = 'Calibri', font.size = 14, bold = TRUE)), fp_p  = fp_par(text.align = "left")))%>% 
    body_end_block_section(value = landscape_one_column) 

print(my_doc, target = 'test.docx')

It works well except that ad the end of the 2 pages it automatically adds a 3rd page which is empty and not possible to remove both by code or in word.

How can this be solved?

Thank you

Arkadi w
  • 129
  • 22
  • Have you tried to remove the empty page from the template first? ```cursor_begin() %>% body_remove()``` – Sven Dec 01 '20 at 11:53
  • This is a package bug and there is no fix. I will close the issue. – Arkadi w Dec 01 '20 at 11:59
  • I had the same issue, always having an extra blank page, but starting with the body_remove before doing anything else did the trick for me. Just in case someone else needs this. :) – Sven Dec 01 '20 at 12:01

0 Answers0