Skip to content

General Issue: Investigate the topic of metadata for pdf in R #15

Open

Description

@Polkas

Background Information

We want to investigate whether we can, with low cost and minimal dependencies, provide metadata support for our PDFs. All cells are saved as pdf metadata.

A hack with a title as a JSON

library(jsonlite)

# 1. Create a list of your custom metadata
my_metadata <- list(
    title = "Alpha",
    header1 = 42,
    status = "Draft",
    tags = c("R", "Plot", "JSON")
)

# 2. Convert to a JSON string - we should use base R for that - we control what we convert
json_string <- toJSON(my_metadata, auto_unbox = TRUE)

# 3. Pass the JSON string to the title argument
pdf("json_metadata_plot.png", title = json_string)
plot(1:10, main = "Data Visualization")
dev.off()

Using a system library
https://stackoverflow.com/a/24254259/5442527

Definition of Done

No response

Activity

  1. jimrothstein commented on Feb 28, 2026

    @jimrothstein

    @Polkas
    Have not worked with ExifTool. Done other things in pharmaverse; this seems interesting and would like to try.
    jim

  2. Polkas commented on Feb 28, 2026

    @Polkas
    CollaboratorAuthor

    Hey @jimrothstein, it is fantastic that you want to contribute.

    This is a really interesting task, and we have at least a few options for how to approach it:

    Vignette Example: Check if we can add an example to a vignette demonstrating how to integrate this into a workflow (e.g., using the xmpdf R package).

    Internal Solution: Consider building a lightweight, internal solution directly within gridify.

    Advanced: We could also consider reporting it to the CRAN community, the lack of this specific grDevices::pdf capability and even try to contribute to base R itself. Since the R pdf() device already adds metadata like the title and author, I assume there is existing code we could easily extend.

    Please assign yourself to the issue once you have decided to move forward with the contribution.

  3. jimrothstein commented on Feb 28, 2026

    @jimrothstein

    @Polkas
    Hi - Let me aim for simple, first. I don't have write access and so will fork.

    Working through gridify and exiftool ... all installed.

  4. jimrothstein commented on Mar 5, 2026

    @jimrothstein

    @Polkas
    Still playing ... time to study packages you have already referenced.

    gridify_mtcars.pdf

  5. Polkas commented on Mar 5, 2026

    @Polkas
    CollaboratorAuthor

    Thank you for working on that.
    No pressure, even trying to help is a fantastic contribution.
    FYI. We can catch up to discuss it or I can propose another interesting issue in future.

    BTW. The first empty page is a known issue.
    As I remeber you need to use pdf(..., onefile = TRUE) and/or print() for image.

  6. jimrothstein commented on Mar 30, 2026

    @jimrothstein

    @Polkas
    Got sidetracked, but did read a bit re: grid/grobs ( nice intro: https://bookdown.org/rdpeng/RProgDA/the-grid-package.html) and poked about some of other tools.

    About to work through ( r-xmpdf https://github.com/trevorld/r-xmpdf?tab=readme-ov-file#overview)
    I am learning, but don't have clear picture, yet, of vignette idea you mentioned. Should I go all the way back to Adobe's XMP (https://opensource.adobe.com/dc-acrobat-sdk-docs/library/pdfmark/pdfmark_Syntax.html) ??

    Suggestion: I'll try to rough sketch what vignette might include. (in 1 week). Then you add/subtract to it?

    Thx

    Vignette Example: Check if we can add an example to a vignette demonstrating how to integrate this into a workflow (e.g., using the xmpdf R package).
    
    Internal Solution: Consider building a lightweight, internal solution directly within gridify.
    
  7. Polkas commented on May 21, 2026

    @Polkas
    CollaboratorAuthor

    we have an active PR for it now. We decided to apply sidecar file solution. Feel free to comment on it:) By default no metadata is saved.
    #19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions