page_print 0.1.7-x86_64-linux → 0.1.9-x86_64-linux

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50ee723070864487a535ed320e78b1484fdcbf6a68bf281be5625c2b56c8ad97
4
- data.tar.gz: 8eaf1c8ff260630fab6cee3e436b87bf500cf623f8edbe36f533a2ed490d3c14
3
+ metadata.gz: ad5333358befafb0066b49716228e8ae374d069253ef0e05a67dc0c21b86f2d6
4
+ data.tar.gz: dd8b0aef43b70ad871454c4fc69710310b2f5c8dd80489a7cbc0b43086030c20
5
5
  SHA512:
6
- metadata.gz: f1feb083d241f52ea404a3a56eb4b339346fa368699d8296cde6deec2d868376f5010a40042ad5e5fb95d820a4a288b40098e8e426abc896ec73a49bc95967c2
7
- data.tar.gz: 49d22a84caf0ca4c4e9d092958e3132feba2e82038ac299e83e1425ea997aa8634363f99efd7f40e4554f0b006b552e49f25bb6b0c27a24ec3e90fb55a52b3fc
6
+ metadata.gz: 6e5602e35a26a8394c07533d3195a8a4740f8ac1cd114a95d9b8b51eb5772656d8d7bc8b93de5dde61ebbade67796d53b7ffea7991ffd2690d27e417f77e29ef
7
+ data.tar.gz: 7a13cf451ac681277bf9193e26d9ac94f8b5d4b20be76239438c6cb076df8cb3d47791af37a0592a6200e2f04c440b4723df0f3681e2474b1ce97e52c7d3a783
data/README.md CHANGED
@@ -3,7 +3,6 @@
3
3
  > [!IMPORTANT]
4
4
  > PagePrint is not production-ready yet. The gem is still in active testing, especially around native packaging and platform compatibility.
5
5
 
6
-
7
6
  `page_print` renders HTML strings to PDF files from Ruby using the `plutobook` library through a native C extension.
8
7
 
9
8
  It exists as a faster, simpler alternative to PDFKit and other `wkhtmltopdf`-based gems. There is no external renderer process to shell out to, and the public Ruby API is intentionally small.
@@ -13,7 +12,7 @@ It exists as a faster, simpler alternative to PDFKit and other `wkhtmltopdf`-bas
13
12
  Add PagePrint to your Gemfile:
14
13
 
15
14
  ```ruby
16
- gem "page_print", "~> 0.1.4"
15
+ gem "page_print"
17
16
  ```
18
17
 
19
18
  Or install from RubyGems directly:
@@ -34,7 +33,7 @@ Render a PDF from a controller:
34
33
  class PrintsController < ApplicationController
35
34
  def pdf
36
35
  html = render_to_string(template: "prints/pdf", formats: [:html], layout: "pdf")
