docxify 0.0.8 → 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 +4 -4
- data/CHANGELOG.md +13 -1
- data/lib/docxify/document.rb +10 -1
- data/lib/docxify/element/page_layout.rb +43 -0
- data/lib/docxify/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 897b2f634b40161a9795499ceb4324d568792267e7e20ac0017c606cf9f42a47
|
4
|
+
data.tar.gz: 99f727d9d8b1d5063d9c290606911f45bdce092d83ede247fab952a112c72fae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '051835c221e1d60bf40e9ee2020ad0bb4682d67fcc3beea6f92ba80380ef0177ef7365b24562d1f19294c72fddfb83ddf860409fe835888b3682277aaf79a318'
|
7
|
+
data.tar.gz: 2f21816e06987a0650c4ab1f5c0628e8eccc77be64fe1bbee35f8a40ed1aede60a95d4bf8fba7bb7ce509feb394c6a1004266541f154a43bc2372a56578b9b17
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,22 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 0.1.0
|
4
|
+
|
5
|
+
Features:
|
6
|
+
|
7
|
+
- Implemented Document#bounds_width and Document#bounds_height
|
8
|
+
|
9
|
+
## 0.0.9
|
10
|
+
|
11
|
+
Features:
|
12
|
+
|
13
|
+
- Fixed page layout loading
|
14
|
+
|
3
15
|
## 0.0.8
|
4
16
|
|
5
17
|
Features:
|
6
18
|
|
7
|
-
- Allow changing of following section's page
|
19
|
+
- Allow changing of following section's page layout
|
8
20
|
|
9
21
|
## 0.0.7
|
10
22
|
|
data/lib/docxify/document.rb
CHANGED
@@ -16,6 +16,14 @@ module DocXify
|
|
16
16
|
@margins = { top: 2, bottom: 2, left: 2, right: 2 }.merge(options[:margins] || {})
|
17
17
|
end
|
18
18
|
|
19
|
+
def bounds_width
|
20
|
+
@page_layout&.bounds_width || (@width - @margins[:left] - @margins[:right])
|
21
|
+
end
|
22
|
+
|
23
|
+
def bounds_height
|
24
|
+
@page_layout&.bounds_height || (@height - @margins[:top] - @margins[:bottom])
|
25
|
+
end
|
26
|
+
|
19
27
|
def default_styling(options = {})
|
20
28
|
@font = options[:font] if options[:font]
|
21
29
|
@size = options[:size] if options[:size]
|
@@ -89,7 +97,8 @@ module DocXify
|
|
89
97
|
|
90
98
|
def add_page_layout(options = {})
|
91
99
|
options[:document] = self
|
92
|
-
|
100
|
+
@page_layout = DocXify::Element::PageLayout.new(options)
|
101
|
+
add @page_layout
|
93
102
|
end
|
94
103
|
|
95
104
|
def add_divider
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Word PageLayouts are a weird concept; instead of a wrapping element or a
|
2
|
+
# "this applies to content from here on down", it's applied retrospectively
|
3
|
+
# to the content that came before it.
|
4
|
+
module DocXify
|
5
|
+
module Element
|
6
|
+
class PageLayout < Base
|
7
|
+
attr_accessor :width, :height, :orientation
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
super()
|
11
|
+
@document = options[:document]
|
12
|
+
@margins = @document.margins
|
13
|
+
@width = options[:width] || @document&.width || DocXify::A4_PORTRAIT_WIDTH
|
14
|
+
@height = options[:height] || @document&.height || DocXify::A4_PORTRAIT_HEIGHT
|
15
|
+
@orientation = options[:orientation] || :portrait
|
16
|
+
end
|
17
|
+
|
18
|
+
# Don't consider this part of the public API, they're used by Document if it's been created
|
19
|
+
def bounds_width
|
20
|
+
@width - @margins[:left] - @margins[:right]
|
21
|
+
end
|
22
|
+
|
23
|
+
def bounds_height
|
24
|
+
@height - @margins[:top] - @margins[:bottom]
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_s(_container = nil)
|
28
|
+
<<~XML
|
29
|
+
<w:p>
|
30
|
+
<w:pPr>
|
31
|
+
<w:sectPr>
|
32
|
+
<w:pgSz w:w="#{@width}" w:h="#{@height}" w:orient="#{@orientation}"/>
|
33
|
+
<w:pgMar w:bottom="#{DocXify.cm2dxa @margins[:bottom]}" w:footer="708" w:gutter="0" w:header="708" w:left="#{DocXify.cm2dxa @margins[:left]}" w:right="#{DocXify.cm2dxa @margins[:right]}" w:top="#{DocXify.cm2dxa @margins[:top]}"/>
|
34
|
+
<w:cols w:space="708"/>
|
35
|
+
<w:docGrid w:linePitch="360"/>
|
36
|
+
</w:sectPr>
|
37
|
+
</w:pPr>
|
38
|
+
</w:p>
|
39
|
+
XML
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/docxify/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docxify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andy Jeffries
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubyzip
|
@@ -46,6 +46,7 @@ files:
|
|
46
46
|
- lib/docxify/element/file.rb
|
47
47
|
- lib/docxify/element/image.rb
|
48
48
|
- lib/docxify/element/page_break.rb
|
49
|
+
- lib/docxify/element/page_layout.rb
|
49
50
|
- lib/docxify/element/paragraph.rb
|
50
51
|
- lib/docxify/element/table.rb
|
51
52
|
- lib/docxify/element/table_cell.rb
|
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
75
|
- !ruby/object:Gem::Version
|
75
76
|
version: '0'
|
76
77
|
requirements: []
|
77
|
-
rubygems_version: 3.5.
|
78
|
+
rubygems_version: 3.5.17
|
78
79
|
signing_key:
|
79
80
|
specification_version: 4
|
80
81
|
summary: DocXify is a gem to help you generate Word documents from Ruby.
|