pdfcrate 0.1.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 +7 -0
- data/Gemfile +9 -0
- data/LICENSE +21 -0
- data/README.md +177 -0
- data/ext/pdfcrate/Cargo.toml +16 -0
- data/ext/pdfcrate/extconf.rb +3 -0
- data/ext/pdfcrate/src/lib.rs +1383 -0
- data/lib/pdfcrate/version.rb +3 -0
- data/lib/pdfcrate.rb +86 -0
- data/pdfcrate.gemspec +43 -0
- metadata +96 -0
data/lib/pdfcrate.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "pdfcrate/version"
|
|
4
|
+
require "pdfcrate/pdfcrate"
|
|
5
|
+
|
|
6
|
+
module Pdfcrate
|
|
7
|
+
# Prawn::View-compatible mixin: delegates method calls to self.document
|
|
8
|
+
module View
|
|
9
|
+
def document
|
|
10
|
+
@document
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def method_missing(name, *args, **kwargs, &block)
|
|
16
|
+
return super unless document.respond_to?(name)
|
|
17
|
+
|
|
18
|
+
if kwargs.empty?
|
|
19
|
+
document.send(name, *args, &block)
|
|
20
|
+
else
|
|
21
|
+
document.send(name, *args, **kwargs, &block)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def respond_to_missing?(name, include_private = false)
|
|
26
|
+
document.respond_to?(name) || super
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Extend GridProxy with bounding_box method that delegates to Document
|
|
31
|
+
class GridProxy
|
|
32
|
+
attr_accessor :_document
|
|
33
|
+
|
|
34
|
+
def bounding_box(&block)
|
|
35
|
+
raise "GridProxy must be associated with a Document" unless _document
|
|
36
|
+
|
|
37
|
+
if is_span
|
|
38
|
+
_document.grid_span_bounding_box(row, col, end_row, end_col, &block)
|
|
39
|
+
else
|
|
40
|
+
_document.grid_cell_bounding_box(row, col, &block)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class Document
|
|
46
|
+
# Override grid to attach document reference
|
|
47
|
+
alias_method :_grid_raw, :grid
|
|
48
|
+
|
|
49
|
+
def grid(*args)
|
|
50
|
+
proxy = _grid_raw(*args)
|
|
51
|
+
proxy._document = self
|
|
52
|
+
proxy
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Grid cell bounding box - uses grid layout coordinates
|
|
56
|
+
def grid_cell_bounding_box(row, col, &block)
|
|
57
|
+
_grid_cell_bb(row, col, &block)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def grid_span_bounding_box(r1, c1, r2, c2, &block)
|
|
61
|
+
_grid_span_bb(r1, c1, r2, c2, &block)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# font_families.update() compatibility
|
|
65
|
+
# Returns a FontFamiliesUpdater that intercepts .update()
|
|
66
|
+
class FontFamiliesUpdater
|
|
67
|
+
def initialize(doc)
|
|
68
|
+
@doc = doc
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def update(families)
|
|
72
|
+
families.each do |name, styles|
|
|
73
|
+
kwargs = {}
|
|
74
|
+
styles.each do |style, path|
|
|
75
|
+
kwargs[style] = path
|
|
76
|
+
end
|
|
77
|
+
@doc.register_font_family(name, **kwargs)
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def font_families
|
|
83
|
+
FontFamiliesUpdater.new(self)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
data/pdfcrate.gemspec
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require_relative 'lib/pdfcrate/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "pdfcrate"
|
|
5
|
+
spec.version = Pdfcrate::VERSION
|
|
6
|
+
spec.authors = ["ratazzi"]
|
|
7
|
+
spec.email = ["ratazzi@gmail.com"]
|
|
8
|
+
|
|
9
|
+
spec.summary = "Ruby bindings for pdfcrate PDF generation library"
|
|
10
|
+
spec.description = "A Ruby gem providing Prawn-compatible API bindings to the pdfcrate Rust PDF generation library using Magnus."
|
|
11
|
+
spec.homepage = "https://github.com/ratazzi/pdfcrate"
|
|
12
|
+
spec.license = "MIT"
|
|
13
|
+
spec.required_ruby_version = ">= 3.1.0"
|
|
14
|
+
|
|
15
|
+
spec.files = Dir[
|
|
16
|
+
'lib/**/*.rb',
|
|
17
|
+
'ext/**/*.{rb,rs,toml}',
|
|
18
|
+
'ext/**/src/**/*.rs',
|
|
19
|
+
'README.md',
|
|
20
|
+
'LICENSE',
|
|
21
|
+
'Gemfile',
|
|
22
|
+
'*.gemspec'
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
spec.files += Dir['lib/**/*.{bundle,so,dll}'] if spec.respond_to?(:platform) && spec.platform != "ruby"
|
|
26
|
+
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
|
|
29
|
+
spec.extensions = ["ext/pdfcrate/extconf.rb"] if !spec.respond_to?(:platform) || spec.platform == "ruby"
|
|
30
|
+
|
|
31
|
+
if !spec.respond_to?(:platform) || spec.platform == "ruby"
|
|
32
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
33
|
+
spec.add_development_dependency "rake-compiler", "~> 1.2"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
spec.add_dependency "rb_sys", "~> 0.9.124"
|
|
37
|
+
|
|
38
|
+
spec.metadata = {
|
|
39
|
+
"source_code_uri" => "https://github.com/ratazzi/pdfcrate",
|
|
40
|
+
"rubygems_mfa_required" => "true",
|
|
41
|
+
"cargo_crate_name" => "pdfcrate-ruby"
|
|
42
|
+
}
|
|
43
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: pdfcrate
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ratazzi
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rake
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '13.0'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '13.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: rake-compiler
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '1.2'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '1.2'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rb_sys
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: 0.9.124
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: 0.9.124
|
|
54
|
+
description: A Ruby gem providing Prawn-compatible API bindings to the pdfcrate Rust
|
|
55
|
+
PDF generation library using Magnus.
|
|
56
|
+
email:
|
|
57
|
+
- ratazzi@gmail.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions:
|
|
60
|
+
- ext/pdfcrate/extconf.rb
|
|
61
|
+
extra_rdoc_files: []
|
|
62
|
+
files:
|
|
63
|
+
- Gemfile
|
|
64
|
+
- LICENSE
|
|
65
|
+
- README.md
|
|
66
|
+
- ext/pdfcrate/Cargo.toml
|
|
67
|
+
- ext/pdfcrate/extconf.rb
|
|
68
|
+
- ext/pdfcrate/src/lib.rs
|
|
69
|
+
- lib/pdfcrate.rb
|
|
70
|
+
- lib/pdfcrate/version.rb
|
|
71
|
+
- pdfcrate.gemspec
|
|
72
|
+
homepage: https://github.com/ratazzi/pdfcrate
|
|
73
|
+
licenses:
|
|
74
|
+
- MIT
|
|
75
|
+
metadata:
|
|
76
|
+
source_code_uri: https://github.com/ratazzi/pdfcrate
|
|
77
|
+
rubygems_mfa_required: 'true'
|
|
78
|
+
cargo_crate_name: pdfcrate-ruby
|
|
79
|
+
rdoc_options: []
|
|
80
|
+
require_paths:
|
|
81
|
+
- lib
|
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
|
+
requirements:
|
|
84
|
+
- - ">="
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: 3.1.0
|
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
requirements: []
|
|
93
|
+
rubygems_version: 3.6.9
|
|
94
|
+
specification_version: 4
|
|
95
|
+
summary: Ruby bindings for pdfcrate PDF generation library
|
|
96
|
+
test_files: []
|