davidgohel / officer

:cop: officer: office documents from R
https://ardata-fr.github.io/officeverse/
Other
593 stars 107 forks source link

Simple external_img() pptx creation works but powerpoint reports 'problem with content' #613

Open schalkwyk opened 8 hours ago

schalkwyk commented 8 hours ago

I'm making a pptx version of beamer slides, where I have sliced up the beamer pdf with gs. The code below works and would of course be easy to loop over all slides. Powerpoint says "PowerPoint found a problem with content in pr.pptx. PowerPoint can attempt to repair the presentation.

If you trust the source of this presentation, click Repair."

and then displays the slides correctly.

(Microsoft Powerpoint for Mac v 16.83)

pr <- read_pptx() pr <- add_slide(pr, layout = "Blank", master = "Office Theme") pr <- ph_with(x=pr, external_img('leo_shared/talks/Leo/2024/miRNA/slides/slide1.pdf'),

  • location = ph_location_fullsize() ) pr <- add_slide(pr, layout = "Blank", master = "Office Theme") pr <- ph_with(x=pr, external_img('leo_shared/talks/Leo/2024/miRNA/slides/slide2.pdf'),
  • location = ph_location_fullsize() ) pr <- add_slide(pr, layout = "Blank", master = "Office Theme") pr <- ph_with(x=pr, external_img('leo_shared/talks/Leo/2024/miRNA/slides/slide3.pdf'),
  • location = ph_location_fullsize() ) print(pr, target='pr.pptx')

sessionInfo() R version 4.4.0 (2024-04-24) Platform: aarch64-apple-darwin21.6.0 Running under: macOS Monterey 12.1

Matrix products: default BLAS: /opt/homebrew/Cellar/openblas/0.3.27/lib/libopenblasp-r0.3.27.dylib LAPACK: /opt/homebrew/Cellar/r/4.4.0/lib/R/lib/libRlapack.dylib; LAPACK version 3.12.0

locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

time zone: Europe/London tzcode source: internal

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

other attached packages: [1] officer_0.6.6

loaded via a namespace (and not attached): [1] compiler_4.4.0 R6_2.5.1 cli_3.6.3 ragg_1.3.2 [5] tools_4.4.0 uuid_1.2-1 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 [13] openssl_2.2.0 askpass_1.2.0

markheckmann commented 7 hours ago

Can you please provide a fully reproducible example, i.e. including the PDF files?

schalkwyk commented 6 hours ago

Sorry, should have done that the first time! Please see files attached.

Leo

From: Mark Heckmann @.> Date: Monday, 30 September 2024 at 13:35 To: davidgohel/officer @.> Cc: Schalkwyk, Leonard @.>, Author @.> Subject: Re: [davidgohel/officer] Simple external_img() pptx creation works but powerpoint reports 'problem with content' (Issue #613)

CAUTION: This email originated from outside our organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. If you are not sure it is safe, please contact the IT Helpdesk.

Can you please provide a fully reproducible example, i.e. including the PDF files?

— Reply to this email directly, view it on GitHubhttps://github.com/davidgohel/officer/issues/613#issuecomment-2383065607, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFJVOHGV73TEVET7MF73BWDZZFAQVAVCNFSM6AAAAABPDDZQ6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBTGA3DKNRQG4. You are receiving this because you authored the thread.Message ID: @.***>

markheckmann commented 6 hours ago

I cannot find an attachment in the reply you sent via email. Could you please check directly on GitHub?

schalkwyk commented 6 hours ago

pr.txt pr.pptx slide3.pdf slide2.pdf slide1.pdf

markheckmann commented 5 hours ago

I don't think that officer can handle PDF files as image input. However, I cannot find any suffix checks that prevent this. I guess, the easiest fix would be to convert the PDFs to JPEG or PNG before adding them.

schalkwyk commented 4 hours ago

Thanks Mark:

I couldn’t find anything in the documents about what kind of files are supported and was pleasantly surprised to see that pdf files sort of work. The ‘repaired’ pptx file does seem to treat the pdf images as vector graphics, they seem to zoom and zoom. When I unzip the pptx file from officer I can find the unchanged pdfs inside, and in the version repaired by Powerpoint there are versions converted to emf.

To me It's a valuable (if accidental) feature of officer to be able to embed vector graphics in powerpoint files. I think it’s clear that the officer output is fairly correct but Powerpoint raises a warning because MS engineers are wary about processing arbitrary vector graphics.

Thanks for your help.

LEo

From: Mark Heckmann @.> Date: Monday, 30 September 2024 at 15:50 To: davidgohel/officer @.> Cc: Schalkwyk, Leonard @.>, Author @.> Subject: Re: [davidgohel/officer] Simple external_img() pptx creation works but powerpoint reports 'problem with content' (Issue #613)

CAUTION: This email originated from outside our organisation. Do not click links or open attachments unless you recognise the sender and know the content is safe. If you are not sure it is safe, please contact the IT Helpdesk.

I don't think that officer can handle PDF files as image input. However, I cannot find any suffix checks that prevent this. I guess, the easiest fix would be to convert the PDFs to JPEG or PNG before adding them.

— Reply to this email directly, view it on GitHubhttps://github.com/davidgohel/officer/issues/613#issuecomment-2383431172, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AFJVOHBWY3CRXMFFDFUISY3ZZFQLJAVCNFSM6AAAAABPDDZQ6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBTGQZTCMJXGI. You are receiving this because you authored the thread.Message ID: @.***>