ironpress 1.5.3 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +60 -29
- data/ext/ironpress/Cargo.toml +2 -2
- data/ext/ironpress/src/lib.rs +10 -0
- data/lib/ironpress/version.rb +1 -1
- data/lib/ironpress.rb +2 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: de16d91489579bd1a6504fba837207713dc4d3c14bec2296fe833e8a2774af12
|
|
4
|
+
data.tar.gz: 72442b9c4915bcd663ab4f40adbed9dbccb037d70e93d95fb91bb11242b37d5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0d4b9d5cc663f7ea20912d4b76f6ad0f301b61415b9309de8e2632f7d63857297fadd6ebbc76f0e58e489c97b48233d9d7f11cc81db89f4e068ce7b9a311c7bc
|
|
7
|
+
data.tar.gz: 896be52ca3c08cf024ae4d31b8ffdbfb2e9a59f94b84b00769cd699a5e9e4ec1c9d0deb5a500437167fa87dfd9137b2aa95b47064968d93e11ba9bc81fa9e81f
|
data/README.md
CHANGED
|
@@ -1,58 +1,89 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ironpress for Ruby
|
|
2
2
|
|
|
3
|
-
Generate PDF
|
|
3
|
+
Generate PDF output from HTML or Markdown with a native Rust renderer. No
|
|
4
|
+
browser process or system PDF dependency is required.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
[Read the complete Ruby getting-started guide](https://gastongouron.github.io/ironpress/get-started/ruby/).
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
## Requirements
|
|
9
|
+
|
|
10
|
+
- Ruby 3.0 or later
|
|
11
|
+
- Linux, macOS, or Windows
|
|
12
|
+
|
|
13
|
+
Releases include supported native gems plus a source gem.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bundle add ironpress
|
|
9
19
|
```
|
|
10
20
|
|
|
11
|
-
|
|
12
|
-
gems for Linux, macOS, and Windows.
|
|
21
|
+
Or install the gem globally:
|
|
13
22
|
|
|
14
|
-
|
|
23
|
+
```bash
|
|
24
|
+
gem install ironpress
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Create your first PDF
|
|
15
28
|
|
|
16
29
|
```ruby
|
|
17
30
|
require "ironpress"
|
|
18
31
|
|
|
19
|
-
pdf = Ironpress.html_to_pdf("<h1>Hello</h1>")
|
|
32
|
+
pdf = Ironpress.html_to_pdf("<h1>Hello from Ruby</h1>")
|
|
20
33
|
File.binwrite("output.pdf", pdf)
|
|
21
34
|
```
|
|
22
35
|
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
The result is a binary Ruby `String`. Write it with `File.binwrite`, return it
|
|
37
|
+
from a web response, or store it in your application.
|
|
38
|
+
|
|
39
|
+
## Render Markdown
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
pdf = Ironpress.markdown_to_pdf("# Release notes\n\nEverything shipped.")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Configure and reuse a converter
|
|
25
46
|
|
|
26
47
|
```ruby
|
|
27
48
|
converter = Ironpress::HtmlConverter.new
|
|
28
49
|
.page_size("Letter")
|
|
29
|
-
.margin_sides(36,
|
|
50
|
+
.margin_sides(36, 48, 36, 48)
|
|
30
51
|
.header("Quarterly report")
|
|
31
52
|
.footer("Page {page} of {pages}")
|
|
32
|
-
|
|
53
|
+
|
|
54
|
+
# Use header_html/footer_html for sanitized images, tables, and styled markup.
|
|
55
|
+
converter.header_html("<strong>Quarterly report</strong>")
|
|
33
56
|
|
|
34
57
|
pdf = converter.convert("<h1>Results</h1>")
|
|
58
|
+
markdown_pdf = converter.convert_markdown("# Results")
|
|
35
59
|
```
|
|
36
60
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Ruby also supports constrained local resources through `base_path` and
|
|
40
|
-
`resource_root`, plus direct file output.
|
|
41
|
-
|
|
42
|
-
See the [binding capability matrix](../README.md) for the contract shared with
|
|
43
|
-
Rust, Python, and WebAssembly.
|
|
61
|
+
Configuration methods return the converter, so policies compose in an idiomatic
|
|
62
|
+
chain. Use `convert_to_file` or `convert_markdown_to_file` for direct output.
|
|
44
63
|
|
|
45
|
-
##
|
|
64
|
+
## Local resources and fonts
|
|
46
65
|
|
|
47
|
-
|
|
48
|
-
your application needs, verify it as part of deployment, then install its bytes:
|
|
66
|
+
Local URLs are denied until a canonical boundary is configured:
|
|
49
67
|
|
|
50
68
|
```ruby
|
|
51
|
-
converter = Ironpress::HtmlConverter.new
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
pdf = converter.convert("<p lang='ja'>日本語</p>")
|
|
69
|
+
converter = Ironpress::HtmlConverter.new
|
|
70
|
+
.base_path("templates")
|
|
71
|
+
.resource_root(".")
|
|
72
|
+
.add_font("Inter", File.binread("assets/Inter.ttf"))
|
|
56
73
|
```
|
|
57
74
|
|
|
58
|
-
|
|
75
|
+
Optional fallback packs enter through `add_font_pack`. Valid names are
|
|
76
|
+
`cjk-jp`, `cjk-kr`, `cjk-sc`, `cjk-tc`, and `emoji`. Rendering never downloads
|
|
77
|
+
a font pack.
|
|
78
|
+
|
|
79
|
+
## Limits and errors
|
|
80
|
+
|
|
81
|
+
- Invalid named settings raise `ArgumentError`.
|
|
82
|
+
- Conversion failures raise `RuntimeError`.
|
|
83
|
+
- HTML sanitization is enabled by default.
|
|
84
|
+
- The binding has no async or streaming conversion API.
|
|
85
|
+
- Remote HTTP document resources are not available.
|
|
86
|
+
- JavaScript and browser DOM execution are not supported.
|
|
87
|
+
|
|
88
|
+
See the [binding capability matrix](../README.md) for the contract shared with
|
|
89
|
+
Rust, Python, browser WebAssembly, and Node.js.
|
data/ext/ironpress/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "ironpress-ruby"
|
|
3
|
-
version = "1.
|
|
3
|
+
version = "1.6.0"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
publish = false
|
|
6
6
|
description = "Ruby bindings for the Ironpress HTML-to-PDF engine"
|
|
@@ -12,6 +12,6 @@ name = "ironpress_ruby"
|
|
|
12
12
|
crate-type = ["cdylib"]
|
|
13
13
|
|
|
14
14
|
[dependencies]
|
|
15
|
-
ironpress-core = { version = "=1.
|
|
15
|
+
ironpress-core = { version = "=1.6.0", package = "ironpress" }
|
|
16
16
|
magnus = "0.7"
|
|
17
17
|
rb-sys = { version = "0.9", default-features = false, features = ["stable-api-compiled-fallback"] }
|
data/ext/ironpress/src/lib.rs
CHANGED
|
@@ -138,10 +138,18 @@ impl NativeConverter {
|
|
|
138
138
|
self.configured(|converter| converter.header(text))
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
fn header_html(&self, html: String) -> Self {
|
|
142
|
+
self.configured(|converter| converter.header_html(html))
|
|
143
|
+
}
|
|
144
|
+
|
|
141
145
|
fn footer(&self, text: String) -> Self {
|
|
142
146
|
self.configured(|converter| converter.footer(text))
|
|
143
147
|
}
|
|
144
148
|
|
|
149
|
+
fn footer_html(&self, html: String) -> Self {
|
|
150
|
+
self.configured(|converter| converter.footer_html(html))
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
fn convert(ruby: &Ruby, this: &Self, html: String) -> Result<RString, Error> {
|
|
146
154
|
let pdf = this
|
|
147
155
|
.converter
|
|
@@ -220,7 +228,9 @@ fn init(_ruby: &Ruby) -> Result<(), Error> {
|
|
|
220
228
|
class.define_method("base_path", method!(NativeConverter::base_path, 1))?;
|
|
221
229
|
class.define_method("resource_root", method!(NativeConverter::resource_root, 1))?;
|
|
222
230
|
class.define_method("header", method!(NativeConverter::header, 1))?;
|
|
231
|
+
class.define_method("header_html", method!(NativeConverter::header_html, 1))?;
|
|
223
232
|
class.define_method("footer", method!(NativeConverter::footer, 1))?;
|
|
233
|
+
class.define_method("footer_html", method!(NativeConverter::footer_html, 1))?;
|
|
224
234
|
class.define_method("convert", method!(NativeConverter::convert, 1))?;
|
|
225
235
|
class.define_method(
|
|
226
236
|
"convert_markdown",
|
data/lib/ironpress/version.rb
CHANGED
data/lib/ironpress.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ironpress
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paul Gaston Gouron
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-08-
|
|
11
|
+
date: 2026-08-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rb_sys
|
|
@@ -42,7 +42,9 @@ files:
|
|
|
42
42
|
homepage: https://github.com/gastongouron/ironpress
|
|
43
43
|
licenses:
|
|
44
44
|
- MIT
|
|
45
|
-
metadata:
|
|
45
|
+
metadata:
|
|
46
|
+
documentation_uri: https://gastongouron.github.io/ironpress/get-started/ruby/
|
|
47
|
+
source_code_uri: https://github.com/gastongouron/ironpress
|
|
46
48
|
post_install_message:
|
|
47
49
|
rdoc_options: []
|
|
48
50
|
require_paths:
|