Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (13.5%) to scientific vocabulary
Keywords
pdf
pkg
r
Last synced: 6 months ago
·
JSON representation
Repository
Minimal pure-R PDF document creator
Basic Info
Statistics
- Stars: 44
- Watchers: 4
- Forks: 4
- Open Issues: 1
- Releases: 0
Topics
pdf
pkg
r
Created over 6 years ago
· Last pushed 6 months ago
Metadata Files
Readme
Changelog
License
README.Rmd
---
output: github_document
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = FALSE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "75%"
)
suppressPackageStartupMessages({
library(dplyr)
library(minipdf)
})
if (FALSE) {
# Check for functions which do not have an @examples block for roxygen
system("grep -c examples man/*Rd", intern = TRUE) |>
grep(":0$", x = _, value = TRUE)
}
```
```{r echo = FALSE, eval = FALSE}
# Quick logo generation. Borrowed heavily from Nick Tierney's Syn logo process
library(magick)
library(showtext)
font_add_google("Abril Fatface", "gf")
# pkgdown::build_site(override = list(destination = "../coolbutuseless.github.io/package/minipdf"))
```
```{r echo = FALSE, eval = FALSE}
img <- image_read("man/figures/mini-cooper-s.gif") %>%
image_transparent(color = "#f9fafb", fuzz = 10) %>%
image_trim() %>%
image_threshold()
hexSticker::sticker(subplot = img,
s_x = 0.92,
s_y = 1.2,
s_width = 1.5,
s_height = 0.95,
package = "pdf",
p_x = 1,
p_y = 0.5,
p_color = "#223344",
p_family = "gf",
p_size = 11,
h_size = 1.2,
h_fill = "#ffffff",
h_color = "#223344",
filename = "man/figures/logo.png")
image_read("man/figures/logo.png")
```
# minipdf


[](https://github.com/coolbutuseless/minipdf/actions/workflows/R-CMD-check.yaml)
`minipdf` is a package for creating simple PDF documents.
### What's in the box
* `create_pdf()` to create an empty PDF document
* `write_pdf()` to write a PDF to file or string
* `pdf_line()`, `pdf_rect()`, `pdf_circle()`, `pdf_polygon()`, `pdf_polyline()`,
`pdf_text()`, `pdf_bezier()`, `pdf_image()` - functions for adding graphical elements to
the PDF
* `pdf_clip_polygon()`, `pdf_clip_rect()` define global clipping regions
* `clip_polygon()`, `clip_rect()` define per-element clipping regions
* `pdf_rotate()`, `pdf_translate()`, `pdf_scale()` define global transformations
* `tf_rotate()`, `tf_translate()`, `tf_scale()` define per-element transformations
* `pgpar()` define PDF graphical parameters
* `pdf_newpage()` begin a new page in the PDF
## Installation
You can install the development version from [GitHub](https://github.com/coolbutuseless/minipdf) with:
``` r
# install.packages("devtools")
devtools::install_github("coolbutuseless/minipdf")
```
# Hello World!
```{r}
doc <- create_pdf(width = 400, height = 250) |>
pdf_circle(80, 100, 50, fill = 'lightblue', col = 'black') |>
pdf_rect(150, 50, 100, 100, fill = 'yellow', col = 'red', lty = 2) |>
pdf_polygon(c(270, 390, 330), c(50, 50, 150)) |>
pdf_text("Hello World!", x = 30, y = 170, fontsize = 50)
```
```{r}
write_pdf(doc, "man/figures/helloworld.pdf")
```
```{r echo=FALSE}
system("magick -density 300 man/figures/helloworld.pdf -resize 50% man/figures/helloworld.png")
knitr::include_graphics("man/figures/helloworld.png")
```
In `write_pdf()` if the output filename is not specified, then the function returns
the PDF document as a string
```{r comment = ""}
write_pdf(doc) |> cat()
```
## Simple example with vectorised arguments
Most coordinate arguments can be vectors - this means multiple objects
can be generated with a single call.
Note that all objects created in this way share a single graphics state i.e.
they'll all be the same color etc.
```{r}
im <- png::readPNG(system.file("img", "Rlogo.png", package="png")) * 255
doc <- create_pdf(width = 400, height = 200) |>
pdf_circle(
x = seq(0, 400, length.out = 9),
y = 100,
r = 2 * (1:9),
col = 'black', lwd = 1, fill = 'lightblue'
) |>
pdf_line(
x1 = seq(0, 400, length.out = 9),
y1 = 100,
x2 = seq(400, 0, length.out = 9),
y2 = 200,
lty = 3, col = 'blue'
) |>
pdf_text(
"#RStats",
x = 0,
y = seq(0, 200, length.out = 10),
fill = 'grey80',
fontfamily = 'mono',
fontsize = seq(12, 30, length.out = 10)
) |>
pdf_image(im = im, x = 300, y = 10, scale = 0.75)
```
```{r}
write_pdf(doc, "man/figures/simple.pdf")
```
```{r echo=FALSE}
system("magick -density 300 man/figures/simple.pdf -resize 50% man/figures/simple.png")
knitr::include_graphics("man/figures/simple.png")
```
## Multiple objects with differing graphics state
```{r echo=FALSE}
set.seed(1)
```
```{r}
doc <- create_pdf(height = 400, width = 600)
N <- 400
xs <- sample(600, N, TRUE)
ys <- sample(400, N, TRUE)
rs <- sample(100, N, TRUE)
cs <- sample(colors(), N, TRUE)
for (i in seq_len(N)) {
doc <- pdf_circle(doc, xs[i], ys[i], rs[i], col = NA, fill = cs[i], alpha = 0.2)
}
doc <- pdf_translate(doc, 50, 0)
doc <- pdf_text(doc, "#RStats", 10, 150, fontsize = 120, mode = 1, col = 'black',
fontface = 'bold.italic', lwd = 5)
```
```{r}
write_pdf(doc, "man/figures/example1.pdf")
```
```{r echo=FALSE}
system("magick -density 300 man/figures/example1.pdf -resize 25% man/figures/example1.png")
knitr::include_graphics("man/figures/example1.png")
```
## Beziers
```{r}
N <- 100
doc <- create_pdf() |>
pdf_bezier(
x0 = seq(0, 400, length.out = N),
y0 = 10,
x1 = 25,
y1 = seq(20, 300, length.out = N),
x2 = seq(100, 80, length.out = N),
y2 = 250,
x3 = 400,
y3 = seq(400, 300, length.out = N),
alpha = 0.2
)
```
```{r eval=interactive()}
write_pdf(doc, "man/figures/beziers.pdf")
```
```{r echo=FALSE, eval=interactive()}
system("magick -density 300 man/figures/beziers.pdf -resize 25% -depth 8 man/figures/beziers.png")
```
```{r echo=FALSE}
knitr::include_graphics("man/figures/beziers.png")
```
Owner
- Name: mikefc
- Login: coolbutuseless
- Kind: user
- Location: Australia
- Website: coolbutuseless.github.io
- Repositories: 23
- Profile: https://github.com/coolbutuseless
Cool, but useless.
GitHub Events
Total
- Watch event: 2
- Delete event: 1
- Push event: 61
- Create event: 2
Last Year
- Watch event: 2
- Delete event: 1
- Push event: 61
- Create event: 2
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 1
- Total pull requests: 0
- Average time to close issues: about 1 month
- Average time to close pull requests: N/A
- Total issue authors: 1
- Total pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 1
- Pull requests: 0
- Average time to close issues: about 1 month
- Average time to close pull requests: N/A
- Issue authors: 1
- Pull request authors: 0
- Average comments per issue: 0.0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- coolbutuseless (1)
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- cran 6 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 1
- Total maintainers: 1
cran.r-project.org: minipdf
PDF Document Creator
- Homepage: https://github.com/coolbutuseless/minipdf
- Documentation: http://cran.r-project.org/web/packages/minipdf/minipdf.pdf
- License: MIT + file LICENSE
-
Latest release: 0.2.7
published 6 months ago
Rankings
Stargazers count: 7.4%
Forks count: 12.2%
Dependent packages count: 25.6%
Dependent repos count: 31.4%
Average: 32.4%
Downloads: 85.3%
Maintainers (1)
Last synced:
6 months ago
Dependencies
.github/workflows/R-CMD-check.yaml
actions
- actions/cache v2 composite
- actions/checkout v2 composite
- actions/upload-artifact main composite
- r-lib/actions/setup-pandoc v1 composite
- r-lib/actions/setup-r v1 composite
DESCRIPTION
cran
- R6 * imports
- knitr * suggests
- rmarkdown * suggests
- viridisLite * suggests
.github/workflows/rhub.yaml
actions
- r-hub/actions/checkout v1 composite
- r-hub/actions/platform-info v1 composite
- r-hub/actions/run-check v1 composite
- r-hub/actions/setup v1 composite
- r-hub/actions/setup-deps v1 composite
- r-hub/actions/setup-r v1 composite
.devcontainer/Dockerfile
docker
- ghcr.io/rocker-org/devcontainer/tidyverse ${VARIANT} build
.devcontainer/requirements.txt
pypi
- ydiff * development