37
- pdf = PagePrint.html_to_pdf_string(
36
+ pdf = PagePrint.render(
38
37
  html,
39
38
  page_size: :a4,
40
39
  margins: :normal,
@@ -59,7 +58,7 @@ During controller actions, PagePrint defaults `base_url` to `request.base_url`.
59
58
  You can still override `base_url` explicitly:
60
59
 
61
60
  ```ruby
62
- pdf = PagePrint.html_to_pdf_string(html, base_url: "https://example.com")
61
+ pdf = PagePrint.render(html, base_url: "https://example.com")
63
62
  ```
64
63
 
65
64
  Override the fetcher only when needed:
@@ -88,19 +87,19 @@ HTML
88
87
 
89
88
  output_path = File.join(Dir.tmpdir, "page_print-output.pdf")
90
89
 
91
- PagePrint.html_to_pdf(html, output_path, base_url: "https://example.com")
90
+ PagePrint.render_to_file(html, output_path, base_url: "https://example.com")
92
91
  ```
93
92
 
94
93
  To get the generated PDF as a binary string instead of writing directly to a file:
95
94
 
96
95
  ```ruby
97
- pdf = PagePrint.html_to_pdf_string(html, base_url: "https://example.com")
96
+ pdf = PagePrint.render(html, base_url: "https://example.com")
98
97
  ```
99
98
 
100
99
  Use custom page dimensions and margins when a preset is not enough:
101
100
 
102
101
  ```ruby
103
- pdf = PagePrint.html_to_pdf_string(
102
+ pdf = PagePrint.render(
104
103
  html,
105
104
  page_size: { width: 100, height: 150, unit: :mm },
106
105
  margins: { top: 5, right: 6, bottom: 7, left: 8, unit: :mm }
@@ -145,7 +144,7 @@ RUNS=30 WARMUPS=3 bundle exec ruby benchmark/pdf_renderers.rb
145
144
  Measured on 2026-05-30 with Ruby 3.4.7 on Apple Silicon:
146
145
 
147
146
  | Renderer | Avg wall | P95 wall | Avg CPU | Avg peak RSS | Avg PDF |
148
- |---|---:|---:|---:|---:|---:|
147
+ | --- | ---: | ---: | ---: | ---: | ---: |
149
148
  | `page_print` | 78.2ms | 89.6ms | 93.4ms | 42.1MB | 33.0KB |
150
149
  | PDFKit | 782.2ms | 2127.1ms | 824.8ms | 59.4MB | 27.9KB |
151
150
 
@@ -161,7 +160,7 @@ For options and CSV output, see `benchmark/README.md`.
161
160
  Supported platforms:
162
161
 
163
162
  | Platform | Install Type |
164
- |---|---|
163
+ | --- | --- |
165
164
  | `x86_64-linux` | Vendored PlutoBook, local Ruby extension build |
166
165
  | `arm64-darwin` | Vendored PlutoBook, local Ruby extension build |
167
166
  | Other platforms | Source build |
@@ -182,7 +181,7 @@ Native gems bundle PlutoBook and required non-system shared libraries. Optional
182
181
 
183
182
  ## Notes
184
183
 
185
- - The extension supports writing to a file path with `html_to_pdf` or returning PDF bytes with `html_to_pdf_string`.
184
+ - The extension supports writing to a file path with `render_to_file` or returning PDF bytes with `render`.
186
185
  - JavaScript execution is intentionally unsupported.
187
186
  - Native gems disable PlutoBook's optional curl, TurboJPEG, and WebP features.
188
187
 
@@ -214,13 +213,13 @@ require "tmpdir"
214
213
 
215
214
  output_path = File.join(Dir.tmpdir, "page_print-output.pdf")
216
215
 
217
- PagePrint.html_to_pdf("<html><body><h1>Hello</h1></body></html>", output_path, page_size: :letter, margins: :narrow, media: :screen)
216
+ PagePrint.render_to_file("<html><body><h1>Hello</h1></body></html>", output_path, page_size: :letter, margins: :narrow, media: :screen)
218
217
  ```
219
218
 
220
219
  You can also do a quick one-shot smoke test from the shell:
221
220
 
222
221
  ```sh
223
- bundle exec ruby -Ilib -e 'require "tmpdir"; require "page_print"; output_path = File.join(Dir.tmpdir, "page_print-output.pdf"); p PagePrint.html_to_pdf("<html><body><h1>Hello</h1></body></html>", output_path, page_size: :letter, margins: :narrow, media: :screen)'
222
+ bundle exec ruby -Ilib -e 'require "tmpdir"; require "page_print"; output_path = File.join(Dir.tmpdir, "page_print-output.pdf"); p PagePrint.render_to_file("<html><body><h1>Hello</h1></body></html>", output_path, page_size: :letter, margins: :narrow, media: :screen)'
224
223
  ```
225
224
 
226
225
  Or use the development console, which compiles the native extension first and then starts IRB with `PagePrint` loaded:
@@ -278,7 +277,7 @@ Build an Apple Silicon macOS platform gem with a vendored PlutoBook library:
278
277
  bundle exec rake package:darwin_arm64
279
278
  ```
280
279
 
281
- These tasks check out PlutoBook `v0.18.0`, build it into `lib/page_print/vendor/<platform>`, and write a platform gem to `pkg/`. Platform gems compile the Ruby extension during gem install to avoid tying the gem to the build machine's Ruby version.
280
+ These tasks check out PlutoBook `v0.19.0`, build it into `lib/page_print/vendor/<platform>`, and write a platform gem to `pkg/`. Platform gems compile the Ruby extension during gem install to avoid tying the gem to the build machine's Ruby version.
282
281
 
283
282
  Native gems bundle PlutoBook and its non-system shared library dependencies. Optional PlutoBook features for curl, TurboJPEG, and WebP are disabled to keep the bundled dependency set smaller.
284
283
 
@@ -739,7 +739,7 @@ static plutobook_stream_status_t pageprint_write_pdf_string(void *closure, const
739
739
  return PLUTOBOOK_STREAM_STATUS_SUCCESS;
740
740
  }
741
741
 
742
- static VALUE pageprint_html_to_pdf(int argc, VALUE *argv, VALUE self) {
742
+ static VALUE pageprint_render_to_file(int argc, VALUE *argv, VALUE self) {
743
743
  VALUE html;
744
744
  VALUE path;
745
745
  VALUE options;
@@ -799,7 +799,7 @@ static VALUE pageprint_html_to_pdf(int argc, VALUE *argv, VALUE self) {
799
799
  return Qtrue;
800
800
  }
801
801
 
802
- static VALUE pageprint_html_to_pdf_string(int argc, VALUE *argv, VALUE self) {
802
+ static VALUE pageprint_render(int argc, VALUE *argv, VALUE self) {
803
803
  VALUE html;
804
804
  VALUE options;
805
805
  pageprint_pdf_string_output_t output;
@@ -888,6 +888,6 @@ void Init_page_print(void) {
888
888
  id_mm = rb_intern_const("mm");
889
889
  id_px = rb_intern_const("px");
890
890
 
891
- rb_define_singleton_method(mPagePrint, "html_to_pdf", RUBY_METHOD_FUNC(pageprint_html_to_pdf), -1);
892
- rb_define_singleton_method(mPagePrint, "html_to_pdf_string", RUBY_METHOD_FUNC(pageprint_html_to_pdf_string), -1);
891
+ rb_define_singleton_method(mPagePrint, "render_to_file", RUBY_METHOD_FUNC(pageprint_render_to_file), -1);
892
+ rb_define_singleton_method(mPagePrint, "render", RUBY_METHOD_FUNC(pageprint_render), -1);
893
893
  }
@@ -39,7 +39,7 @@ extern "C" {
39
39
  #endif
40
40
 
41
41
  #define PLUTOBOOK_VERSION_MAJOR 0
42
- #define PLUTOBOOK_VERSION_MINOR 18
42
+ #define PLUTOBOOK_VERSION_MINOR 19
43
43
  #define PLUTOBOOK_VERSION_MICRO 0
44
44
 
45
45
  #define PLUTOBOOK_VERSION_ENCODE(major, minor, micro) (((major) * 10000) + ((minor) * 100) + ((micro) * 1))
@@ -680,7 +680,7 @@ PLUTOBOOK_API void plutobook_set_http_max_redirects(int amount);
680
680
  /**
681
681
  * @brief Sets the maximum time allowed for an HTTP request.
682
682
  *
683
- * If not set, the default timeout is 300 seconds.
683
+ * If not set, the default timeout is 30 seconds.
684
684
  *
685
685
  * @param timeout Timeout duration in seconds.
686
686
  */
@@ -316,6 +316,16 @@ public:
316
316
  */
317
317
  static const PageMargins Moderate;
318
318
 
319
+ /**
320
+ * @brief Represents wide page margins.
321
+ *
322
+ * - Top: 72 points (1 inch)
323
+ * - Right: 144 points (2 inches)
324
+ * - Bottom: 72 points (1 inch)
325
+ * - Left: 144 points (2 inches)
326
+ */
327
+ static const PageMargins Wide;
328
+
319
329
  private:
320
330
  float m_top{0};
321
331
  float m_right{0};
@@ -327,6 +337,7 @@ inline const PageMargins PageMargins::None = PLUTOBOOK_PAGE_MARGINS_NONE;
327
337
  inline const PageMargins PageMargins::Normal = PLUTOBOOK_PAGE_MARGINS_NORMAL;
328
338
  inline const PageMargins PageMargins::Narrow = PLUTOBOOK_PAGE_MARGINS_NARROW;
329
339
  inline const PageMargins PageMargins::Moderate = PLUTOBOOK_PAGE_MARGINS_MODERATE;
340
+ inline const PageMargins PageMargins::Wide = PLUTOBOOK_PAGE_MARGINS_WIDE;
330
341
 
331
342
  /**
332
343
  * Defines conversion factors for various units to points (pt) and vice versa.
@@ -587,7 +598,7 @@ public:
587
598
  /**
588
599
  * @brief Sets the maximum time allowed for a request.
589
600
  *
590
- * If not set, the default timeout is 300 seconds.
601
+ * If not set, the default timeout is 30 seconds.
591
602
  *
592
603
  * @param timeout Timeout duration in seconds.
593
604
  */
@@ -612,7 +623,7 @@ private:
612
623
 
613
624
  bool m_followRedirects = true;
614
625
  int m_maxRedirects = 30;
615
- int m_timeout = 300;
626
+ int m_timeout = 30;
616
627
 
617
628
  friend DefaultResourceFetcher* defaultResourceFetcher();
618
629
  };
@@ -4,8 +4,8 @@ libdir=${prefix}/lib
4
4
 
5
5
  Name: PlutoBook
6
6
  Description: Paged HTML rendering library
7
- Version: 0.18.0
8
- Requires.private: harfbuzz, expat >= 2.1.0, icu-uc >= 57.0, icu-i18n >= 57.0, freetype2 >= 9.7.3, fontconfig >= 2.12.5, cairo >= 1.15.10, cairo-pdf >= 1.15.10, cairo-png >= 1.15.10, cairo-ft >= 1.15.10, cairo-fc >= 1.15.10
7
+ Version: 0.19.0
8
+ Requires.private: harfbuzz, expat >= 2.1.0, icu-uc >= 57.0, freetype2 >= 9.7.3, fontconfig >= 2.12.5, cairo >= 1.15.10, cairo-pdf >= 1.15.10, cairo-png >= 1.15.10, cairo-ft >= 1.15.10, cairo-fc >= 1.15.10
9
9
  Libs: -L${libdir} -lplutobook
10
10
  Libs.private: -pthread -lm
11
11
  Cflags: -I${includedir}/plutobook
@@ -6,5 +6,5 @@ libharfbuzz-subset.so libharfbuzz-subset.so.0.61230.0
6
6
  libharfbuzz-subset.so.0 libharfbuzz-subset.so.0.61230.0
7
7
  libharfbuzz.so libharfbuzz.so.0.61230.0
8
8
  libharfbuzz.so.0 libharfbuzz.so.0.61230.0
9
- libplutobook.so libplutobook.so.0.18.0
10
- libplutobook.so.0 libplutobook.so.0.18.0
9
+ libplutobook.so libplutobook.so.0.19.0
10
+ libplutobook.so.0 libplutobook.so.0.19.0
@@ -1,3 +1,3 @@
1
1
  module PagePrint
2
- VERSION = '0.1.7'
2
+ VERSION = '0.1.9'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Dino Maric
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-08 00:00:00.000000000 Z
11
+ date: 2026-08-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A Ruby gem with a native extension that renders HTML strings to PDF files
14
14
  via the plutobook C library.
@@ -91,14 +91,12 @@ files:
91
91
  - lib/page_print/vendor/x86_64-linux/lib/libharfbuzz-subset.so.0.61230.0
92
92
  - lib/page_print/vendor/x86_64-linux/lib/libharfbuzz.so.0.61230.0
93
93
  - lib/page_print/vendor/x86_64-linux/lib/libicudata.so.67
94
- - lib/page_print/vendor/x86_64-linux/lib/libicui18n.so.67
95
94
  - lib/page_print/vendor/x86_64-linux/lib/libicuuc.so.67
96
95
  - lib/page_print/vendor/x86_64-linux/lib/libmd.so.0
97
96
  - lib/page_print/vendor/x86_64-linux/lib/libpcre.so.3
98
97
  - lib/page_print/vendor/x86_64-linux/lib/libpixman-1.so.0
99
- - lib/page_print/vendor/x86_64-linux/lib/libplutobook.so.0.18.0
98
+ - lib/page_print/vendor/x86_64-linux/lib/libplutobook.so.0.19.0
100
99
  - lib/page_print/vendor/x86_64-linux/lib/libpng16.so.16
101
- - lib/page_print/vendor/x86_64-linux/lib/libruby.so.3.2
102
100
  - lib/page_print/vendor/x86_64-linux/lib/libuuid.so.1
103
101
  - lib/page_print/vendor/x86_64-linux/lib/libxcb-render.so.0
104
102
  - lib/page_print/vendor/x86_64-linux/lib/libxcb-shm.so.0