asposewordsjavaforruby 0.0.4 → 0.0.5
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/Gempackage +2 -2
- data/LICENSE +20 -20
- data/README.md +28 -2
- data/Rakefile +2 -2
- data/asposewordsjavaforruby.gemspec +27 -27
- data/config/aspose.yml +5 -5
- data/data/LoadTxt.txt +14 -14
- data/lib/asposewordsjavaforruby.rb +71 -71
- data/lib/asposewordsjavaforruby/addwatermark.rb +84 -84
- data/lib/asposewordsjavaforruby/appenddoc.rb +24 -24
- data/lib/asposewordsjavaforruby/appenddocument.rb +229 -229
- data/lib/asposewordsjavaforruby/applylicense.rb +16 -16
- data/lib/asposewordsjavaforruby/asposewordsjava.rb +23 -23
- data/lib/asposewordsjavaforruby/autofittables.rb +123 -123
- data/lib/asposewordsjavaforruby/bookmarks.rb +132 -132
- data/lib/asposewordsjavaforruby/checkformat.rb +70 -70
- data/lib/asposewordsjavaforruby/compressimages.rb +53 -53
- data/lib/asposewordsjavaforruby/doc2pdf.rb +15 -15
- data/lib/asposewordsjavaforruby/doctohtml.rb +26 -26
- data/lib/asposewordsjavaforruby/extractcontent.rb +395 -395
- data/lib/asposewordsjavaforruby/findandreplace.rb +29 -29
- data/lib/asposewordsjavaforruby/helloworld.rb +26 -26
- data/lib/asposewordsjavaforruby/imagetopdf.rb +71 -71
- data/lib/asposewordsjavaforruby/insertnestedfields.rb +39 -39
- data/lib/asposewordsjavaforruby/loadandsavetodisk.rb +20 -20
- data/lib/asposewordsjavaforruby/loadandsavetostream.rb +32 -32
- data/lib/asposewordsjavaforruby/loadtxt.rb +14 -14
- data/lib/asposewordsjavaforruby/mergefield.rb +45 -45
- data/lib/asposewordsjavaforruby/nodes.rb +29 -29
- data/lib/asposewordsjavaforruby/processcomments.rb +72 -72
- data/lib/asposewordsjavaforruby/removebreaks.rb +65 -65
- data/lib/asposewordsjavaforruby/removefield.rb +23 -23
- data/lib/asposewordsjavaforruby/saveasmultipagetiff.rb +26 -26
- data/lib/asposewordsjavaforruby/simplemailmerge.rb +23 -23
- data/lib/asposewordsjavaforruby/styles.rb +77 -77
- data/lib/asposewordsjavaforruby/updatefields.rb +62 -62
- data/lib/asposewordsjavaforruby/version.rb +3 -3
- metadata +18 -28
@@ -1,29 +1,29 @@
|
|
1
|
-
module Asposewordsjavaforruby
|
2
|
-
module FindAndReplace
|
3
|
-
def initialize()
|
4
|
-
# Find and replace text in document.
|
5
|
-
replace_text()
|
6
|
-
end
|
7
|
-
|
8
|
-
def replace_text()
|
9
|
-
# The path to the documents directory.
|
10
|
-
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
|
11
|
-
|
12
|
-
# Open the document.
|
13
|
-
doc = Rjb::import('com.aspose.words.Document').new(data_dir + "ReplaceSimple.doc")
|
14
|
-
|
15
|
-
# Check the text of the document.
|
16
|
-
puts "Original document text: " + doc.getRange().getText()
|
17
|
-
|
18
|
-
# Replace the text in the document.
|
19
|
-
doc.getRange().replace("_CustomerName_", "James Bond", false, false)
|
20
|
-
|
21
|
-
# Check the replacement was made.
|
22
|
-
puts "Document text after replace: " + doc.getRange().getText()
|
23
|
-
|
24
|
-
# Save the modified document.
|
25
|
-
doc.save(data_dir + "ReplaceSimple Out.doc")
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
1
|
+
module Asposewordsjavaforruby
|
2
|
+
module FindAndReplace
|
3
|
+
def initialize()
|
4
|
+
# Find and replace text in document.
|
5
|
+
replace_text()
|
6
|
+
end
|
7
|
+
|
8
|
+
def replace_text()
|
9
|
+
# The path to the documents directory.
|
10
|
+
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
|
11
|
+
|
12
|
+
# Open the document.
|
13
|
+
doc = Rjb::import('com.aspose.words.Document').new(data_dir + "ReplaceSimple.doc")
|
14
|
+
|
15
|
+
# Check the text of the document.
|
16
|
+
puts "Original document text: " + doc.getRange().getText()
|
17
|
+
|
18
|
+
# Replace the text in the document.
|
19
|
+
doc.getRange().replace("_CustomerName_", "James Bond", false, false)
|
20
|
+
|
21
|
+
# Check the replacement was made.
|
22
|
+
puts "Document text after replace: " + doc.getRange().getText()
|
23
|
+
|
24
|
+
# Save the modified document.
|
25
|
+
doc.save(data_dir + "ReplaceSimple Out.doc")
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -1,26 +1,26 @@
|
|
1
|
-
module Asposewordsjavaforruby
|
2
|
-
module HelloWorld
|
3
|
-
def initialize()
|
4
|
-
# Create document.
|
5
|
-
print_hello_world()
|
6
|
-
end
|
7
|
-
|
8
|
-
def print_hello_world()
|
9
|
-
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
|
10
|
-
|
11
|
-
#Create a blank document.
|
12
|
-
document = Rjb::import('com.aspose.words.Document').new()
|
13
|
-
|
14
|
-
#DocumentBuilder provides members to easily add content to a document.
|
15
|
-
builder = Rjb::import('com.aspose.words.DocumentBuilder').new(document)
|
16
|
-
|
17
|
-
#Write a new paragraph in the document with the text "Hello World!"
|
18
|
-
builder.writeln("Hello World!")
|
19
|
-
|
20
|
-
# Save the document in DOCX format. The format to save as is inferred from the extension of the file name.
|
21
|
-
# Aspose.Words supports saving any document in many more formats.
|
22
|
-
document.save(data_dir + "HelloWorld.docx")
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module Asposewordsjavaforruby
|
2
|
+
module HelloWorld
|
3
|
+
def initialize()
|
4
|
+
# Create document.
|
5
|
+
print_hello_world()
|
6
|
+
end
|
7
|
+
|
8
|
+
def print_hello_world()
|
9
|
+
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
|
10
|
+
|
11
|
+
#Create a blank document.
|
12
|
+
document = Rjb::import('com.aspose.words.Document').new()
|
13
|
+
|
14
|
+
#DocumentBuilder provides members to easily add content to a document.
|
15
|
+
builder = Rjb::import('com.aspose.words.DocumentBuilder').new(document)
|
16
|
+
|
17
|
+
#Write a new paragraph in the document with the text "Hello World!"
|
18
|
+
builder.writeln("Hello World!")
|
19
|
+
|
20
|
+
# Save the document in DOCX format. The format to save as is inferred from the extension of the file name.
|
21
|
+
# Aspose.Words supports saving any document in many more formats.
|
22
|
+
document.save(data_dir + "HelloWorld.docx")
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -1,71 +1,71 @@
|
|
1
|
-
module Asposewordsjavaforruby
|
2
|
-
module ImageToPdf
|
3
|
-
def initialize()
|
4
|
-
# The path to the documents directory.
|
5
|
-
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/imagetopdf/'
|
6
|
-
|
7
|
-
convert_image_to_pdf(data_dir + "Test.jpg", data_dir + "TestJpg Out.pdf")
|
8
|
-
convert_image_to_pdf(data_dir + "Test.png", data_dir + "TestPng Out.pdf")
|
9
|
-
convert_image_to_pdf(data_dir + "Test.bmp", data_dir + "TestBmp Out.pdf")
|
10
|
-
convert_image_to_pdf(data_dir + "Test.gif", data_dir + "TestGif Out.pdf")
|
11
|
-
end
|
12
|
-
|
13
|
-
def convert_image_to_pdf(input_filename, output_filename)
|
14
|
-
# Create Aspose.Words.Document and DocumentBuilder.
|
15
|
-
# The builder makes it simple to add content to the document.
|
16
|
-
doc = Rjb::import('com.aspose.words.Document').new
|
17
|
-
builder = Rjb::import('com.aspose.words.DocumentBuilder').new(doc)
|
18
|
-
|
19
|
-
# Load images from the disk using the approriate reader.
|
20
|
-
# The file formats that can be loaded depends on the image readers available on the machine.
|
21
|
-
imageio = Rjb::import('javax.imageio.ImageIO')
|
22
|
-
ImageInputStream = Rjb::import('javax.imageio.stream.ImageInputStream')
|
23
|
-
reader = Rjb::import('javax.imageio.ImageReader')
|
24
|
-
|
25
|
-
iis = imageio.createImageInputStream(Rjb::import('java.io.File').new(input_filename))
|
26
|
-
reader = imageio.getImageReaders(iis).next()
|
27
|
-
reader.setInput(iis, false)
|
28
|
-
|
29
|
-
# Get the number of frames in the image.
|
30
|
-
framesCount = reader.getNumImages(true)
|
31
|
-
|
32
|
-
# Loop through all frames.
|
33
|
-
for (int frameIdx = 0; frameIdx < framesCount; frameIdx++)
|
34
|
-
{
|
35
|
-
# Insert a section break before each new page, in case of a multi-frame image.
|
36
|
-
if (frameIdx != 0) then
|
37
|
-
break_type = Rjb::import('com.aspose.words.BreakType')
|
38
|
-
builder.insertBreak(break_type.SECTION_BREAK_NEW_PAGE)
|
39
|
-
end
|
40
|
-
|
41
|
-
# Select active frame.
|
42
|
-
image = Rjb::import('java.awt.image.BufferedImage')
|
43
|
-
image = reader.read(frameIdx)
|
44
|
-
|
45
|
-
# We want the size of the page to be the same as the size of the image.
|
46
|
-
# Convert pixels to points to size the page to the actual image size.
|
47
|
-
ps = Rjb::import('com.aspose.words.PageSetup')
|
48
|
-
ps = builder.getPageSetup()
|
49
|
-
|
50
|
-
convert_util = Rjb::import('com.aspose.words.ConvertUtil')
|
51
|
-
ps.setPageWidth(convert_util.pixelToPoint(image.getWidth()))
|
52
|
-
ps.setPageHeight(convert_util.pixelToPoint(image.getHeight()))
|
53
|
-
|
54
|
-
# Insert the image into the document and position it at the top left corner of the page.
|
55
|
-
builder.insertImage(
|
56
|
-
image,
|
57
|
-
RelativeHorizontalPosition.PAGE,
|
58
|
-
0,
|
59
|
-
RelativeVerticalPosition.PAGE,
|
60
|
-
0,
|
61
|
-
ps.getPageWidth(),
|
62
|
-
ps.getPageHeight(),
|
63
|
-
WrapType.NONE)
|
64
|
-
|
65
|
-
# Save the document.
|
66
|
-
doc.save(output_filename)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
1
|
+
module Asposewordsjavaforruby
|
2
|
+
module ImageToPdf
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/imagetopdf/'
|
6
|
+
|
7
|
+
convert_image_to_pdf(data_dir + "Test.jpg", data_dir + "TestJpg Out.pdf")
|
8
|
+
convert_image_to_pdf(data_dir + "Test.png", data_dir + "TestPng Out.pdf")
|
9
|
+
convert_image_to_pdf(data_dir + "Test.bmp", data_dir + "TestBmp Out.pdf")
|
10
|
+
convert_image_to_pdf(data_dir + "Test.gif", data_dir + "TestGif Out.pdf")
|
11
|
+
end
|
12
|
+
|
13
|
+
def convert_image_to_pdf(input_filename, output_filename)
|
14
|
+
# Create Aspose.Words.Document and DocumentBuilder.
|
15
|
+
# The builder makes it simple to add content to the document.
|
16
|
+
doc = Rjb::import('com.aspose.words.Document').new
|
17
|
+
builder = Rjb::import('com.aspose.words.DocumentBuilder').new(doc)
|
18
|
+
|
19
|
+
# Load images from the disk using the approriate reader.
|
20
|
+
# The file formats that can be loaded depends on the image readers available on the machine.
|
21
|
+
imageio = Rjb::import('javax.imageio.ImageIO')
|
22
|
+
ImageInputStream = Rjb::import('javax.imageio.stream.ImageInputStream')
|
23
|
+
reader = Rjb::import('javax.imageio.ImageReader')
|
24
|
+
|
25
|
+
iis = imageio.createImageInputStream(Rjb::import('java.io.File').new(input_filename))
|
26
|
+
reader = imageio.getImageReaders(iis).next()
|
27
|
+
reader.setInput(iis, false)
|
28
|
+
|
29
|
+
# Get the number of frames in the image.
|
30
|
+
framesCount = reader.getNumImages(true)
|
31
|
+
|
32
|
+
# Loop through all frames.
|
33
|
+
for (int frameIdx = 0; frameIdx < framesCount; frameIdx++)
|
34
|
+
{
|
35
|
+
# Insert a section break before each new page, in case of a multi-frame image.
|
36
|
+
if (frameIdx != 0) then
|
37
|
+
break_type = Rjb::import('com.aspose.words.BreakType')
|
38
|
+
builder.insertBreak(break_type.SECTION_BREAK_NEW_PAGE)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Select active frame.
|
42
|
+
image = Rjb::import('java.awt.image.BufferedImage')
|
43
|
+
image = reader.read(frameIdx)
|
44
|
+
|
45
|
+
# We want the size of the page to be the same as the size of the image.
|
46
|
+
# Convert pixels to points to size the page to the actual image size.
|
47
|
+
ps = Rjb::import('com.aspose.words.PageSetup')
|
48
|
+
ps = builder.getPageSetup()
|
49
|
+
|
50
|
+
convert_util = Rjb::import('com.aspose.words.ConvertUtil')
|
51
|
+
ps.setPageWidth(convert_util.pixelToPoint(image.getWidth()))
|
52
|
+
ps.setPageHeight(convert_util.pixelToPoint(image.getHeight()))
|
53
|
+
|
54
|
+
# Insert the image into the document and position it at the top left corner of the page.
|
55
|
+
builder.insertImage(
|
56
|
+
image,
|
57
|
+
RelativeHorizontalPosition.PAGE,
|
58
|
+
0,
|
59
|
+
RelativeVerticalPosition.PAGE,
|
60
|
+
0,
|
61
|
+
ps.getPageWidth(),
|
62
|
+
ps.getPageHeight(),
|
63
|
+
WrapType.NONE)
|
64
|
+
|
65
|
+
# Save the document.
|
66
|
+
doc.save(output_filename)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -1,39 +1,39 @@
|
|
1
|
-
module Asposewordsjavaforruby
|
2
|
-
module InsertNestedFields
|
3
|
-
def initialize()
|
4
|
-
# The path to the documents directory.
|
5
|
-
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/'
|
6
|
-
|
7
|
-
# Create new document.
|
8
|
-
doc = Rjb::import('com.aspose.words.Document').new
|
9
|
-
builder = Rjb::import("com.aspose.words.DocumentBuilder").new(doc)
|
10
|
-
|
11
|
-
# Insert few page breaks (just for testing)
|
12
|
-
breakType = Rjb::import("com.aspose.words.BreakType")
|
13
|
-
|
14
|
-
for i in 0..4
|
15
|
-
builder.insertBreak(breakType.PAGE_BREAK)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Move DocumentBuilder cursor into the primary footer.
|
19
|
-
headerFooterType = Rjb::import("com.aspose.words.HeaderFooterType")
|
20
|
-
builder.moveToHeaderFooter(headerFooterType.FOOTER_PRIMARY)
|
21
|
-
|
22
|
-
# We want to insert a field like this:
|
23
|
-
# { IF {PAGE} <> {NUMPAGES} "See Next Page" "Last Page" }
|
24
|
-
field = builder.insertField("IF ")
|
25
|
-
builder.moveTo(field.getSeparator())
|
26
|
-
builder.insertField("PAGE")
|
27
|
-
builder.write(" <> ")
|
28
|
-
builder.insertField("NUMPAGES")
|
29
|
-
builder.write(" \"See Next Page\" \"Last Page\" ")
|
30
|
-
|
31
|
-
# Finally update the outer field to recalcaluate the final value. Doing this will automatically update
|
32
|
-
# the inner fields at the same time.
|
33
|
-
field.update()
|
34
|
-
|
35
|
-
# Save the document.
|
36
|
-
doc.save(data_dir + "InsertNestedFields Out.doc")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
module Asposewordsjavaforruby
|
2
|
+
module InsertNestedFields
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/'
|
6
|
+
|
7
|
+
# Create new document.
|
8
|
+
doc = Rjb::import('com.aspose.words.Document').new
|
9
|
+
builder = Rjb::import("com.aspose.words.DocumentBuilder").new(doc)
|
10
|
+
|
11
|
+
# Insert few page breaks (just for testing)
|
12
|
+
breakType = Rjb::import("com.aspose.words.BreakType")
|
13
|
+
|
14
|
+
for i in 0..4
|
15
|
+
builder.insertBreak(breakType.PAGE_BREAK)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Move DocumentBuilder cursor into the primary footer.
|
19
|
+
headerFooterType = Rjb::import("com.aspose.words.HeaderFooterType")
|
20
|
+
builder.moveToHeaderFooter(headerFooterType.FOOTER_PRIMARY)
|
21
|
+
|
22
|
+
# We want to insert a field like this:
|
23
|
+
# { IF {PAGE} <> {NUMPAGES} "See Next Page" "Last Page" }
|
24
|
+
field = builder.insertField("IF ")
|
25
|
+
builder.moveTo(field.getSeparator())
|
26
|
+
builder.insertField("PAGE")
|
27
|
+
builder.write(" <> ")
|
28
|
+
builder.insertField("NUMPAGES")
|
29
|
+
builder.write(" \"See Next Page\" \"Last Page\" ")
|
30
|
+
|
31
|
+
# Finally update the outer field to recalcaluate the final value. Doing this will automatically update
|
32
|
+
# the inner fields at the same time.
|
33
|
+
field.update()
|
34
|
+
|
35
|
+
# Save the document.
|
36
|
+
doc.save(data_dir + "InsertNestedFields Out.doc")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,20 +1,20 @@
|
|
1
|
-
module Asposewordsjavaforruby
|
2
|
-
module LoadAndSaveToDisk
|
3
|
-
def initialize()
|
4
|
-
# Load and save the document.
|
5
|
-
save_to_disk()
|
6
|
-
end
|
7
|
-
|
8
|
-
def save_to_disk()
|
9
|
-
# The path to the documents directory.
|
10
|
-
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
|
11
|
-
|
12
|
-
# Open the document.
|
13
|
-
doc = Rjb::import('com.aspose.words.Document').new(data_dir + "Document.doc")
|
14
|
-
|
15
|
-
# Save the document as DOCX document.
|
16
|
-
doc.save(data_dir + "Document Out.docx")
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
1
|
+
module Asposewordsjavaforruby
|
2
|
+
module LoadAndSaveToDisk
|
3
|
+
def initialize()
|
4
|
+
# Load and save the document.
|
5
|
+
save_to_disk()
|
6
|
+
end
|
7
|
+
|
8
|
+
def save_to_disk()
|
9
|
+
# The path to the documents directory.
|
10
|
+
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
|
11
|
+
|
12
|
+
# Open the document.
|
13
|
+
doc = Rjb::import('com.aspose.words.Document').new(data_dir + "Document.doc")
|
14
|
+
|
15
|
+
# Save the document as DOCX document.
|
16
|
+
doc.save(data_dir + "Document Out.docx")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
module Asposewordsjavaforruby
|
2
|
-
module LoadAndSaveToStream
|
3
|
-
def initialize()
|
4
|
-
# Load and save to stream.
|
5
|
-
save_to_stream()
|
6
|
-
end
|
7
|
-
|
8
|
-
def save_to_stream()
|
9
|
-
# The path to the documents directory.
|
10
|
-
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
|
11
|
-
|
12
|
-
# Open the stream. Read only access is enough for Aspose.Words to load a document.
|
13
|
-
stream = Rjb::import('java.io.FileInputStream').new(data_dir + "Document.doc")
|
14
|
-
|
15
|
-
# Load the entire document into memory.
|
16
|
-
doc = Rjb::import('com.aspose.words.Document').new(stream)
|
17
|
-
|
18
|
-
# You can close the stream now, it is no longer needed because the document is in memory.
|
19
|
-
stream.close()
|
20
|
-
# ... do something with the document
|
21
|
-
# Convert the document to a different format and save to stream.
|
22
|
-
dst_stream = Rjb::import("java.io.ByteArrayOutputStream").new()
|
23
|
-
save_format = Rjb::import("com.aspose.words.SaveFormat")
|
24
|
-
doc.save(dst_stream, save_format.RTF)
|
25
|
-
|
26
|
-
output = Rjb::import("java.io.FileOutputStream").new(data_dir + "Document Out.rtf")
|
27
|
-
output.write(dst_stream.toByteArray())
|
28
|
-
output.close()
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
1
|
+
module Asposewordsjavaforruby
|
2
|
+
module LoadAndSaveToStream
|
3
|
+
def initialize()
|
4
|
+
# Load and save to stream.
|
5
|
+
save_to_stream()
|
6
|
+
end
|
7
|
+
|
8
|
+
def save_to_stream()
|
9
|
+
# The path to the documents directory.
|
10
|
+
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/quickstart/'
|
11
|
+
|
12
|
+
# Open the stream. Read only access is enough for Aspose.Words to load a document.
|
13
|
+
stream = Rjb::import('java.io.FileInputStream').new(data_dir + "Document.doc")
|
14
|
+
|
15
|
+
# Load the entire document into memory.
|
16
|
+
doc = Rjb::import('com.aspose.words.Document').new(stream)
|
17
|
+
|
18
|
+
# You can close the stream now, it is no longer needed because the document is in memory.
|
19
|
+
stream.close()
|
20
|
+
# ... do something with the document
|
21
|
+
# Convert the document to a different format and save to stream.
|
22
|
+
dst_stream = Rjb::import("java.io.ByteArrayOutputStream").new()
|
23
|
+
save_format = Rjb::import("com.aspose.words.SaveFormat")
|
24
|
+
doc.save(dst_stream, save_format.RTF)
|
25
|
+
|
26
|
+
output = Rjb::import("java.io.FileOutputStream").new(data_dir + "Document Out.rtf")
|
27
|
+
output.write(dst_stream.toByteArray())
|
28
|
+
output.close()
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
module Asposewordsjavaforruby
|
2
|
-
module LoadTxt
|
3
|
-
def initialize()
|
4
|
-
# The path to the documents directory.
|
5
|
-
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/'
|
6
|
-
|
7
|
-
# Open the document.
|
8
|
-
doc = Rjb::import('com.aspose.words.Document').new(data_dir + "LoadTxt.txt")
|
9
|
-
|
10
|
-
# Save as any Aspose.Words supported format, such as DOCX.
|
11
|
-
doc.save(data_dir + "LoadTxt Out.doc")
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
module Asposewordsjavaforruby
|
2
|
+
module LoadTxt
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/'
|
6
|
+
|
7
|
+
# Open the document.
|
8
|
+
doc = Rjb::import('com.aspose.words.Document').new(data_dir + "LoadTxt.txt")
|
9
|
+
|
10
|
+
# Save as any Aspose.Words supported format, such as DOCX.
|
11
|
+
doc.save(data_dir + "LoadTxt Out.doc")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|