Giter VIP home page Giter VIP logo

Comments (6)

fb-elong avatar fb-elong commented on August 15, 2024 1

The issue is about this line

https://github.com/Merck/r2rtf/blob/master/R/assemble.R#L64

that needs to be updated as below to avoid duplicate font claim in RTF. Will create a PR to fix the issue.

start <- c(1, vapply(rtf[-1], function(x) max(grep("fcharset",rtf[[1]])) + 2, numeric(1)))

from r2rtf.

nanxstats avatar nanxstats commented on August 15, 2024 1

Fixed by #129

from r2rtf.

elong0527 avatar elong0527 commented on August 15, 2024

could you attach a few tables that can reproduce the issue?

Please also try the new function in r2rtf, we will need to update r4csr on this topic. Thanks!

https://merck.github.io/r2rtf/reference/assemble_docx.html

https://merck.github.io/r2rtf/reference/assemble_rtf.html

from r2rtf.

dylanjohnlukes avatar dylanjohnlukes commented on August 15, 2024

sure here is a dummy example:
(1) example_1.rtf has correct formatting (i.e., Arial font both body, header, footer text)
(2) example_2.rtf has correct formatting (i.e., Arial font both body, header, footer text)
(3) example_combined.rtf (use assemble_rtf() to combine example1.rtf and example2.rtf) no longer has correct formatting

Interestingly, the body text is correct (i.e., Arial font) on the first page but reverts to Courier New on the second page. All header and footer font text immediately revert to Courier New.

"example_1"
example_1

"example_2"
example_2

"example_combined"
example_combined

from r2rtf.

fb-elong avatar fb-elong commented on August 15, 2024

The code below works as expected.

Table body are both in Courier font from my end.

Could you try the code and see if it works?

For me to find the root cause, please share code that can fully reproduce the issue from your end.

library(r2rtf)
library(magrittr)

file <- replicate(2, tempfile(fileext = ".rtf"))
file1 <- head(iris) %>% rtf_body(text_font = 6) %>% rtf_encode() %>% write_rtf(file[1])
file2 <- head(cars) %>% rtf_page(orientation = "landscape") %>%
              rtf_body(text_font = 6) %>% rtf_encode() %>% write_rtf(file[2])
output <- tempfile(fileext = ".rtf")

assemble_rtf(
  input = file,
  output = "tmp.rtf"
)

from r2rtf.

dylanjohnlukes avatar dylanjohnlukes commented on August 15, 2024

No problem. See code below. You need to change the "text_font" to something other than Courier (e.g., text_font = 3 below). Courier appears to be the default font the program is reverting to when RTF tables are combined.

library(r2rtf) # Reporting in RTF format
library(magrittr) # Required for %>%

file <- replicate(2, tempfile(fileext = ".rtf"))

file1 <- head(iris) %>%
rtf_page_header(
text = c("Testing Testing Testing"),
text_font = 3,
text_font_size = 10
) %>%
rtf_page_footer(
text = c("Testing Testing Testing"),
text_font = 3,
text_font_size = 10
) %>%
rtf_body(
text_font = 3,
text_font_size = 10
) %>%
rtf_encode() %>%
write_rtf(file[1])

file2 <- head(cars) %>%
rtf_page(orientation = "landscape") %>%
rtf_page_header(
text = c("Testing Testing Testing"),
text_font = 3,
text_font_size = 10
) %>%
rtf_page_footer(
text = c("Testing Testing Testing"),
text_font = 3,
text_font_size = 10
) %>%
rtf_body(
text_font = 3,
text_font_size = 10
) %>%
rtf_encode() %>%
write_rtf(file[2])

output <- tempfile(fileext = ".rtf")

assemble_rtf(
input = file,
output = "tmp.rtf"
)

from r2rtf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.