Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

External docx file target path #588

Open
CRAB-Stat opened this issue Jun 28, 2024 · 0 comments
Open

External docx file target path #588

CRAB-Stat opened this issue Jun 28, 2024 · 0 comments

Comments

@CRAB-Stat
Copy link

CRAB-Stat commented Jun 28, 2024

Thanks for all of your work on this package, it's so great!

I've been using officer package to generate docx files and, during regression testing, I compare different versions of the docx files using a separate comparison app. I noticed that when there is a document that contains external docx files, the comparison app throws an error related to incorrect URI paths. I don't get that error if I open the document directly with Word.

I think the issue is with the process_docx_poured function's media_rel_dir parameter. I believe that it should be media_rel_dir = "." instead of media_rel_dir = "./" in order to set the correct value for the target in the word/_rels/document.xml.rels file that gets made when the docx file is saved. Currently the target starts with ".//", but I believe it should be "./" instead.

I've provided a reproducible example for the officer side of things but let me know if you need any additional information about the error that comes from the comparison tool. And I'd be happy to submit a pull request if you'd like.

sessionInfo()

R version 4.4.1 (2024-06-14 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Los_Angeles
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] magrittr_2.0.3 officer_0.6.6 

loaded via a namespace (and not attached):
 [1] compiler_4.4.1    R6_2.5.1          cli_3.6.3         ragg_1.3.2        tools_4.4.1       uuid_1.2-0        xml2_1.3.6        zip_2.3.1        
 [9] textshaping_0.4.0 lifecycle_1.0.4   rlang_1.1.4       systemfonts_1.1.0 openssl_2.2.0     askpass_1.2.0    
library(officer)
library(magrittr)

doc_1 <- read_docx() %>% body_add_par("First Document")
print(doc_1, target = "H:\\doc_1.docx")
doc_2 = read_docx() %>% body_add_par("Second Document") %>% body_add_docx("H:\\doc_1.docx")
print(doc_2, target = "H:\\doc_2.docx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant