asposewordsjavaforruby 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/Gempackage +2 -2
  3. data/LICENSE +20 -20
  4. data/README.md +28 -2
  5. data/Rakefile +2 -2
  6. data/asposewordsjavaforruby.gemspec +27 -27
  7. data/config/aspose.yml +5 -5
  8. data/data/LoadTxt.txt +14 -14
  9. data/lib/asposewordsjavaforruby.rb +71 -71
  10. data/lib/asposewordsjavaforruby/addwatermark.rb +84 -84
  11. data/lib/asposewordsjavaforruby/appenddoc.rb +24 -24
  12. data/lib/asposewordsjavaforruby/appenddocument.rb +229 -229
  13. data/lib/asposewordsjavaforruby/applylicense.rb +16 -16
  14. data/lib/asposewordsjavaforruby/asposewordsjava.rb +23 -23
  15. data/lib/asposewordsjavaforruby/autofittables.rb +123 -123
  16. data/lib/asposewordsjavaforruby/bookmarks.rb +132 -132
  17. data/lib/asposewordsjavaforruby/checkformat.rb +70 -70
  18. data/lib/asposewordsjavaforruby/compressimages.rb +53 -53
  19. data/lib/asposewordsjavaforruby/doc2pdf.rb +15 -15
  20. data/lib/asposewordsjavaforruby/doctohtml.rb +26 -26
  21. data/lib/asposewordsjavaforruby/extractcontent.rb +395 -395
  22. data/lib/asposewordsjavaforruby/findandreplace.rb +29 -29
  23. data/lib/asposewordsjavaforruby/helloworld.rb +26 -26
  24. data/lib/asposewordsjavaforruby/imagetopdf.rb +71 -71
  25. data/lib/asposewordsjavaforruby/insertnestedfields.rb +39 -39
  26. data/lib/asposewordsjavaforruby/loadandsavetodisk.rb +20 -20
  27. data/lib/asposewordsjavaforruby/loadandsavetostream.rb +32 -32
  28. data/lib/asposewordsjavaforruby/loadtxt.rb +14 -14
  29. data/lib/asposewordsjavaforruby/mergefield.rb +45 -45
  30. data/lib/asposewordsjavaforruby/nodes.rb +29 -29
  31. data/lib/asposewordsjavaforruby/processcomments.rb +72 -72
  32. data/lib/asposewordsjavaforruby/removebreaks.rb +65 -65
  33. data/lib/asposewordsjavaforruby/removefield.rb +23 -23
  34. data/lib/asposewordsjavaforruby/saveasmultipagetiff.rb +26 -26
  35. data/lib/asposewordsjavaforruby/simplemailmerge.rb +23 -23
  36. data/lib/asposewordsjavaforruby/styles.rb +77 -77
  37. data/lib/asposewordsjavaforruby/updatefields.rb +62 -62
  38. data/lib/asposewordsjavaforruby/version.rb +3 -3
  39. metadata +18 -28
