palapala_pdf 0.1.3 → 0.1.4
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 +6 -6
- data/lib/palapala/pdf.rb +1 -1
- data/lib/palapala/version.rb +1 -1
- data/lib/palapala.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 467a7808449c84b0d2ddbd56c16a791ce1e3148636d911e8010fd3804f306abf
|
4
|
+
data.tar.gz: 7680b71baec5030b0992383f77c3098ac12da223d88057a36a4a985f97755c35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2533a247040eed4962a337ebd15e9bf51c875ed562242e44b791597d46dc69079e182980f9053cb3519525f6283c249f32dde0ee5668f9bccb2f9a10843d33f9
|
7
|
+
data.tar.gz: '07527904c55f1f0b99d98c1854ac369722c548f4626f5fe5ead3bf49d3bd573fc68ff9f4514cdbdf0acf4fb6c4bead8b80e10f34b3b55ee9fd3cc8f7ddf08436'
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ This is how easy and powerfull PDF generation can be in Ruby:
|
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
require "palapala"
|
11
|
-
Palapala::
|
11
|
+
Palapala::Pdf.new("<h1>Hello, world! #{Time.now}</h1>").save('hello.pdf')
|
12
12
|
```
|
13
13
|
|
14
14
|
And this while having the most modern HTML/CSS/JS availlable to you: flex, grid, canvas, you name it.
|
@@ -76,14 +76,14 @@ in IRB, load palapala and create a PDF from an HTML snippet:
|
|
76
76
|
|
77
77
|
```ruby
|
78
78
|
require "palapala"
|
79
|
-
Palapala::
|
79
|
+
Palapala::Pdf.new("<h1>Hello, world! #{Time.now}</h1>").save('hello.pdf')
|
80
80
|
```
|
81
81
|
|
82
|
-
Instantiate a new Palapala::
|
82
|
+
Instantiate a new Palapala::Pdf object with your HTML content and generate the PDF binary data.
|
83
83
|
|
84
84
|
```ruby
|
85
85
|
require "palapala"
|
86
|
-
binary_data = Palapala::
|
86
|
+
binary_data = Palapala::Pdf.new("<h1>Hello, world! #{Time.now}</h1>").binary_data
|
87
87
|
```
|
88
88
|
|
89
89
|
## Paged CSS
|
@@ -97,7 +97,7 @@ When using Chromium-based rendering engines, headers and footers are not control
|
|
97
97
|
With palapala PDF headers and footers are defined using `header_html` and `footer_html` options. These allow you to insert HTML content directly into the header or footer areas.
|
98
98
|
|
99
99
|
```ruby
|
100
|
-
Palapala::
|
100
|
+
Palapala::Pdf.new(
|
101
101
|
"<p>Hello world</>",
|
102
102
|
header_html: '<div style="text-align: center;">Page <span class="pageNumber"></span> of <span class="totalPages"></span></div>',
|
103
103
|
footer_html: '<div style="text-align: center;">Generated with Palapala PDF</div>',
|
@@ -198,7 +198,7 @@ Here's an example of how to use `render_to_string` to render a view template to
|
|
198
198
|
```ruby
|
199
199
|
def download_pdf
|
200
200
|
html_string = render_to_string(template: "example/template", layout: "print", locals: { } )
|
201
|
-
pdf_data = Palapala::
|
201
|
+
pdf_data = Palapala::Pdf.new(html_string).binary_data
|
202
202
|
send_data pdf_data, filename: "document.pdf", type: "application/pdf"
|
203
203
|
end
|
204
204
|
```
|
data/lib/palapala/pdf.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Palapala
|
4
4
|
# Page class to generate PDF from HTML content using Chrome in headless mode in a thread-safe way
|
5
5
|
# @param page_ranges Empty string means all pages, e.g., "1-3, 5, 7-9"
|
6
|
-
class
|
6
|
+
class Pdf
|
7
7
|
def initialize(content = nil,
|
8
8
|
header_html: nil,
|
9
9
|
footer_html: nil,
|
data/lib/palapala/version.rb
CHANGED
data/lib/palapala.rb
CHANGED