asposepdfjava 0.0.1
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 +3 -0
- data/LICENSE +21 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/asposepdfjava.gemspec +27 -0
- data/config/aspose.yml +5 -0
- data/data/Example.svg +69 -0
- data/data/index.html +5 -0
- data/data/input.pdf +0 -0
- data/data/input1.pdf +0 -0
- data/lib/asposepdfjava.rb +71 -0
- data/lib/asposepdfjava/Converter/convertpagestoimages.rb +21 -0
- data/lib/asposepdfjava/Converter/htmltopdf.rb +18 -0
- data/lib/asposepdfjava/Converter/pdftodoc.rb +16 -0
- data/lib/asposepdfjava/Converter/pdftoexcel.rb +19 -0
- data/lib/asposepdfjava/Converter/pdftosvg.rb +22 -0
- data/lib/asposepdfjava/Converter/svgtopdf.rb +19 -0
- data/lib/asposepdfjava/Document/addjavascript.rb +27 -0
- data/lib/asposepdfjava/Document/addlayers.rb +40 -0
- data/lib/asposepdfjava/Document/addtoc.rb +56 -0
- data/lib/asposepdfjava/Document/getdocumentwindow.rb +46 -0
- data/lib/asposepdfjava/Document/getpdffileinfo.rb +22 -0
- data/lib/asposepdfjava/Document/getxmpmetadata.rb +16 -0
- data/lib/asposepdfjava/Document/optimize.rb +47 -0
- data/lib/asposepdfjava/Document/removemetadata.rb +24 -0
- data/lib/asposepdfjava/Document/setdocumentwindow .rb +49 -0
- data/lib/asposepdfjava/Document/setdocumentwindow.rb +49 -0
- data/lib/asposepdfjava/Document/setexpiration.rb +26 -0
- data/lib/asposepdfjava/Document/setpdffileinfo.rb +26 -0
- data/lib/asposepdfjava/Pages/concatenatepdffiles.rb +22 -0
- data/lib/asposepdfjava/Pages/deletepage.rb +19 -0
- data/lib/asposepdfjava/Pages/getnumberofpages.rb +14 -0
- data/lib/asposepdfjava/Pages/getpage.rb +25 -0
- data/lib/asposepdfjava/Pages/getpageproperties.rb +27 -0
- data/lib/asposepdfjava/Pages/insertemptypage.rb +19 -0
- data/lib/asposepdfjava/Pages/insertemptypageatendoffile.rb +19 -0
- data/lib/asposepdfjava/Pages/splitallpages.rb +29 -0
- data/lib/asposepdfjava/Pages/updatepagedimensions.rb +26 -0
- data/lib/asposepdfjava/Text/addhtml.rb +33 -0
- data/lib/asposepdfjava/Text/addtext.rb +39 -0
- data/lib/asposepdfjava/Text/extracttextfromallpages.rb +34 -0
- data/lib/asposepdfjava/Text/replacetextallpages.rb +39 -0
- data/lib/asposepdfjava/asposepdf.rb +5 -0
- data/lib/asposepdfjava/converter.rb +6 -0
- data/lib/asposepdfjava/document.rb +11 -0
- data/lib/asposepdfjava/helloworld.rb +21 -0
- data/lib/asposepdfjava/pages.rb +9 -0
- data/lib/asposepdfjava/text.rb +4 -0
- data/lib/asposepdfjava/version.rb +3 -0
- data/samples/test.rb +8 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 89ac1902e34a00eebb3720bf2d0063472b008803
|
4
|
+
data.tar.gz: 3b683923efc493c8fa95cca2757bcc00b73206b3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e4ce5a8105ebd1f9a9ee680997c50413cb3a36d2021ff96f991d657b9d381dac0184bb2f6ddfb95117bfbe343ca6cfafe93db68c88e455954d7f5f8c8d64f8ab
|
7
|
+
data.tar.gz: 0cb5a18d0226f7464a122e89496f526a41fa044eddf0fb72df97684e75b0d14bb39d56bca3019841e2686ca905b350293e38a41d11e9db6d8a65373aca03aedc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2001-2015 Aspose Pty Ltd
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Aspose_Pdf_Java_for_Ruby
|
2
|
+
Aspose.Pdf Java for Ruby is a gem that demonstrates / provides the Aspose.Pdf for Java API usage examples in Ruby by using Rjb - Ruby Java Bridge.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
|
6
|
+
Execute following command.
|
7
|
+
|
8
|
+
$ gem install asposepdfjava
|
9
|
+
|
10
|
+
To download Aspose.Pdf for Java API to be used with these examples through RJB, Please navigate to:
|
11
|
+
|
12
|
+
http://www.aspose.com/community/files/72/java-components/aspose.pdf-for-java/
|
13
|
+
|
14
|
+
Note: Create jars folder at root of the gem and copy downloaded Aspose.Pdf for java component into it.
|
15
|
+
|
16
|
+
For most complete documentation of the project, check Aspose.Pdf Java for Ruby confluence wiki link:
|
17
|
+
|
18
|
+
http://www.aspose.com/docs/display/pdfjava/2.+Aspose.Pdf+Java+For+Ruby
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require File.dirname(File.dirname(File.dirname(__FILE__))) + '/lib/asposepdfjava'
|
24
|
+
include Asposepdfjava
|
25
|
+
include Asposepdfjava::HelloWorld
|
26
|
+
initialize_aspose_pdf
|
27
|
+
```
|
28
|
+
Lets understand the above code
|
29
|
+
* The first line makes sure that the aspose pdf is loaded and available
|
30
|
+
* Include the files that are required to access the aspose pdf
|
31
|
+
* Initialize the libraries. The aspose JAVA classes are loaded from the path provided in the aspose.yml file
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'asposepdfjava/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'asposepdfjava'
|
8
|
+
spec.version = Asposepdfjava::VERSION
|
9
|
+
spec.authors = ['Aspose Marketplace']
|
10
|
+
spec.email = ['marketplace@aspose.com']
|
11
|
+
spec.summary = %q{A Ruby gem to work with Aspose.Pdf libraries}
|
12
|
+
spec.description = %q{AsposePdfJava is a Ruby gem that can help working with Aspose.Pdf libraries}
|
13
|
+
spec.homepage = 'https://github.com/asposepdf/Aspose_Pdf_Java/tree/master/Plugins/Aspose_Pdf_Java_for_Ruby'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
|
25
|
+
spec.add_dependency 'rjb', '~> 1.5.2'
|
26
|
+
|
27
|
+
end
|
data/config/aspose.yml
ADDED
data/data/Example.svg
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg
|
3
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
4
|
+
xmlns:cc="http://web.resource.org/cc/"
|
5
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
6
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
8
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
9
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
10
|
+
width="600"
|
11
|
+
height="600"
|
12
|
+
id="svg2"
|
13
|
+
sodipodi:version="0.32"
|
14
|
+
inkscape:version="0.45.1"
|
15
|
+
sodipodi:docname="Example.svg"
|
16
|
+
inkscape:output_extension="org.inkscape.output.svg.inkscape"
|
17
|
+
sodipodi:docbase="/home/gmaxwell"
|
18
|
+
version="1.0">
|
19
|
+
<metadata
|
20
|
+
id="metadata9">
|
21
|
+
<rdf:RDF>
|
22
|
+
<cc:Work
|
23
|
+
rdf:about="">
|
24
|
+
<dc:format>image/svg+xml</dc:format>
|
25
|
+
<dc:type
|
26
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
27
|
+
</cc:Work>
|
28
|
+
</rdf:RDF>
|
29
|
+
</metadata>
|
30
|
+
<sodipodi:namedview
|
31
|
+
inkscape:window-height="620"
|
32
|
+
inkscape:window-width="814"
|
33
|
+
inkscape:pageshadow="2"
|
34
|
+
inkscape:pageopacity="0.0"
|
35
|
+
guidetolerance="10.0"
|
36
|
+
gridtolerance="10.0"
|
37
|
+
objecttolerance="10.0"
|
38
|
+
borderopacity="1.0"
|
39
|
+
bordercolor="#666666"
|
40
|
+
pagecolor="#ffffff"
|
41
|
+
id="base"
|
42
|
+
width="600px"
|
43
|
+
height="600px"
|
44
|
+
inkscape:zoom="0.35974058"
|
45
|
+
inkscape:cx="50"
|
46
|
+
inkscape:cy="519.04966"
|
47
|
+
inkscape:window-x="483"
|
48
|
+
inkscape:window-y="101"
|
49
|
+
inkscape:current-layer="svg2" />
|
50
|
+
<defs
|
51
|
+
id="defs16" />
|
52
|
+
<g
|
53
|
+
id="g2161"
|
54
|
+
transform="matrix(6.3951354,0,0,6.3951354,-22.626246,-7.1082509)">
|
55
|
+
<path
|
56
|
+
nodetypes="ccccccccccccccccccccccccccccccccccccccc"
|
57
|
+
id="flowRoot1882"
|
58
|
+
d="M 36.009766,9.2505083 C 37.739295,9.4211273 38.305879,11.470697 38.052581,12.935049 C 37.346266,16.153899 36.316821,19.51466 35.445405,22.717701 C 36.091666,24.812224 31.712284,24.008877 33.219932,22.315459 C 34.817041,18.411202 36.011404,13.498336 36.009766,9.2505083 z M 36.009766,2.9926958 C 38.210311,1.2242088 40.996268,9.172757 33.911571,6.1534847 C 33.884619,5.7603019 36.096289,3.3869447 36.009766,2.9926958 z M 41.371094,15.871601 C 41.371094,13.66457 41.371094,11.457539 41.371094,9.250508 C 43.180621,9.4257387 43.963014,11.704559 43.286137,13.215517 C 42.859084,15.059792 42.939241,17.3996 44.601487,18.625335 C 46.710544,19.683477 49.38774,17.353112 48.803268,15.118437 C 48.93196,13.406538 48.236292,11.613848 48.968862,9.9690415 C 51.055097,9.6500357 51.500677,12.487155 50.544985,13.844747 C 50.070023,15.309708 50.857452,16.781898 50.672344,18.239432 C 50.279615,19.94056 48.418404,20.00023 47.0225,20.071868 C 45.478489,20.38194 43.516835,20.791368 42.361947,19.38874 C 41.522514,18.444089 41.211274,17.107671 41.371094,15.871601 z M 61.224609,9.5727739 C 60.41978,11.557552 58.100804,10.235616 56.62767,10.571551 C 53.836862,14.393611 60.920038,13.513667 61.8085,17.011648 C 61.85613,18.933747 60.028359,20.587389 58.129091,20.443312 C 56.904487,20.607229 54.609204,20.982393 54.417879,19.267622 C 55.280609,17.508269 57.336359,19.528803 58.633111,18.8463 C 60.403141,17.99081 59.402232,15.555325 57.728781,15.321475 C 56.550115,14.98135 55.091813,15.225439 54.254747,14.112764 C 53.017669,12.881167 53.392132,10.733148 54.736719,9.7413252 C 56.619172,8.3307396 59.170326,8.9535067 61.224609,9.5727739 z M 66.458984,6.1450396 C 65.368126,7.6333334 67.348936,9.9531574 68.987229,9.0948979 C 69.978133,11.042503 66.524641,10.777931 66.473495,12.430992 C 64.443605,16.101814 68.48273,18.623426 67.571657,20.417528 C 65.440858,20.26155 64.324307,17.844452 64.577433,15.919357 C 64.70847,14.408586 65.055107,12.79361 64.322961,11.373941 C 63.786422,9.5475192 64.150419,7.1452655 65.954233,6.1552477 L 66.206043,6.1203323 L 66.458984,6.1450396 L 66.458984,6.1450396 z " />
|
59
|
+
<path
|
60
|
+
nodetypes="ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
|
61
|
+
id="flowRoot1890"
|
62
|
+
d="M 10.867188,44.877953 C 6.2812618,42.124849 5.2205914,52.366268 10.409215,49.892431 C 12.389385,49.295568 14.988045,43.912658 10.867188,44.877953 z M 15.167969,43.987328 C 14.919826,46.33724 16.617756,52.554202 12.298734,50.536918 C 9.8041142,52.312916 6.0580855,52.958674 4.5023123,49.583386 C 2.6350454,45.257322 7.3033103,42.298712 11.046443,43.361059 C 15.247185,41.320786 9.4930286,38.338264 7.1068792,40.322138 C 3.4374421,40.01388 7.406407,37.201407 9.3495087,37.962912 C 12.44212,37.877788 15.556534,40.380131 15.171751,43.648912 L 15.169638,43.83797 L 15.167969,43.987328 z M 30.53125,43.553734 C 29.638794,45.911558 32.49467,50.463872 28.779999,51.070944 C 26.888088,47.702306 30.931621,41.190257 25.58365,40.046147 C 20.73931,40.312798 21.252194,45.910871 22.001439,49.154066 C 21.84253,51.828309 18.790577,51.39256 19.585585,48.673738 C 19.851829,45.693864 18.285332,39.630301 20.986983,38.702911 C 23.508461,40.80889 25.761847,35.731906 28.452459,38.686226 C 29.921454,39.793194 30.827618,41.709992 30.53125,43.553734 z M 38.807,49.770223 C 42.369034,50.768974 44.523344,46.328688 43.700521,43.358983 C 40.402775,35.546453 32.491199,44.344131 38.807,49.770223 z M 39.941406,38.034203 C 52.085872,39.705642 43.204854,59.098342 34.688722,48.642968 C 32.591886,44.778031 34.383109,38.440132 39.291369,38.051827 L 39.941406,38.034203 L 39.941406,38.034203 z M 51.660156,34.624046 C 49.815978,37.850583 54.789459,38.666222 55.83437,39.23566 C 54.140746,40.715733 50.093061,40.12158 51.562461,43.76212 C 51.004096,46.980523 52.486847,50.037723 55.670614,50.54595 C 53.547788,53.782616 48.41793,50.035495 49.349973,46.519692 C 50.339877,43.686471 48.78131,40.671166 48.467256,38.48357 C 51.099926,37.413599 47.886512,33.32283 51.660156,34.624046 z M 69.859375,43.553734 C 68.966918,45.911557 71.822794,50.463872 68.108124,51.070944 C 66.216214,47.702306 70.259746,41.190256 64.911775,40.046145 C 60.222418,40.285904 60.439194,45.757728 61.367942,48.953683 C 60.705448,53.064855 57.788626,49.900134 58.838379,47.289738 C 58.969709,43.381174 59.006437,39.455087 58.607404,35.565714 C 59.356025,31.632413 62.368269,34.68013 61.01352,37.194316 C 60.38417,39.302538 61.469087,40.653476 62.996248,38.474829 C 66.202089,36.826154 70.863269,39.826451 69.859375,43.553734 z M 85.410156,44.374046 C 83.244849,47.905533 76.447085,42.456344 75.976013,47.444052 C 76.913541,51.724548 83.275324,48.726196 84.393639,50.133773 C 82.109855,53.525123 76.421339,51.860111 74.285335,49.01336 C 71.258247,44.729984 74.614013,37.166516 80.254289,37.96756 C 83.286958,38.284495 85.833914,41.310745 85.410156,44.374046 z M 83.253906,43.741234 C 84.431319,39.039614 74.594812,38.687325 76.291886,43.335226 C 78.284783,44.796048 81.032856,43.090943 83.253906,43.741234 z M 96.554688,40.366234 C 93.290612,38.6882 90.622217,42.519635 90.728522,45.492665 C 90.881925,47.333676 92.330286,52.144465 89.028751,50.905988 C 88.95673,46.763963 88.353312,42.447207 89.31721,38.336643 C 91.040471,38.503437 92.207514,40.668181 93.421468,38.208298 C 94.902478,37.44973 97.690944,38.263668 96.554688,40.366234 z " />
|
63
|
+
<path
|
64
|
+
style="fill:#ff0000"
|
65
|
+
nodetypes="ccccccccccccccccccccccccccccccccccccccccccccccccccccc"
|
66
|
+
id="flowRoot1898"
|
67
|
+
d="M 17.026327,63.789847 C 0.7506376,64.058469 13.88279,66.387154 13.113883,69.323258 C 8.0472417,70.287093 3.5936285,63.565714 6.8090451,59.370548 C 8.7591553,55.717791 15.269922,55.198361 16.902068,59.393261 C 17.532581,60.758947 17.628237,62.396589 17.026327,63.789847 z M 15.306463,62.656109 C 18.852566,58.713773 7.6543584,56.609143 10.765803,61.304742 C 12.124789,62.217715 13.961359,61.705342 15.306463,62.656109 z M 31.307931,62.391383 C 27.130518,63.524026 24.669863,68.663004 27.470717,72.229472 C 25.946657,74.052316 24.253697,71.076237 24.857281,69.636909 C 23.737444,67.038428 17.399862,72.254246 19.386636,68.888657 C 23.159719,67.551193 22.398496,63.711301 22.06067,60.848671 C 24.064085,60.375294 24.370376,65.772689 27.167918,63.326048 C 28.350126,62.546369 29.927362,61.067531 31.307931,62.391383 z M 37.66875,70.598623 C 33.467314,66.62264 32.517064,77.972723 37.30626,74.466636 C 38.742523,73.853608 40.55904,70.38932 37.66875,70.598623 z M 41.677321,70.973131 C 42.340669,75.308182 36.926157,78.361257 33.331921,76.223155 C 29.43435,74.893988 30.618698,67.677232 35.003806,68.567885 C 37.137393,70.592854 42.140265,67.002221 37.656192,66.290007 C 35.242233,65.914214 35.166503,62.640757 38.036954,63.926404 C 40.847923,64.744926 43.227838,68.124735 41.677321,70.973131 z M 62.379099,76.647079 C 62.007404,78.560417 61.161437,84.034535 58.890565,82.010019 C 59.769679,79.039958 62.536382,72.229115 56.947899,72.765789 C 53.790416,73.570863 54.908257,80.968388 51.529286,79.496859 C 51.707831,76.559817 55.858125,71.896837 50.8321,70.678504 C 45.898113,69.907818 47.485944,75.735824 45.286883,78.034703 C 42.916393,76.333396 45.470823,71.647155 46.624124,69.414735 C 50.919507,67.906486 63.618534,70.878704 62.379099,76.647079 z M 66.426447,83.84905 C 67.616398,85.777591 62.114624,94.492698 62.351124,90.31711 C 63.791684,86.581961 65.730376,78.000636 67.391891,74.85575 C 71.027815,73.781175 76.383067,75.350289 76.591972,79.751898 C 77.048545,83.793048 73.066803,88.429945 68.842187,86.765936 C 67.624386,86.282034 66.56741,85.195132 66.426447,83.84905 z M 74.086569,81.803435 C 76.851893,78.050524 69.264402,74.310256 67.560734,78.378191 C 65.893402,80.594099 67.255719,83.775746 69.700555,84.718558 C 72.028708,85.902224 73.688639,83.888662 74.086569,81.803435 z M 82.318799,73.124577 C 84.30523,75.487059 81.655015,88.448086 78.247183,87.275736 C 78.991935,82.387828 81.291029,77.949394 82.318799,73.124577 z M 95.001985,87.684695 C 78.726298,87.953319 91.858449,90.281999 91.089542,93.218107 C 86.0229,94.18194 81.569287,87.460562 84.784701,83.265394 C 86.734814,79.612637 93.245582,79.09321 94.877729,83.28811 C 95.508245,84.653796 95.603892,86.291438 95.001985,87.684695 z M 93.282122,86.550957 C 96.828223,82.608621 85.630017,80.503993 88.741461,85.199592 C 90.100447,86.112565 91.937018,85.600192 93.282122,86.550957 z " />
|
68
|
+
</g>
|
69
|
+
</svg>
|
data/data/index.html
ADDED
data/data/input.pdf
ADDED
Binary file
|
data/data/input1.pdf
ADDED
Binary file
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative 'asposepdfjava/version'
|
2
|
+
require_relative 'asposepdfjava/asposepdf'
|
3
|
+
require 'logger'
|
4
|
+
require 'rjb'
|
5
|
+
|
6
|
+
module Asposepdfjava
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :aspose_pdf_config
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize_aspose_pdf
|
13
|
+
aspose_jars_dir = Asposepdfjava.aspose_pdf_config ? Asposepdfjava.aspose_pdf_config['jar_dir'] : nil
|
14
|
+
aspose_license_path = Asposepdfjava.aspose_pdf_config ? Asposepdfjava.aspose_pdf_config['license_path'] : nil
|
15
|
+
jvm_args = Asposepdfjava.aspose_pdf_config ? Asposepdfjava.aspose_pdf_config['jvm_args'] : nil
|
16
|
+
|
17
|
+
load_aspose_jars(aspose_jars_dir, jvm_args)
|
18
|
+
load_aspose_license(aspose_license_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def load_aspose_license(aspose_license_path)
|
22
|
+
if aspose_license_path && File.exist?(aspose_license_path)
|
23
|
+
set_license(File.join(aspose_license_path))
|
24
|
+
else
|
25
|
+
logger = Logger.new(STDOUT)
|
26
|
+
logger.level = Logger::WARN
|
27
|
+
logger.warn('Using the non licensed aspose jar. Please specify path to your aspose license directory in config/aspose.yml file!')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def load_aspose_jars(aspose_jars_dir, jvm_args)
|
32
|
+
if aspose_jars_dir && File.exist?(aspose_jars_dir)
|
33
|
+
jardir = File.join(aspose_jars_dir, '**', '*.jar')
|
34
|
+
else
|
35
|
+
jardir = File.join(File.dirname(File.dirname(__FILE__)), 'jars', '**', '*.jar')
|
36
|
+
end
|
37
|
+
|
38
|
+
if jvm_args
|
39
|
+
args = jvm_args.split(' ') << '-Djava.awt.headless=true'
|
40
|
+
logger = Logger.new(STDOUT)
|
41
|
+
logger.level = Logger::DEBUG
|
42
|
+
logger.debug("JVM args : #{args}")
|
43
|
+
Rjb::load(classpath = Dir.glob(jardir).join(':'), jvmargs=args)
|
44
|
+
else
|
45
|
+
Rjb::load(classpath = Dir.glob(jardir).join(':'), jvmargs=['-Djava.awt.headless=true'])
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def input_file(file)
|
51
|
+
Rjb::import('java.io.FileInputStream').new(file)
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_license(aspose_license_file)
|
55
|
+
begin
|
56
|
+
fstream = input_file(aspose_license_file)
|
57
|
+
license = Rjb::import('com.aspose.api.License').new()
|
58
|
+
license.setLicense(fstream)
|
59
|
+
rescue Exception => ex
|
60
|
+
logger = Logger.new(STDOUT)
|
61
|
+
logger.level = Logger::ERROR
|
62
|
+
logger.error("Could not load the license file : #{ex}")
|
63
|
+
fstream.close() if fstream
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.configure_aspose_pdf config
|
68
|
+
Asposecellsjava.aspose_pdf_config = config
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Asposepdfjava
|
2
|
+
module ConvertPagesToImages
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
6
|
+
|
7
|
+
converter = Rjb::import('com.aspose.pdf.facades.PdfConverter').new
|
8
|
+
converter.bindPdf(data_dir + 'input1.pdf')
|
9
|
+
converter.doConvert()
|
10
|
+
suffix = ".jpg"
|
11
|
+
image_count = 1
|
12
|
+
image_format_internal = Rjb::import('com.aspose.pdf.ImageFormatInternal')
|
13
|
+
while converter.hasNextImage()
|
14
|
+
converter.getNextImage(data_dir + "image#{image_count}#{suffix}", image_format_internal.getJpeg())
|
15
|
+
image_count +=1
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "PDF pages are converted to individual images successfully!"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Asposepdfjava
|
2
|
+
module HtmlToPdf
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
6
|
+
|
7
|
+
htmloptions = Rjb::import('com.aspose.pdf.HtmlLoadOptions').new(data_dir)
|
8
|
+
|
9
|
+
# Load HTML file
|
10
|
+
pdf = Rjb::import('com.aspose.pdf.Document').new(data_dir + "index.html", htmloptions)
|
11
|
+
|
12
|
+
# Save the concatenated output file (the target document)
|
13
|
+
pdf.save(data_dir+ "html.pdf")
|
14
|
+
|
15
|
+
puts "Document has been converted successfully"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Asposepdfjava
|
2
|
+
module PdfToDoc
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
6
|
+
|
7
|
+
# Open the target document
|
8
|
+
pdf = Rjb::import('com.aspose.pdf.Document').new(data_dir + 'input1.pdf')
|
9
|
+
|
10
|
+
# Save the concatenated output file (the target document)
|
11
|
+
pdf.save(data_dir+ "output.doc")
|
12
|
+
|
13
|
+
puts "Document has been converted successfully"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Asposepdfjava
|
2
|
+
module PdfToExcel
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
6
|
+
|
7
|
+
# Open the target document
|
8
|
+
pdf = Rjb::import('com.aspose.pdf.Document').new(data_dir + 'input1.pdf')
|
9
|
+
|
10
|
+
# Instantiate ExcelSave Option object
|
11
|
+
excelsave = Rjb::import('com.aspose.pdf.ExcelSaveOptions').new
|
12
|
+
|
13
|
+
# Save the output to XLS format
|
14
|
+
pdf.save(data_dir + "Converted_Excel.xls", excelsave)
|
15
|
+
|
16
|
+
puts "Document has been converted successfully"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Asposepdfjava
|
2
|
+
module PdfToSvg
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
6
|
+
|
7
|
+
# Open the target document
|
8
|
+
pdf = Rjb::import('com.aspose.pdf.Document').new(data_dir + 'input1.pdf')
|
9
|
+
|
10
|
+
# instantiate an object of SvgSaveOptions
|
11
|
+
save_options = Rjb::import('com.aspose.pdf.SvgSaveOptions').new
|
12
|
+
|
13
|
+
# do not compress SVG image to Zip archive
|
14
|
+
save_options.CompressOutputToZipArchive = false
|
15
|
+
|
16
|
+
# Save the output to XLS format
|
17
|
+
pdf.save(data_dir + "Output.svg", save_options)
|
18
|
+
|
19
|
+
puts "Document has been converted successfully"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Asposepdfjava
|
2
|
+
module SvgToPdf
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
6
|
+
|
7
|
+
# Instantiate LoadOption object using SVG load option
|
8
|
+
options = Rjb::import('com.aspose.pdf.SvgLoadOptions').new
|
9
|
+
|
10
|
+
# Create document object
|
11
|
+
pdf = Rjb::import('com.aspose.pdf.Document').new(data_dir + 'Example.svg', options)
|
12
|
+
|
13
|
+
# Save the output to XLS format
|
14
|
+
pdf.save(data_dir + "SVG.pdf")
|
15
|
+
|
16
|
+
puts "Document has been converted successfully"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Asposepdfjava
|
2
|
+
module AddJavaScript
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
6
|
+
|
7
|
+
# Open a pdf document.
|
8
|
+
doc = Rjb::import('com.aspose.pdf.Document').new(data_dir + "input1.pdf")
|
9
|
+
|
10
|
+
# Adding JavaScript at Document Level
|
11
|
+
# Instantiate JavascriptAction with desried JavaScript statement
|
12
|
+
javaScript = Rjb::import('com.aspose.pdf.JavascriptAction').new("this.print({bUI:true,bSilent:false,bShrinkToFit:true});");
|
13
|
+
|
14
|
+
# Assign JavascriptAction object to desired action of Document
|
15
|
+
doc.setOpenAction(javaScript)
|
16
|
+
|
17
|
+
# Adding JavaScript at Page Level
|
18
|
+
doc.getPages().get_Item(2).getActions().setOnOpen(Rjb::import('com.aspose.pdf.JavascriptAction').new("app.alert('page 2 is opened')"))
|
19
|
+
doc.getPages().get_Item(2).getActions().setOnClose(Rjb::import('com.aspose.pdf.JavascriptAction').new("app.alert('page 2 is closed')"))
|
20
|
+
|
21
|
+
# Save PDF Document
|
22
|
+
doc.save(data_dir + "JavaScript-Added.pdf")
|
23
|
+
|
24
|
+
puts "Added JavaScript Successfully, please check the output file."
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Asposepdfjava
|
2
|
+
module AddLayers
|
3
|
+
def initialize()
|
4
|
+
# The path to the documents directory.
|
5
|
+
data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
|
6
|
+
|
7
|
+
doc = Rjb::import('com.aspose.pdf.Document').new
|
8
|
+
page = doc.getPages().add()
|
9
|
+
|
10
|
+
operator = Rjb::import('com.aspose.pdf.Operator')
|
11
|
+
|
12
|
+
layer = Rjb::import('com.aspose.pdf.Layer').new("oc1", "Red Line")
|
13
|
+
layer.getContents().add(operator.SetRGBColorStroke(1, 0, 0))
|
14
|
+
layer.getContents().add(operator.MoveTo(500, 700))
|
15
|
+
layer.getContents().add(operator.LineTo(400, 700))
|
16
|
+
layer.getContents().add(operator.Stroke())
|
17
|
+
page.setLayers(Rjb::import('java.util.ArrayList').new)
|
18
|
+
page.getLayers().add(layer)
|
19
|
+
|
20
|
+
layer = Rjb::import('com.aspose.pdf.Layer').new("oc2", "Green Line")
|
21
|
+
layer.getContents().add(operator.SetRGBColorStroke(0, 1, 0))
|
22
|
+
layer.getContents().add(operator.MoveTo(500, 750))
|
23
|
+
layer.getContents().add(operator.LineTo(400, 750))
|
24
|
+
layer.getContents().add(operator.Stroke())
|
25
|
+
page.getLayers().add(layer)
|
26
|
+
|
27
|
+
layer = Rjb::import('com.aspose.pdf.Layer').new("oc3", "Blue Line")
|
28
|
+
layer.getContents().add(operator.SetRGBColorStroke(0, 0, 1))
|
29
|
+
layer.getContents().add(operator.MoveTo(500, 800))
|
30
|
+
layer.getContents().add(operator.LineTo(400, 800))
|
31
|
+
layer.getContents().add(operator.Stroke())
|
32
|
+
page.getLayers().add(layer)
|
33
|
+
|
34
|
+
# Save PDF Document
|
35
|
+
doc.save(data_dir + "Layers-Added.pdf")
|
36
|
+
|
37
|
+
puts "Added Layers Successfully, please check the output file."
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|