page_print 0.1.4-x86_64-linux → 0.1.6-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: 9dc3add8d3a96218b4e1bac7ca7002090e5495136fc2eda197a3846f79f2b46d
4
- data.tar.gz: 5c7ddb43128bff0c1e37b1632aee94dbb9d4835847df95861114ac518e891fed
3
+ metadata.gz: 5c4b102152d43feb2342bebd51167ef627964198945a74621060ab724d0cdd09
4
+ data.tar.gz: bb9dfec69bb3caafb150060247d0201e97fca142102e774295a5edbb3f675ac6
5
5
  SHA512:
6
- metadata.gz: 3c77024abc333f92727c49c0429902ddf70645ef6e72fbd9c55294e9746572a1abe047981127a19d3da39e02aeafa93bdd1980cc3b39da7ffa33a319ea4e6dc8
7
- data.tar.gz: 4127db92edb55b3524520faede9cb899649d0e341a11bfaa96730e111145fd2964e762d787cdd932a24307f6c354f777115954f8f063751be21842e1632c4283
6
+ metadata.gz: f99c5d07470b510cdab437c1bf80d690efec59067003cd65515dc35915248016d2e45a7aeee48e7f738e1dd95c5de4f90c7af45b653c42d59a231bc6c0965dcc
7
+ data.tar.gz: 6d4ec974bb6f0ce44ae515e6574d2362645ef0aaf519421f43fb352a6ddc16c3fb912febc413865a95925ac84f3762bb59007cc3b98ae6eea1ef4b454775ddf9
data/README.md CHANGED
@@ -130,6 +130,8 @@ Supported keyword options:
130
130
  - `resource_fetcher:` callable that receives a URL and returns `nil` or `{ content:, mime_type:, text_encoding: nil }`
131
131
  - `metadata:` hash with `:title`, `:author`, `:subject`, `:keywords`, `:creation_date`, or `:modification_date`
132
132
 
133
+ Unresolved URLs are not fetched over the network. Provide assets through `resource_fetcher`, or return `nil` to skip a URL.
134
+
133
135
  `metadata[:creation_date]` and `metadata[:modification_date]` should be ISO-8601 strings, for example `2026-05-10T12:00:00Z`.
134
136
 
135
137
  Custom dimensions and margins require `unit:`. Supported units are `:pt`, `:pc`, `:in`, `:cm`, `:mm`, and `:px`.
@@ -151,7 +153,7 @@ For options and CSV output, see `benchmark/README.md`.
151
153
 
152
154
  ## Requirements
153
155
 
154
- - Ruby 3.0+
156
+ - Ruby 3.2+
155
157
  - Native gems are published for `x86_64-linux` and `arm64-darwin`.
156
158
  - Native gems vendor PlutoBook but compile the small Ruby extension during install so it links against your local Ruby.
157
159
  - Source builds on unsupported platforms require PlutoBook development headers and library files.
@@ -250,6 +252,18 @@ gem build page_print.gemspec
250
252
  gem install ./page_print-*.gem
251
253
  ```
252
254
 
255
+ ## Releasing
256
+
257
+ Publish a new version with:
258
+
259
+ ```sh
260
+ bin/bump 0.1.6
261
+ ```
262
+
263
+ That updates `lib/page_print/version.rb` and `Gemfile.lock`, commits `Release 0.1.6`, creates annotated tag `v0.1.6`, and pushes `main` plus the tag. Requires a clean worktree on `main`.
264
+
265
+ The Package workflow then builds the source and platform gems, pushes them to RubyGems (trusted publishing / OIDC, GitHub environment `release`), and creates a GitHub Release with the gem artifacts and commit notes since the previous `v*` tag.
266
+
253
267
  ## Building Native Gems
254
268
 
255
269
  Build an `x86_64-linux` platform gem with a vendored PlutoBook library:
@@ -264,7 +278,7 @@ Build an Apple Silicon macOS platform gem with a vendored PlutoBook library:
264
278
  bundle exec rake package:darwin_arm64
265
279
  ```
266
280
 