@@ -1,24 +1,24 @@
1
- module Asposewordsjavaforruby
2
- module AppendDoc
3
- def initialize()
4
- # Append document.
5
- append_documents()
6
- end
7
-
8
- def append_documents()
9
- data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
10
-
11
- # Load the destination and source documents from disk.
12
- dst_doc = Rjb::import('com.aspose.words.Document').new(data_dir + "TestFile.Destination.doc")
13
- src_doc = Rjb::import('com.aspose.words.Document').new(data_dir + "TestFile.Source.doc")
14
-
15
- importformatmode = Rjb::import('com.aspose.words.ImportFormatMode')
16
- source_formating = importformatmode.KEEP_SOURCE_FORMATTING
17
-
18
- # Append the source document to the destination document while keeping the original formatting of the source document.
19
- dst_doc.appendDocument(src_doc, source_formating)
20
- dst_doc.save(data_dir + "TestFile Out.docx")
21
- end
22
-
23
- end
24
- end
1
+ module Asposewordsjavaforruby
2
+ module AppendDoc
3
+ def initialize()
4
+ # Append document.
5
+ append_documents()
6
+ end
7
+
8
+ def append_documents()
9
+ data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
10
+
11
+ # Load the destination and source documents from disk.
12
+ dst_doc = Rjb::import('com.aspose.words.Document').new(data_dir + "TestFile.Destination.doc")
13
+ src_doc = Rjb::import('com.aspose.words.Document').new(data_dir + "TestFile.Source.doc")
14
+
15
+ importformatmode = Rjb::import('com.aspose.words.ImportFormatMode')
16
+ source_formating = importformatmode.KEEP_SOURCE_FORMATTING
17
+
18
+ # Append the source document to the destination document while keeping the original formatting of the source document.
19
+ dst_doc.appendDocument(src_doc, source_formating)
20
+ dst_doc.save(data_dir + "TestFile Out.docx")
21
+ end
22
+
23
+ end
24
+ end
@@ -1,229 +1,229 @@
1
- module Asposewordsjavaforruby
2
- module AppendDocument
3
- def initialize()
4
- # The path to the documents directory.
5
- @data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/joiningandappending/'
6
-
7
- simple_append_document()
8
- keep_source_formatting()
9
- use_destination_styles()
10
- join_continuous()
11
- join_new_page()
12
- restart_page_numbering()
13
- link_headers_footers()
14
- unlink_headers_footers()
15
- remove_source_headers_footers()
16
- different_page_setup()
17
- end
18
-
19
- =begin
20
- Shows how to append a document to the end of another document using no additional options.
21
- =end
22
- def simple_append_document()
23
- # Load the documents to join.
24
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
25
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
26
-
27
- # Append the source document to the destination document using no extra options.
28
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
29
- dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
30
-
31
- # Save the document.
32
- dst_doc.save(@data_dir + "TestFile.SimpleAppendDocument Out.docx")
33
- end
34
-
35
- =begin
36
- Shows how to append a document to another document while keeping the original formatting.
37
- =end
38
- def keep_source_formatting()
39
- # Load the documents to join.
40
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
41
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
42
-
43
- # Append the source document to the destination document using no extra options.
44
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
45
- dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
46
-
47
- # Save the document.
48
- dst_doc.save(@data_dir + "TestFile.KeepSourceFormatting Out.docx")
49
- end
50
-
51
- =begin
52
- Shows how to append a document to another document using the formatting of the destination document.
53
- =end
54
- def use_destination_styles()
55
- # Load the documents to join.
56
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
57
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
58
-
59
- # Append the source document to the destination document using no extra options.
60
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
61
- dst_doc.appendDocument(src_doc, import_format_mode.USE_DESTINATION_STYLES)
62
-
63
- # Save the document.
64
- dst_doc.save(@data_dir + "TestFile.UseDestinationStyles Out.docx")
65
- end
66
-
67
- =begin
68
- Shows how to append a document to another document so the content flows continuously.
69
- =end
70
- def join_continuous()
71
- # Load the documents to join.
72
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
73
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
74
-
75
- # Make the document appear straight after the destination documents content.
76
- section_start = Rjb::import("com.aspose.words.SectionStart")
77
- src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.CONTINUOUS)
78
-
79
- # Append the source document using the original styles found in the source document.
80
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
81
- dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
82
-
83
- # Save the document.
84
- dst_doc.save(@data_dir + "TestFile.JoinContinuous Out.docx")
85
- end
86
-
87
- =begin
88
- Shows how to append a document to another document so it starts on a new page.
89
- =end
90
- def join_new_page()
91
- # Load the documents to join.
92
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
93
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
94
-
95
- # Set the appended document to start on a new page.
96
- section_start = Rjb::import("com.aspose.words.SectionStart")
97
- src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.NEW_PAGE)
98
-
99
- # Append the source document using the original styles found in the source document.
100
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
101
- dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
102
-
103
- # Save the document.
104
- dst_doc.save(@data_dir + "TestFile.JoinNewPage Out.docx")
105
- end
106
-
107
- =begin
108
- Shows how to append a document to another document with page numbering restarted.
109
- =end
110
- def restart_page_numbering()
111
- # Load the documents to join.
112
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
113
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
114
-
115
- # Set the appended document to start on a new page.
116
- section_start = Rjb::import("com.aspose.words.SectionStart")
117
- src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.NEW_PAGE)
118
-
119
- # Restart the page numbering for the document to be appended.
120
- src_doc.getFirstSection().getPageSetup().setRestartPageNumbering(true)
121
-
122
- # Append the source document using the original styles found in the source document.
123
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
124
- dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
125
-
126
- # Save the document.
127
- dst_doc.save(@data_dir + "TestFile.RestartPageNumbering Out.docx")
128
- end
129
-
130
- =begin
131
- Shows how to append a document to another document and continue headers and footers from the destination document.
132
- =end
133
- def link_headers_footers()
134
- # Load the documents to join.
135
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
136
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
137
-
138
- # Set the appended document to start on a new page.
139
- section_start = Rjb::import("com.aspose.words.SectionStart")
140
- src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.NEW_PAGE)
141
-
142
- # Link the headers and footers in the source document to the previous section.
143
- # This will override any headers or footers already found in the source document.
144
- src_doc.getFirstSection().getHeadersFooters().linkToPrevious(true)
145
-
146
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
147
- dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
148
-
149
- # Save the document.
150
- dst_doc.save(@data_dir + "TestFile.LinkHeadersFooters Out.docx")
151
- end
152
-
153
- =begin
154
- Shows how to append a document to another document so headers and footers do not continue from the destination document.
155
- =end
156
- def unlink_headers_footers()
157
- # Load the documents to join.
158
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
159
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
160
-
161
- # Even a document with no headers or footers can still have the LinkToPrevious setting set to true.
162
- # Unlink the headers and footers in the source document to stop this from continuing the headers and footers
163
- # from the destination document.
164
- src_doc.getFirstSection().getHeadersFooters().linkToPrevious(false)
165
-
166
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
167
- dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
168
-
169
- # Save the document.
170
- dst_doc.save(@data_dir + "TestFile.UnlinkHeadersFooters Out.docx")
171
- end
172
-
173
- =begin
174
- Shows how to append a document to another document so headers and footers do not continue from the destination document.
175
- =end
176
- def remove_source_headers_footers()
177
- # Load the documents to join.
178
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
179
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
180
-
181
- # Remove the headers and footers from each of the sections in the source document.
182
- sections = src_doc.getSections().toArray()
183
- sections.each do |section|
184
- section.clearHeadersFooters()
185
- end
186
-
187
- # Even after the headers and footers are cleared from the source document, the "LinkToPrevious" setting
188
- # for HeadersFooters can still be set. This will cause the headers and footers to continue from the destination
189
- # document. This should set to false to avoid this behaviour.
190
- src_doc.getFirstSection().getHeadersFooters().linkToPrevious(false)
191
-
192
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
193
- dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
194
-
195
- # Save the document.
196
- dst_doc.save(@data_dir + "TestFile.RemoveSourceHeadersFooters Out.docx")
197
- end
198
-
199
- =begin
200
- Shows how to append a document to another document continuously which has different page settings.
201
- =end
202
- def different_page_setup()
203
- # Load the documents to join.
204
- dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
205
- src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
206
-
207
- # Set the source document to continue straight after the end of the destination document.
208
- # If some page setup settings are different then this may not work and the source document will appear
209
- # on a new page.
210
- section_start = Rjb::import("com.aspose.words.SectionStart")
211
- src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.CONTINUOUS)
212
-
213
- # To ensure this does not happen when the source document has different page setup settings make sure the
214
- # settings are identical between the last section of the destination document.
215
- # If there are further continuous sections that follow on in the source document then this will need to be
216
- # repeated for those sections as well.
217
- src_doc.getFirstSection().getPageSetup().setPageWidth(dst_doc.getLastSection().getPageSetup().getPageWidth())
218
- src_doc.getFirstSection().getPageSetup().setPageHeight(dst_doc.getLastSection().getPageSetup().getPageHeight())
219
- src_doc.getFirstSection().getPageSetup().setOrientation(dst_doc.getLastSection().getPageSetup().getOrientation())
220
-
221
- import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
222
- dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
223
-
224
- # Save the document.
225
- dst_doc.save(@data_dir + "TestFile.DifferentPageSetup Out.docx")
226
- end
227
-
228
- end
229
- end
1
+ module Asposewordsjavaforruby
2
+ module AppendDocument
3
+ def initialize()
4
+ # The path to the documents directory.
5
+ @data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/joiningandappending/'
6
+
7
+ simple_append_document()
8
+ keep_source_formatting()
9
+ use_destination_styles()
10
+ join_continuous()
11
+ join_new_page()
12
+ restart_page_numbering()
13
+ link_headers_footers()
14
+ unlink_headers_footers()
15
+ remove_source_headers_footers()
16
+ different_page_setup()
17
+ end
18
+
19
+ =begin
20
+ Shows how to append a document to the end of another document using no additional options.
21
+ =end
22
+ def simple_append_document()
23
+ # Load the documents to join.
24
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
25
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
26
+
27
+ # Append the source document to the destination document using no extra options.
28
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
29
+ dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
30
+
31
+ # Save the document.
32
+ dst_doc.save(@data_dir + "TestFile.SimpleAppendDocument Out.docx")
33
+ end
34
+
35
+ =begin
36
+ Shows how to append a document to another document while keeping the original formatting.
37
+ =end
38
+ def keep_source_formatting()
39
+ # Load the documents to join.
40
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
41
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
42
+
43
+ # Append the source document to the destination document using no extra options.
44
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
45
+ dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
46
+
47
+ # Save the document.
48
+ dst_doc.save(@data_dir + "TestFile.KeepSourceFormatting Out.docx")
49
+ end
50
+
51
+ =begin
52
+ Shows how to append a document to another document using the formatting of the destination document.
53
+ =end
54
+ def use_destination_styles()
55
+ # Load the documents to join.
56
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
57
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
58
+
59
+ # Append the source document to the destination document using no extra options.
60
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
61
+ dst_doc.appendDocument(src_doc, import_format_mode.USE_DESTINATION_STYLES)
62
+
63
+ # Save the document.
64
+ dst_doc.save(@data_dir + "TestFile.UseDestinationStyles Out.docx")
65
+ end
66
+
67
+ =begin
68
+ Shows how to append a document to another document so the content flows continuously.
69
+ =end
70
+ def join_continuous()
71
+ # Load the documents to join.
72
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
73
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
74
+
75
+ # Make the document appear straight after the destination documents content.
76
+ section_start = Rjb::import("com.aspose.words.SectionStart")
77
+ src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.CONTINUOUS)
78
+
79
+ # Append the source document using the original styles found in the source document.
80
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
81
+ dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
82
+
83
+ # Save the document.
84
+ dst_doc.save(@data_dir + "TestFile.JoinContinuous Out.docx")
85
+ end
86
+
87
+ =begin
88
+ Shows how to append a document to another document so it starts on a new page.
89
+ =end
90
+ def join_new_page()
91
+ # Load the documents to join.
92
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
93
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
94
+
95
+ # Set the appended document to start on a new page.
96
+ section_start = Rjb::import("com.aspose.words.SectionStart")
97
+ src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.NEW_PAGE)
98
+
99
+ # Append the source document using the original styles found in the source document.
100
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
101
+ dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
102
+
103
+ # Save the document.
104
+ dst_doc.save(@data_dir + "TestFile.JoinNewPage Out.docx")
105
+ end
106
+
107
+ =begin
108
+ Shows how to append a document to another document with page numbering restarted.
109
+ =end
110
+ def restart_page_numbering()
111
+ # Load the documents to join.
112
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
113
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
114
+
115
+ # Set the appended document to start on a new page.
116
+ section_start = Rjb::import("com.aspose.words.SectionStart")
117
+ src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.NEW_PAGE)
118
+
119
+ # Restart the page numbering for the document to be appended.
120
+ src_doc.getFirstSection().getPageSetup().setRestartPageNumbering(true)
121
+
122
+ # Append the source document using the original styles found in the source document.
123
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
124
+ dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
125
+
126
+ # Save the document.
127
+ dst_doc.save(@data_dir + "TestFile.RestartPageNumbering Out.docx")
128
+ end
129
+
130
+ =begin
131
+ Shows how to append a document to another document and continue headers and footers from the destination document.
132
+ =end
133
+ def link_headers_footers()
134
+ # Load the documents to join.
135
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
136
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
137
+
138
+ # Set the appended document to start on a new page.
139
+ section_start = Rjb::import("com.aspose.words.SectionStart")
140
+ src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.NEW_PAGE)
141
+
142
+ # Link the headers and footers in the source document to the previous section.
143
+ # This will override any headers or footers already found in the source document.
144
+ src_doc.getFirstSection().getHeadersFooters().linkToPrevious(true)
145
+
146
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
147
+ dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
148
+
149
+ # Save the document.
150
+ dst_doc.save(@data_dir + "TestFile.LinkHeadersFooters Out.docx")
151
+ end
152
+
153
+ =begin
154
+ Shows how to append a document to another document so headers and footers do not continue from the destination document.
155
+ =end
156
+ def unlink_headers_footers()
157
+ # Load the documents to join.
158
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
159
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
160
+
161
+ # Even a document with no headers or footers can still have the LinkToPrevious setting set to true.
162
+ # Unlink the headers and footers in the source document to stop this from continuing the headers and footers
163
+ # from the destination document.
164
+ src_doc.getFirstSection().getHeadersFooters().linkToPrevious(false)
165
+
166
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
167
+ dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
168
+
169
+ # Save the document.
170
+ dst_doc.save(@data_dir + "TestFile.UnlinkHeadersFooters Out.docx")
171
+ end
172
+
173
+ =begin
174
+ Shows how to append a document to another document so headers and footers do not continue from the destination document.
175
+ =end
176
+ def remove_source_headers_footers()
177
+ # Load the documents to join.
178
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
179
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
180
+
181
+ # Remove the headers and footers from each of the sections in the source document.
182
+ sections = src_doc.getSections().toArray()
183
+ sections.each do |section|
184
+ section.clearHeadersFooters()
185
+ end
186
+
187
+ # Even after the headers and footers are cleared from the source document, the "LinkToPrevious" setting
188
+ # for HeadersFooters can still be set. This will cause the headers and footers to continue from the destination
189
+ # document. This should set to false to avoid this behaviour.
190
+ src_doc.getFirstSection().getHeadersFooters().linkToPrevious(false)
191
+
192
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
193
+ dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
194
+
195
+ # Save the document.
196
+ dst_doc.save(@data_dir + "TestFile.RemoveSourceHeadersFooters Out.docx")
197
+ end
198
+
199
+ =begin
200
+ Shows how to append a document to another document continuously which has different page settings.
201
+ =end
202
+ def different_page_setup()
203
+ # Load the documents to join.
204
+ dst_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Destination.doc")
205
+ src_doc = Rjb::import("com.aspose.words.Document").new(@data_dir + "TestFile.Source.doc")
206
+
207
+ # Set the source document to continue straight after the end of the destination document.
208
+ # If some page setup settings are different then this may not work and the source document will appear
209
+ # on a new page.
210
+ section_start = Rjb::import("com.aspose.words.SectionStart")
211
+ src_doc.getFirstSection().getPageSetup().setSectionStart(section_start.CONTINUOUS)
212
+
213
+ # To ensure this does not happen when the source document has different page setup settings make sure the
214
+ # settings are identical between the last section of the destination document.
215
+ # If there are further continuous sections that follow on in the source document then this will need to be
216
+ # repeated for those sections as well.
217
+ src_doc.getFirstSection().getPageSetup().setPageWidth(dst_doc.getLastSection().getPageSetup().getPageWidth())
218
+ src_doc.getFirstSection().getPageSetup().setPageHeight(dst_doc.getLastSection().getPageSetup().getPageHeight())
219
+ src_doc.getFirstSection().getPageSetup().setOrientation(dst_doc.getLastSection().getPageSetup().getOrientation())
220
+
221
+ import_format_mode = Rjb::import("com.aspose.words.ImportFormatMode")
222
+ dst_doc.appendDocument(src_doc, import_format_mode.KEEP_SOURCE_FORMATTING)
223
+
224
+ # Save the document.
225
+ dst_doc.save(@data_dir + "TestFile.DifferentPageSetup Out.docx")
226
+ end
227
+
228
+ end
229
+ end