267
- These tasks check out PlutoBook `v0.17.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.
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.
268
282
 
269
283
  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.
270
284
 
@@ -48,7 +48,7 @@ typedef struct {
48
48
  plutobook_page_size_t page_size;
49
49
  plutobook_page_margins_t margins;
50
50
  plutobook_media_type_t media;
51
- const char *base_url;
51
+ VALUE base_url;
52
52
  VALUE resource_fetcher;
53
53
  VALUE metadata;
54
54
  } pageprint_options_t;
@@ -97,6 +97,11 @@ typedef struct {
97
97
  int ok;
98
98
  } pageprint_write_pdf_stream_args_t;
99
99
 
100
+ typedef struct {
101
+ plutobook_t *book;
102
+ VALUE metadata;
103
+ } pageprint_apply_metadata_args_t;
104
+
100
105
  static VALUE pageprint_append_pdf_string(VALUE value);
101
106
  static plutobook_stream_status_t pageprint_write_pdf_string(void *closure, const char *data, unsigned int length);
102
107
  static plutobook_resource_data_t *pageprint_fetch_resource(void *closure, const char *url);
@@ -368,6 +373,15 @@ static void pageprint_apply_metadata(plutobook_t *book, VALUE metadata)
368
373
  pageprint_set_metadata_value(book, metadata, id_modification_date, PLUTOBOOK_PDF_METADATA_MODIFICATION_DATE);
369
374
  }
370
375
 
376
+ static VALUE pageprint_apply_metadata_with_gvl(VALUE ptr)
377
+ {
378
+ pageprint_apply_metadata_args_t *args = (pageprint_apply_metadata_args_t *)ptr;
379
+
380
+ pageprint_apply_metadata(args->book, args->metadata);
381
+
382
+ return Qnil;
383
+ }
384
+
371
385
  static void *pageprint_load_html_without_gvl(void *ptr)
372
386
  {
373
387
  pageprint_load_html_args_t *args = ptr;
@@ -487,23 +501,26 @@ static plutobook_resource_data_t *pageprint_fetch_resource(void *closure, const
487
501
  pageprint_resource_fetch_args_t args;
488
502
  int state;
489
503
 
490
- args.fetcher = fetcher;
491
- args.url = url;
492
- args.resource = NULL;
504
+ if (!NIL_P(fetcher->object)) {
505
+ args.fetcher = fetcher;
506
+ args.url = url;
507
+ args.resource = NULL;
493
508
 
494
- state = (int)(intptr_t)rb_thread_call_with_gvl(pageprint_call_resource_fetcher_with_gvl, &args);
509
+ state = (int)(intptr_t)rb_thread_call_with_gvl(pageprint_call_resource_fetcher_with_gvl, &args);
495
510
 
496
- if (state) {
497
- fetcher->state = state;
498
- plutobook_set_error_message("failed to fetch URL '%s'", url);
499
- return NULL;
500
- }
511
+ if (state) {
512
+ fetcher->state = state;
513
+ plutobook_set_error_message("failed to fetch URL '%s'", url);
514
+ return NULL;
515
+ }
501
516
 
502
- if (args.resource) {
503
- return args.resource;
517
+ if (args.resource) {
518
+ return args.resource;
519
+ }
504
520
  }
505
521
 
506
- return plutobook_fetch_url(url);
522
+ plutobook_set_error_message("network fetch disabled for URL '%s'", url);
523
+ return NULL;
507
524
  }
508
525
 
509
526
  static pageprint_options_t pageprint_options_from_value(VALUE options)
@@ -521,7 +538,7 @@ static pageprint_options_t pageprint_options_from_value(VALUE options)
521
538
  result.page_size = PLUTOBOOK_PAGE_SIZE_A4;
522
539
  result.margins = PLUTOBOOK_PAGE_MARGINS_NORMAL;
523
540
  result.media = PLUTOBOOK_MEDIA_TYPE_PRINT;
524
- result.base_url = "";
541
+ result.base_url = Qnil;
525
542
  result.resource_fetcher = Qnil;
526
543
  result.metadata = Qnil;
527
544
 
@@ -556,7 +573,7 @@ static pageprint_options_t pageprint_options_from_value(VALUE options)
556
573
  rb_raise(rb_eTypeError, "base_url must be a String or nil");
557
574
  }
558
575
 
559
- result.base_url = StringValueCStr(base_url_value);
576
+ result.base_url = base_url_value;
560
577
  }
561
578
 
562
579
  if (page_size_value != Qundef) {
@@ -596,6 +613,7 @@ static plutobook_t *pageprint_create_book_from_html(VALUE html, VALUE options, p
596
613
  pageprint_options_t pageprint_options;
597
614
 
598
615
  const char *html_str;
616
+ const char *base_url_str;
599
617
  long html_len;
600
618
 
601
619
  plutobook_t *book;
@@ -628,21 +646,30 @@ static plutobook_t *pageprint_create_book_from_html(VALUE html, VALUE options, p
628
646
  resource_fetcher->object = pageprint_options.resource_fetcher;
629
647
  resource_fetcher->state = 0;
630
648
 
631
- if (!NIL_P(resource_fetcher->object)) {
632
- plutobook_set_custom_resource_fetcher(book, pageprint_fetch_resource, resource_fetcher);
633
- }
649
+ plutobook_set_custom_resource_fetcher(book, pageprint_fetch_resource, resource_fetcher);
634
650
 
635
651
  /* 2. Load HTML */
636
652
  plutobook_clear_error_message();
637
653
 
654
+ base_url_str = "";
655
+ if (!NIL_P(pageprint_options.base_url)) {
656
+ base_url_str = StringValueCStr(pageprint_options.base_url);
657
+ }
658
+
638
659
  load_args.book = book;
639
660
  load_args.html = html_str;
640
661
  load_args.length = (int)html_len;
641
662
  load_args.user_style = "";
642
663
  load_args.user_script = "";
643
- load_args.base_url = pageprint_options.base_url;
664
+ load_args.base_url = base_url_str;
644
665
  load_args.ok = 0;
645
666
 
667
+ RB_GC_GUARD(html);
668
+ RB_GC_GUARD(options);
669
+ RB_GC_GUARD(pageprint_options.base_url);
670
+ RB_GC_GUARD(pageprint_options.resource_fetcher);
671
+ RB_GC_GUARD(pageprint_options.metadata);
672
+
646
673
  rb_thread_call_without_gvl(
647
674
  pageprint_load_html_without_gvl,
648
675
  &load_args,
@@ -665,7 +692,20 @@ static plutobook_t *pageprint_create_book_from_html(VALUE html, VALUE options, p
665
692
  rb_jump_tag(resource_fetcher->state);
666
693
  }
667
694
 
668
- pageprint_apply_metadata(book, pageprint_options.metadata);
695
+ {
696
+ pageprint_apply_metadata_args_t metadata_args;
697
+ int metadata_state = 0;
698
+
699
+ metadata_args.book = book;
700
+ metadata_args.metadata = pageprint_options.metadata;
701
+
702
+ rb_protect(pageprint_apply_metadata_with_gvl, (VALUE)&metadata_args, &metadata_state);
703
+
704
+ if (metadata_state) {
705
+ plutobook_destroy(book);
706
+ rb_jump_tag(metadata_state);
707
+ }
708
+ }
669
709
 
670
710
  return book;
671
711
  }
@@ -734,6 +774,11 @@ static VALUE pageprint_html_to_pdf(int argc, VALUE *argv, VALUE self) {
734
774
  write_args.path = path_str;
735
775
  write_args.ok = 0;
736
776
 
777
+ RB_GC_GUARD(html);
778
+ RB_GC_GUARD(options);
779
+ RB_GC_GUARD(resource_fetcher.object);
780
+ RB_GC_GUARD(path);
781
+
737
782
  rb_thread_call_without_gvl(
738
783
  pageprint_write_pdf_without_gvl,
739
784
  &write_args,
@@ -751,10 +796,6 @@ static VALUE pageprint_html_to_pdf(int argc, VALUE *argv, VALUE self) {
751
796
  pageprint_raise_plutobook_error_with_path(rb_eRuntimeError, "failed to write PDF to", path_str);
752
797
  }
753
798
 
754
- RB_GC_GUARD(resource_fetcher.object);
755
- RB_GC_GUARD(options);
756
- RB_GC_GUARD(path);
757
-
758
799
  return Qtrue;
759
800
  }
760
801
 
@@ -783,6 +824,11 @@ static VALUE pageprint_html_to_pdf_string(int argc, VALUE *argv, VALUE self) {
783
824
  write_args.output = &output;
784
825
  write_args.ok = 0;
785
826
 
827
+ RB_GC_GUARD(html);
828
+ RB_GC_GUARD(options);
829
+ RB_GC_GUARD(resource_fetcher.object);
830
+ RB_GC_GUARD(output.output);
831
+
786
832
  rb_thread_call_without_gvl(
787
833
  pageprint_write_pdf_stream_without_gvl,
788
834
  &write_args,
@@ -804,10 +850,6 @@ static VALUE pageprint_html_to_pdf_string(int argc, VALUE *argv, VALUE self) {
804
850
  pageprint_raise_plutobook_error(rb_eRuntimeError, "failed to write PDF to string");
805
851
  }
806
852
 
807
- RB_GC_GUARD(resource_fetcher.object);
808
- RB_GC_GUARD(options);
809
- RB_GC_GUARD(output.output);
810
-
811
853
  return output.output;
812
854
  }
813
855
 
@@ -39,7 +39,7 @@ extern "C" {
39
39
  #endif
40
40
 
41
41
  #define PLUTOBOOK_VERSION_MAJOR 0
42
- #define PLUTOBOOK_VERSION_MINOR 17
42
+ #define PLUTOBOOK_VERSION_MINOR 18
43
43
  #define PLUTOBOOK_VERSION_MICRO 0
44
44
 
45
45
  #define PLUTOBOOK_VERSION_ENCODE(major, minor, micro) (((major) * 10000) + ((minor) * 100) + ((micro) * 1))
@@ -4,7 +4,7 @@ libdir=${prefix}/lib
4
4
 
5
5
  Name: PlutoBook
6
6
  Description: Paged HTML rendering library
7
- Version: 0.17.0
7
+ Version: 0.18.0
8
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
9
9
  Libs: -L${libdir} -lplutobook
10
10
  Libs.private: -pthread -lm
@@ -1,3 +1,3 @@
1
1
  module PagePrint
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.6'
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.4
4
+ version: 0.1.6
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-06-03 00:00:00.000000000 Z
11
+ date: 2026-07-26 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.
@@ -106,9 +106,9 @@ files:
106
106
  - lib/page_print/vendor/x86_64-linux/lib/libpixman-1.so.0
107
107
  - lib/page_print/vendor/x86_64-linux/lib/libplutobook.so
108
108
  - lib/page_print/vendor/x86_64-linux/lib/libplutobook.so.0
109
- - lib/page_print/vendor/x86_64-linux/lib/libplutobook.so.0.17.0
109
+ - lib/page_print/vendor/x86_64-linux/lib/libplutobook.so.0.18.0
110
110
  - lib/page_print/vendor/x86_64-linux/lib/libpng16.so.16
111
- - lib/page_print/vendor/x86_64-linux/lib/libruby.so.3.0
111
+ - lib/page_print/vendor/x86_64-linux/lib/libruby.so.3.2
112
112
  - lib/page_print/vendor/x86_64-linux/lib/libuuid.so.1
113
113
  - lib/page_print/vendor/x86_64-linux/lib/libxcb-render.so.0
114
114
  - lib/page_print/vendor/x86_64-linux/lib/libxcb-shm.so.0
@@ -135,14 +135,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: '3.0'
138
+ version: '3.2'
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - ">="
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
- rubygems_version: 3.2.33
145
+ rubygems_version: 3.4.19
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Render HTML to PDF from Ruby using plutobook