Revision 7827

View differences:

org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2

  
3
    <modelVersion>4.0.0</modelVersion>
4
    <parent>
5
        <groupId>org.gvsig</groupId>
6
        <artifactId>org.gvsig.desktop</artifactId>
7
        <version>2.0.406</version>
8
    </parent>
9
    <artifactId>org.gvsig.pdf</artifactId>
10
    <version>1.0.117</version>
11
    <packaging>pom</packaging>
12
    <name>${project.artifactId}</name>
13

  
14
    <url>https://devel.gvsig.org/svn/gvsig-projects-pool/${project.artifactId}/trunk/${project.artifactId}</url>
15
  
16
    <distributionManagement>
17
        <site>
18
            <id>gvsig-repository</id>
19
            <url>dav:https://devel.gvsig.org/sites/${project.artifactId}/${project.version}</url>
20
        </site>
21
    </distributionManagement>
22
  
23
    <scm>
24
        <connection>scm:svn:https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117</connection>
25
        <developerConnection>scm:svn:https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117</developerConnection>
26
        <url>https://devel.gvsig.org/svn/gvsig-projects-pool/org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117</url>
27
    </scm>
28

  
29
    <developers>
30
        <developer>
31
            <id>jjdelcerro</id>
32
            <name>Joaquin Jose del Cerro</name>
33
            <email>jjdelcerro@gvsig.com</email>
34
            <roles>
35
                <role>Architect</role>
36
                <role>Developer</role>
37
            </roles>
38
        </developer>
39
    </developers>
40

  
41
    <repositories>
42
        <repository>
43
            <id>gvsig-public-http-repository</id>
44
            <name>gvSIG maven public HTTP repository</name>
45
            <url>http://devel.gvsig.org/m2repo/j2se</url>
46
            <releases>
47
                <enabled>true</enabled>
48
                <updatePolicy>daily</updatePolicy>
49
                <checksumPolicy>warn</checksumPolicy>
50
            </releases>
51
            <snapshots>
52
                <enabled>true</enabled>
53
                <updatePolicy>daily</updatePolicy>
54
                <checksumPolicy>warn</checksumPolicy>
55
            </snapshots>
56
        </repository>
57
<!--        <repository>
58
            
59
            https://stackoverflow.com/questions/26993105/i-get-an-error-downloading-javax-media-jai-core1-1-3-from-maven-central
60
            
61
            <id>geotoolkit-org</id>
62
            <name>geotoolkit.org repository</name>
63
            <url>http://maven.geotoolkit.org/</url>
64
        </repository>-->
65
    </repositories>
66

  
67
    <build>
68
        <plugins>
69
            <plugin>
70
                <groupId>org.apache.maven.plugins</groupId>
71
                <artifactId>maven-release-plugin</artifactId>
72
                <configuration>
73
                    <tagBase>https://devel.gvsig.org/svn/gvsig-projects-pool/${project.artifactId}/tags</tagBase>
74
                    <goal>deploy</goal>
75
                </configuration>
76
            </plugin>
77
        </plugins>
78
    </build>
79

  
80

  
81
    <dependencyManagement>
82
        <dependencies>
83
            <dependency>
84
                <groupId>org.gvsig</groupId>
85
                <artifactId>org.gvsig.pdf.app.mainplugin</artifactId>
86
                <version>1.0.117</version>
87
            </dependency>
88
            <dependency>
89
                <groupId>org.gvsig</groupId>
90
                <artifactId>org.gvsig.pdf.lib.api</artifactId>
91
                <version>1.0.117</version>
92
            </dependency>
93
            <dependency>
94
                <groupId>org.gvsig</groupId>
95
                <artifactId>org.gvsig.pdf.lib.impl</artifactId>
96
                <version>1.0.117</version>
97
            </dependency>
98
            <dependency>
99
                <groupId>org.gvsig</groupId>
100
                <artifactId>org.gvsig.pdf.swing.api</artifactId>
101
                <version>1.0.117</version>
102
            </dependency>
103
            <dependency>
104
                <groupId>org.gvsig</groupId>
105
                <artifactId>org.gvsig.pdf.swing.impl</artifactId>
106
                <version>1.0.117</version>
107
            </dependency>
108
            <dependency>
109
                <groupId>org.icepdf.os</groupId>
110
                <artifactId>icepdf-core</artifactId>
111
                <version>6.2.2</version>
112
                <exclusions>
113
                    <exclusion>
114
                        <groupId>batik</groupId>
115
                        <artifactId>batik-awt-util</artifactId>
116
                    </exclusion>        
117
                    <exclusion>
118
                        <groupId>batik</groupId>
119
                        <artifactId>batik-dom</artifactId>
120
                    </exclusion>        
121
                    <exclusion>
122
                        <groupId>batik</groupId>
123
                        <artifactId>batik-svg-dom</artifactId>
124
                    </exclusion>        
125
                    <exclusion>
126
                        <groupId>batik</groupId>
127
                        <artifactId>batik-svggen</artifactId>
128
                    </exclusion>        
129
                    <exclusion>
130
                        <groupId>batik</groupId>
131
                        <artifactId>batik-util</artifactId>
132
                    </exclusion>        
133
                    <exclusion>
134
                        <groupId>batik</groupId>
135
                        <artifactId>batik-xml</artifactId>
136
                    </exclusion>        
137
                    <!--
138
                    <exclusion>
139
                        <groupId>javax.media</groupId>
140
                        <artifactId>jai_core</artifactId>
141
                    </exclusion>        
142
                    -->
143
                </exclusions>
144
            </dependency>
145
	    <dependency>
146
                <groupId>org.icepdf.os</groupId>
147
                <artifactId>icepdf-viewer</artifactId>
148
                <version>6.2.2</version>
149
                <exclusions>
150
                    <exclusion>
151
                        <groupId>batik</groupId>
152
                        <artifactId>batik-awt-util</artifactId>
153
                    </exclusion>        
154
                    <exclusion>
155
                        <groupId>batik</groupId>
156
                        <artifactId>batik-dom</artifactId>
157
                    </exclusion>        
158
                    <exclusion>
159
                        <groupId>batik</groupId>
160
                        <artifactId>batik-svg-dom</artifactId>
161
                    </exclusion>        
162
                    <exclusion>
163
                        <groupId>batik</groupId>
164
                        <artifactId>batik-svggen</artifactId>
165
                    </exclusion>        
166
                    <exclusion>
167
                        <groupId>batik</groupId>
168
                        <artifactId>batik-util</artifactId>
169
                    </exclusion>        
170
                    <exclusion>
171
                        <groupId>batik</groupId>
172
                        <artifactId>batik-xml</artifactId>
173
                    </exclusion>  
174
                    <!--      
175
                    <exclusion>
176
                        <groupId>javax.media</groupId>
177
                        <artifactId>jai_core</artifactId>
178
                    </exclusion>        
179
                    -->
180
                </exclusions>
181
            </dependency>
182
            <!--
183
            <dependency>
184
              <groupId>com.cosium.jai-imageio</groupId>
185
              <artifactId>jai-imageio-core</artifactId>
186
              <version>1.3.0.1</version>
187
            </dependency>
188
            -->
189
            <dependency>
190
              <groupId>org.bouncycastle</groupId>
191
              <artifactId>bcpkix-jdk15on</artifactId>
192
              <version>1.54</version>
193
            </dependency>
194
            <dependency>
195
              <groupId>org.bouncycastle</groupId>
196
              <artifactId>bcprov-jdk15on</artifactId>
197
              <version>1.54</version>
198
            </dependency>
199
            <dependency>
200
              <groupId>org.bouncycastle</groupId>
201
              <artifactId>bcprov-ext-jdk15on</artifactId>
202
              <version>1.54</version>
203
            </dependency>
204
<!--            <dependency>
205
                <groupId>com.itextpdf</groupId>
206
                <artifactId>itextpdf</artifactId>
207
                <version>5.5.8</version>
208
            </dependency>-->
209
            <dependency>
210
                <groupId>org.apache.pdfbox</groupId>
211
                <artifactId>pdfbox</artifactId>
212
                <version>2.0.16</version>
213
            </dependency>
214
            <dependency>
215
                <groupId>org.apache.pdfbox</groupId>
216
                <artifactId>fontbox</artifactId>
217
                <version>2.0.16</version>
218
            </dependency>
219
            <dependency>
220
                <groupId>de.rototor.pdfbox</groupId>
221
                <artifactId>graphics2d</artifactId>
222
                <version>0.24</version>
223
            </dependency>
224
            <dependency>
225
                <groupId>org.apache.tika</groupId>
226
                <artifactId>tika-core</artifactId>
227
                <version>1.12</version>
228
            </dependency>
229
            <dependency>
230
              <groupId>org.apache.pdfbox</groupId>
231
              <artifactId>xmpbox</artifactId>
232
              <version>2.0.16</version>
233
              <type>bundle</type>
234
            </dependency>
235
        
236
            <dependency>
237
              <groupId>com.openhtmltopdf</groupId>
238
              <artifactId>openhtmltopdf-pdfbox</artifactId>
239
              <version>1.0.10</version>
240
            </dependency>
241
            <dependency>
242
              <groupId>com.openhtmltopdf</groupId>
243
              <artifactId>openhtmltopdf-objects</artifactId>
244
              <version>1.0.10</version>
245
            </dependency>
246
            <dependency>
247
              <groupId>com.openhtmltopdf</groupId>
248
              <artifactId>openhtmltopdf-core</artifactId>
249
              <version>1.0.10</version>
250
            </dependency>
251
            <dependency>
252
              <groupId>com.openhtmltopdf</groupId>
253
              <artifactId>openhtmltopdf-java2d</artifactId>
254
              <version>1.0.10</version>
255
            </dependency>
256
            <dependency>
257
              <groupId>com.openhtmltopdf</groupId>
258
              <artifactId>openhtmltopdf-slf4j</artifactId>
259
              <version>1.0.10</version>
260
            </dependency>
261
            <dependency>
262
              <groupId>com.openhtmltopdf</groupId>
263
              <artifactId>openhtmltopdf-rtl-support</artifactId>
264
              <version>1.0.10</version>
265
            </dependency>
266
            <dependency>
267
              <groupId>com.openhtmltopdf</groupId>
268
              <artifactId>openhtmltopdf-svg-support</artifactId>
269
              <version>1.0.10</version>
270
            </dependency>
271
            
272
        </dependencies>
273
    </dependencyManagement>
274

  
275
    <modules>
276
        <module>org.gvsig.pdf.lib</module>
277
        <module>org.gvsig.pdf.swing</module>
278
        <module>org.gvsig.pdf.app</module>
279
    </modules>
280

  
281
</project>
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.pdf</artifactId>
6
    <version>1.0.117</version>
7
  </parent>
8
  <artifactId>org.gvsig.pdf.app</artifactId>
9
  <packaging>pom</packaging>
10
  <name>${project.artifactId}</name>
11
  <modules>
12
  	<module>org.gvsig.pdf.app.mainplugin</module>
13
  </modules>
14
</project>
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/buildNumber.properties
1
#Sun Feb 19 22:26:50 CET 2023
2
buildNumber=120
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/src/main/resources-plugin/i18n/text.properties
1
#Translations for language [es]
2
#Thu Nov 20 10:10:09 CET 2014
3
_Open=Abrir
4
_Print_form=Imprimir formulario
5
_Simple_form=Formulario sencillo
6
_Reports=Informes
7
_Copy_template=Copiar plantilla
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
1
#Translations for language [en]
2
#Thu Nov 20 10:10:15 CET 2014
3
_Open=Open
4
_Print_form=Print form
5
_Simple_form=Simple form
6
_Reports=Reports
7
_Copy_template=Copy template
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2014 gvSIG
3
  Association. This program is free software; you can redistribute it and/or modify
4
  it under the terms of the GNU General Public License as published by the Free Software
5
  Foundation; either version 3 of the License, or (at your option) any later version.
6
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
7
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8
  PURPOSE. See the GNU General Public License for more details. You should have received
9
  a copy of the GNU General Public License along with this program; if not, write to
10
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
11
  USA. For any additional information, do not hesitate to contact us at info AT gvsig.com,
12
  or visit our website www.gvsig.com. -->
13
<plugin-config>
14
  <depends plugin-name="org.gvsig.app.mainplugin" />
15
  <resourceBundle name="text" />
16
  <libraries library-dir="lib" />
17
  <extensions>
18

  
19

  
20
    <extension class-name="org.gvsig.pdf.app.mainplugin.PDFExtension"
21
      description="" active="true" priority="1">
22
    </extension>
23

  
24

  
25
  </extensions>
26
</plugin-config>
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/src/main/resources-plugin/report_template_top.txt
1
<html>
2
<!--        
3
Recurso: "$$TABLENAME$$.dynamictext"
4
(this contents)
5

  
6
Recurso: "$$TABLENAME$$.report"
7
{
8
  "type" : "dynamictext",
9
  "name" : "Form $$TABLENAME$$",
10
  "templateName" : "dynamictext"
11
}
12
-->     
13
  <head>
14
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
15
    <title><%=$REPORT.getName()%></title>
16
  <style>
17
* { 
18
  font-family: "Sans"; 
19
}
20
@page {
21
  size: A4 portrait;
22
  margin-top: 15mm;
23
  margin-bottom: 15mm;
24

  
25
  @top-center {
26
    content: element(top-center);
27
    padding: 1mm; border: 1px solid white; 
28
    vertical-align: bottom;
29
    /* background: #eeeeee; */
30
  }
31

  
32
  @bottom-center {
33
    content: element(bottom-center);
34
    padding: 1mm; border: 1px solid white; 
35
    vertical-align: top;
36
    /* background: #eeeeee; */
37
  }
38
}
39

  
40
.top-center {
41
  position: running(top-center);
42
}
43
.bottom-center { 
44
  position: running(bottom-center);
45
}
46
.page-number::after  {   
47
  content: counter(page);
48
}
49

  
50
.vspace1 {
51
  height: 4px;
52
}
53

  
54
</style>
55
</head>
56
<body>
57
    <%
58
    ROWCOUNT := 1;
59
    FOR ROW in $ROWS
60
    LOOP
61
        IF ROWCOUNT > 1 THEN
62
            %>
63
    <p style="page-break-after: always;">&nbsp;</p>
64
            <%
65
        END IF;
66
        ROWCOUNT := ROWCOUNT + 1;
67
    %>
68
    <div class="top-center">
69
        <table width="100%" cellspacing="0" cellpadding="0" border="0">
70
           <tr>
71
              <td><%=$REPORT.getName()%></td>
72
              <td style="text-align: right; font-size: xx-small">Page <span class="page-number"/></td>
73
           </tr>
74
        </table>
75
    </div>
76
    <div class="bottom-center">
77
        <hr/>
78
        <table width="100%" cellspacing="0" cellpadding="0" border="0">
79
           <tr>
80
              <td><%=CURRENT_DATE()%></td>
81
              <td style="text-align: right; font-size: xx-small">Page <span class="page-number"/></td>
82
           </tr>
83
        </table>
84
    </div>
85

  
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/src/main/resources-plugin/report_template_bottom.txt
1

  
2
    <%
3
    END LOOP;
4
    %>
5
<!--
6
    To include embeded images:
7
    <img src="data:image/<%=simpleimage.getFormatName()%>;base64,<%=simpleimage.toStringBase64()%>>
8
-->
9
  </body>
10
</html>
11

  
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<!--
2

  
3
    gvSIG. Desktop Geographic Information System.
4

  
5
    Copyright (C) 2007-2013 gvSIG Association.
6

  
7
    This program is free software; you can redistribute it and/or
8
    modify it under the terms of the GNU General Public License
9
    as published by the Free Software Foundation; either version 3
10
    of the License, or (at your option) any later version.
11

  
12
    This program is distributed in the hope that it will be useful,
13
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
    GNU General Public License for more details.
16

  
17
    You should have received a copy of the GNU General Public License
18
    along with this program; if not, write to the Free Software
19
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
    MA  02110-1301, USA.
21

  
22
    For any additional information, do not hesitate to contact us
23
    at info AT gvsig.com, or visit our website www.gvsig.com.
24

  
25
-->
26
<assembly>
27
    <id>gvsig-plugin-package</id>
28
    <formats>
29
        <format>zip</format>
30
    </formats>
31
    <baseDirectory>${project.artifactId}</baseDirectory>
32
    <includeBaseDirectory>true</includeBaseDirectory>
33
    <files>
34
        <file>
35
            <source>target/${project.artifactId}-${project.version}.jar</source>
36
            <outputDirectory>lib</outputDirectory>
37
        </file>
38
        <file>
39
            <source>target/package.info</source>
40
        </file>
41
    </files>
42

  
43
    <fileSets>
44
        <fileSet>
45
            <directory>src/main/resources-plugin</directory>
46
            <outputDirectory>.</outputDirectory>
47
        </fileSet>
48
    </fileSets>
49

  
50

  
51
    <dependencySets>
52
        <dependencySet>
53
            <useProjectArtifact>false</useProjectArtifact>
54
            <useTransitiveDependencies>false</useTransitiveDependencies>
55
            <outputDirectory>lib</outputDirectory>
56
            <includes>
57
                <include>org.gvsig:org.gvsig.pdf.lib.api</include>
58
                <include>org.gvsig:org.gvsig.pdf.lib.impl</include>
59
                <include>org.gvsig:org.gvsig.pdf.swing.api</include>
60
                <include>org.gvsig:org.gvsig.pdf.swing.impl</include>
61
                <include>org.icepdf.os:icepdf-viewer</include>
62
                <include>org.icepdf.os:icepdf-core</include>
63

  
64
                <include>javax.media:jai_core</include>
65
                <include>org.bouncycastle:bcpkix-jdk15on</include>
66
                
67
                <include>org.apache.pdfbox:pdfbox</include>
68
                <include>de.rototor.pdfbox:graphics2d</include>
69
                <include>org.apache.pdfbox:xmpbox</include>
70
                <include>org.apache.pdfbox:fontbox</include>
71
                <include>org.apache.tika:tika-core</include>
72

  
73
                <include>com.openhtmltopdf:openhtmltopdf-objects</include>
74
                <include>com.openhtmltopdf:openhtmltopdf-core</include>
75
                <include>com.openhtmltopdf:openhtmltopdf-java2d</include>
76
                <include>com.openhtmltopdf:openhtmltopdf-slf4j</include>
77
                <include>com.openhtmltopdf:openhtmltopdf-rtl-support</include>
78
                <include>com.openhtmltopdf:openhtmltopdf-svg-support</include>
79
                <include>com.openhtmltopdf:openhtmltopdf-pdfbox</include>
80
                
81
                <!--
82
                <include>com.ibm.icu:icu4j</include>
83
                <include>org.apache.xmlgraphics:batik-transcoder</include>
84
                <include>org.apache.xmlgraphics:batik-shared-resources</include>
85
                <include>org.apache.xmlgraphics:batik-svggen</include>
86
                <include>org.apache.xmlgraphics:batik-codec</include>
87
                <include>org.apache.xmlgraphics:xmlgraphics-commons</include>
88
                -->
89
                
90
                
91
                
92
                <!--
93
                Estos dos jars ya se los esta llevando andami
94
                <include>org.bouncycastle:bcprov-jdk15on</include>
95
                <include>org.bouncycastle:bcprov-ext-jdk15on</include>
96
                -->
97
            </includes>
98
        </dependencySet>
99
    </dependencySets>
100

  
101
</assembly>
102

  
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/src/main/java/org/gvsig/pdf/app/mainplugin/PDFExtension.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.pdf.app.mainplugin;
25

  
26
import org.gvsig.andami.plugins.Extension;
27
import org.gvsig.pdf.app.mainplugin.StoreReportsAction.ReportsActionFactory;
28

  
29
/**
30
 *
31
 * @author jjdelcerro
32
 */
33
public class PDFExtension extends Extension {
34

  
35
    @Override
36
    public void initialize() {
37

  
38
    }
39

  
40
    @Override
41
    public void postInitialize() {
42
        ReportsActionFactory.selfRegister();
43
    }
44

  
45
    @Override
46
    public void execute(String action) {
47

  
48
    }
49

  
50
    @Override
51
    public boolean isEnabled() {
52

  
53
        return true;
54
    }
55

  
56
    @Override
57
    public boolean isVisible() {
58
        return true;
59
    }
60
    
61
}
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/src/main/java/org/gvsig/pdf/app/mainplugin/StoreReportsAction.java
1
package org.gvsig.pdf.app.mainplugin;
2

  
3
import java.awt.Dimension;
4
import java.awt.event.ActionEvent;
5
import java.io.IOException;
6
import java.io.InputStream;
7
import java.net.URL;
8
import java.nio.charset.StandardCharsets;
9
import java.util.ArrayList;
10
import java.util.List;
11
import java.util.logging.Level;
12
import javax.json.Json;
13
import javax.json.JsonObject;
14
import javax.swing.AbstractAction;
15
import javax.swing.Action;
16
import javax.swing.JComponent;
17
import javax.swing.JMenuItem;
18
import javax.swing.JOptionPane;
19
import javax.swing.JPopupMenu;
20
import org.apache.commons.io.IOUtils;
21
import org.apache.commons.lang3.StringUtils;
22
import org.apache.commons.text.StringEscapeUtils;
23
import org.gvsig.app.ApplicationLocator;
24
import org.gvsig.app.project.DocumentsContainerNotification;
25
import org.gvsig.app.project.Project;
26
import org.gvsig.featureform.swing.JFeaturesForm;
27
import org.gvsig.fmap.dal.DataStore;
28
import org.gvsig.fmap.dal.feature.FeatureQuery;
29
import org.gvsig.fmap.dal.feature.FeatureSelection;
30
import org.gvsig.fmap.dal.feature.FeatureStore;
31
import org.gvsig.fmap.dal.swing.DALSwingLocator;
32
import org.gvsig.fmap.dal.swing.DataSwingManager;
33
import org.gvsig.tools.ToolsLocator;
34
import org.gvsig.tools.i18n.I18nManager;
35
import org.gvsig.tools.observer.Observable;
36
import org.gvsig.tools.swing.api.ToolsSwingLocator;
37
import org.gvsig.tools.swing.icontheme.IconTheme;
38
import org.gvsig.tools.resourcesstorage.ResourcesStorage;
39
import org.gvsig.tools.resourcesstorage.ResourcesStorage.Resource;
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42
import org.gvsig.fmap.dal.swing.DALActionFactory;
43
import org.gvsig.fmap.dal.swing.DALActionFactory.DALActionContext;
44
import org.gvsig.pdf.lib.api.PDFDocument;
45
import org.gvsig.pdf.lib.api.PDFLocator;
46
import org.gvsig.pdf.lib.api.PDFManager;
47
import org.gvsig.pdf.swing.api.DynamicTextReport;
48
import org.gvsig.pdf.swing.api.PDFSwingLocator;
49
import org.gvsig.pdf.swing.api.PDFSwingManager;
50
import org.gvsig.pdf.swing.api.PDFViewer;
51
import org.gvsig.tools.dispose.DisposeUtils;
52
import org.gvsig.tools.dynform.DynFormDefinition;
53
import org.gvsig.tools.dynform.DynFormFieldDefinition;
54
import org.gvsig.tools.dynform.JDynForm;
55
import org.gvsig.tools.dynform.JDynFormField;
56
import org.gvsig.tools.swing.api.ToolsSwingUtils;
57
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
58

  
59
/**
60
 *
61
 * @author jjdelcerro
62
 */
63
@SuppressWarnings("UseSpecificCatch")
64
public class StoreReportsAction
65
        extends AbstractAction {
66

  
67
    public static String ACTION_NAME = "Reports";
68

  
69
    public static class ReportsActionFactory implements DALActionFactory {
70

  
71
        @Override
72
        public String getName() {
73
            return ACTION_NAME;
74
        }
75

  
76
        @Override
77
        public Action createAction(DALActionContext context) {
78
            return new StoreReportsAction(context);
79
        }
80

  
81
        @Override
82
        public boolean isApplicable(Object... args) {
83
            return true;
84
        }
85

  
86
        public static void selfRegister() {
87
            DataSwingManager dalSwingManager = DALSwingLocator.getSwingManager();
88
            dalSwingManager.registerStoreAction(new ReportsActionFactory());
89
            String[][] iconNames = new String[][]{
90
                new String[]{"Report", "report-select-reports"}
91
            };
92
            IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent();
93
            for (String[] icon : iconNames) {
94
                URL url = StoreReportsAction.class.getResource("/images/report/" + icon[1] + ".png");
95
                theme.registerDefault("Report", icon[0], icon[1], null, url);
96
            }
97
        }
98

  
99
    }
100

  
101
    private static final Logger LOGGER = LoggerFactory.getLogger(StoreReportsAction.class);
102

  
103
    private final DALActionContext context;
104

  
105
    @SuppressWarnings("OverridableMethodCallInConstructor")
106
    public StoreReportsAction(DALActionContext context) {
107
        this.context = context;
108
        I18nManager i18n = ToolsLocator.getI18nManager();
109
        this.putValue(
110
                Action.ACTION_COMMAND_KEY,
111
                ACTION_NAME
112
        );
113
        this.putValue(
114
                Action.SHORT_DESCRIPTION,
115
                i18n.getTranslation("_Reports")
116
        );
117
        this.putValue(
118
                Action.SMALL_ICON,
119
                ToolsSwingLocator.getIconThemeManager().getCurrent().get("report-select-reports")
120
        );
121
        Project project = ApplicationLocator.getProjectManager().getCurrentProject();
122
        project.addObserver((Observable observable, Object notification) -> {
123
            if (notification instanceof DocumentsContainerNotification) {
124
                DocumentsContainerNotification n = (DocumentsContainerNotification) notification;
125
                switch (n.getNotificationType()) {
126
                    case DocumentsContainerNotification.AFTER_ADD_DOCUMENT:
127
                    case DocumentsContainerNotification.AFTER_REMOVE_DOCUMENT:
128
                        updateEnabled();
129
                }
130
            }
131
        });
132
        updateEnabled();
133
    }
134

  
135
    private List<JsonObject> getReports(Project project, FeatureStore store) {
136
        List<JsonObject> reports = new ArrayList<>();
137
        ResourcesStorage resources = null;
138
        try {
139
            resources = store.getResourcesStorage();
140
            if (resources != null) {
141
                List<Resource> reportsResources = resources.getResources("report");
142
                if (reportsResources != null && !reportsResources.isEmpty()) {
143
                    for (Resource resource : reportsResources) {
144
                        InputStream is = null;
145
                        try {
146
                            is = resource.asInputStream();
147
                            JsonObject json = Json.createReader(is).readObject();
148
                            String type = json.getString("type", "jasper").trim().toLowerCase();
149
                            switch (type) {
150
                                case "dynamictext":
151
                                    reports.add(json);
152
                                    break;
153
                            }
154
                        } catch (Exception ex) {
155
                            LOGGER.warn("Can't load report form resource (" + resource.getURL() + ")", ex);
156
                        } finally {
157
                            IOUtils.closeQuietly(is);
158
                        }
159
                    }
160
                }
161
            }
162
        } finally {
163
            DisposeUtils.disposeQuietly(resources);
164
        }
165
        if (reports.isEmpty()) {
166
            return null;
167
        }
168
        return reports;
169
    }
170

  
171
    private void updateEnabled() {
172
        Project project = ApplicationLocator.getProjectManager().getCurrentProject();
173
        DataStore store = this.context.getStore();
174
        if (!(store instanceof FeatureStore)) {
175
            return;
176
        }
177
        List<JsonObject> reports = this.getReports(project, (FeatureStore) store);
178
        if (reports == null || reports.isEmpty()) {
179
            this.setEnabled(false);
180
        } else {
181
            this.setEnabled(true);
182
        }
183
    }
184

  
185
    @Override
186
    public void actionPerformed(ActionEvent e) {
187
        try {
188
            this.setEnabled(false);
189
            DataStore store = this.context.getStore();
190
            if (!(store instanceof FeatureStore)) {
191
                return;
192
            }
193
            boolean needseparator = false;
194
            JPopupMenu popup = new JPopupMenu();
195
            Project project = ApplicationLocator.getProjectManager().getCurrentProject();
196
            List<JsonObject> reports = this.getReports(project, (FeatureStore) store);
197
            if (reports != null && !reports.isEmpty()) {
198
                for (JsonObject json : reports) {
199
                    popup.add(this.createItem(
200
                            (FeatureStore) store,
201
                            this.context.getQuery(),
202
                            this.context.getSelecteds(),
203
                            json
204
                    )
205
                    );
206
                    needseparator = true;
207
                }
208
            }
209
            JFeaturesForm featuresForm = (JFeaturesForm) this.context.get("featuresform");
210
            if (featuresForm != null) {
211
                I18nManager i18n = ToolsLocator.getI18nManager();
212
                JMenuItem item = new JMenuItem(i18n.getTranslation("_Simple_form"));
213
                item.addActionListener((ActionEvent ae) -> {
214
                    doShowSimpleForm(featuresForm);
215
                });
216
                if (needseparator) {
217
                    popup.addSeparator();
218
                }
219
                popup.add(item);
220
                if ((e.getModifiers() & ActionEvent.SHIFT_MASK) == ActionEvent.SHIFT_MASK) {
221
                    item = new JMenuItem(i18n.getTranslation("_Copy_template"));
222
                    item.addActionListener((ActionEvent ae) -> {
223
                        doCopyTemplate(featuresForm);
224
                    });
225
                    popup.add(item);
226
                }
227
            }
228
            JComponent button = this.context.getActionButton(ACTION_NAME);
229
            popup.show(button, 0, button.getHeight());
230
        } catch (Exception ex) {
231
            LOGGER.warn("Can't show form", ex);
232
        } finally {
233
            this.setEnabled(true);
234
        }
235
    }
236

  
237
    private JMenuItem createItem(FeatureStore store, FeatureQuery query, FeatureSelection selecteds, final JsonObject json) {
238

  
239
        JMenuItem item = null;
240
        String type = json.getString("type", "jasper").trim().toLowerCase();
241
        switch (type) {
242
            case "dynamictext":
243
                PDFSwingManager pdfSwingManager = PDFSwingLocator.getPDFSwingManager();
244
                DynamicTextReport dtreport = pdfSwingManager.createDynamicTextReport(store, query, selecteds, json);
245
                item = new JMenuItem(dtreport.getName());
246
                item.addActionListener((ActionEvent e) -> {
247
                    dtreport.show();
248
                });
249
                item.setEnabled(dtreport.isValid());
250
                break;
251
        }
252
        return item;
253
    }
254

  
255
    private void doShowSimpleForm(JFeaturesForm featuresForm) {
256
        try {
257
            PDFManager pdfManager = PDFLocator.getPDFManager();
258
            PDFSwingManager pdfSwingManager = PDFSwingLocator.getPDFSwingManager();
259
            WindowManager windowManager = ToolsSwingLocator.getWindowManager();
260

  
261
            this.setEnabled(false);
262

  
263
            JDynForm form = featuresForm.getFormset().getForm();
264
            String html = form.toHtml();
265

  
266
            PDFDocument pdfdoc = pdfManager.createPDFDocument(html);
267
            if (pdfdoc == null) {
268
                // Mensaje al usuario?
269
                return;
270
            }
271
            PDFViewer viewer = pdfSwingManager.createPDFViewer();
272
            viewer.put(pdfdoc);
273
            viewer.setMode(PDFViewer.MODE_LIGHT);
274

  
275
            JComponent comp = viewer.asJComponent();
276
            Dimension size = ToolsSwingUtils.ensureRowsCols(comp.getPreferredSize(), 20, 100, 40, 150);
277
            comp.setSize(size);
278

  
279
            String title = "PDF: " + form.getDefinition().getLabel();
280
            windowManager.showWindow(
281
                    comp,
282
                    title,
283
                    WindowManager.MODE.WINDOW
284
            );
285
        } catch (Exception ex) {
286
            LOGGER.warn("Can't show form", ex);
287
        } finally {
288
            this.setEnabled(true);
289
        }
290
    }
291

  
292
    private void doCopyTemplate(JFeaturesForm featuresForm) {
293
        try {
294
            I18nManager i18n = ToolsLocator.getI18nManager();
295
            JDynForm form = featuresForm.getFormset().getForm();
296
            DynFormDefinition formdef = form.getDefinition();
297
            FeatureStore store = featuresForm.getFeatureStore();
298
            String tableName = store.getName();
299
            List<String> groups = formdef.getGroups();
300

  
301
            String template_top = StringUtils.join(
302
                    IOUtils.readLines(
303
                            this.getClass().getResourceAsStream("/report_template_top.txt"),
304
                            StandardCharsets.UTF_8),
305
                    "\n"
306
            );
307
            String template_bottom = StringUtils.join(
308
                    IOUtils.readLines(
309
                            this.getClass().getResourceAsStream("/report_template_bottom.txt"),
310
                            StandardCharsets.UTF_8),
311
                    "\n"
312
            );
313
            template_top = StringUtils.replace(template_top, "$$TABLENAME$$", tableName);
314
            template_bottom = StringUtils.replace(template_bottom, "$$TABLENAME$$", tableName);
315

  
316
            StringBuilder builder = new StringBuilder();
317
            builder.append(template_top);
318
            builder.append("<table style=\"border: none;\" cellspacing=\"2\" cellpadding=\"0\">\n");
319
            for (String group : groups) {
320
                String tablabel = group;
321
                if (StringUtils.isBlank(tablabel)) {
322
                    tablabel = i18n.getTranslation("General");
323
                } else {
324
                    tablabel = i18n.getTranslation(tablabel);
325
                }
326
                builder.append("<tr>\n");
327
                builder.append("<td colspan=\"2\">\n<br/><i>")
328
                    .append(StringEscapeUtils.escapeHtml3(tablabel))
329
                    .append("</i>")
330
                    .append("</td>\n");
331
                builder.append("</tr>\n");
332
                List<DynFormFieldDefinition> fields = formdef.getDefinitions(group);
333
                for (DynFormFieldDefinition fieldDefinition : fields) {
334
                    if (fieldDefinition.isHidden()) {
335
                        continue;
336
                    }
337
                    JDynFormField jfield = form.getField(fieldDefinition.getName());
338
                    if (jfield == null) {
339
                        continue; // ??????
340
                    }
341
                    String value;
342
                    if (fieldDefinition.isHidden() || fieldDefinition.getDataType().isContainer()) {
343
                        continue;
344
                    }
345
                    value = "<%=ROW.getLabelOfValue('" + jfield.getName() + "')%>";
346
                    builder.append("  <tr style=\"page-break-inside: avoid;\">\n");
347
                    if (jfield.useEmptyLabel()) {
348
                        builder.append("    <td colspan=\"2\">")
349
                            .append(value)
350
                            .append("</td>\n");
351
                    } else {
352
                        builder.append("    <td valign=\"top\" style=\"white-space:nowrap;\">");
353
                        if (fieldDefinition.isMandatory()) {
354
                            builder.append("<b>")
355
                                .append(fieldDefinition.getLabel())
356
                                .append("</b>");
357
                        } else {
358
                            builder.append(fieldDefinition.getLabel());
359
                        }
360
                        builder.append(": ")
361
                            .append("</td>\n");
362

  
363
                        builder.append("    <td>")
364
                            .append(value)
365
                            .append("</td>\n");
366
                    }
367
                    builder.append("  </tr>\n");
368
                }
369
            }
370

  
371
            builder.append("</table>\n");
372
            builder.append(template_bottom);
373

  
374
            ToolsSwingLocator.getToolsSwingManager().putInClipboard(builder.toString());
375
            ToolsSwingLocator.getThreadSafeDialogsManager().messageDialog(
376
                    "Copied the template to the clipboard.",
377
                    "Reports",
378
                    JOptionPane.INFORMATION_MESSAGE
379
            );
380
        } catch (IOException ex) {
381
            java.util.logging.Logger.getLogger(StoreReportsAction.class.getName()).log(Level.SEVERE, null, ex);
382
        }
383
    }
384
}
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.app/org.gvsig.pdf.app.mainplugin/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
    <modelVersion>4.0.0</modelVersion>
3
    <parent>
4
        <groupId>org.gvsig</groupId>
5
        <artifactId>org.gvsig.pdf.app</artifactId>
6
        <version>1.0.117</version>
7
    </parent>
8
    <artifactId>org.gvsig.pdf.app.mainplugin</artifactId>
9
    <name>${project.artifactId}</name>
10
    <dependencies>
11
        <dependency>
12
            <groupId>org.gvsig</groupId>
13
            <artifactId>org.gvsig.app.mainplugin</artifactId>
14
            <scope>compile</scope>
15
        </dependency>
16
        <dependency>
17
            <groupId>org.gvsig</groupId>
18
            <artifactId>org.gvsig.pdf.lib.api</artifactId>
19
            <scope>compile</scope>
20
        </dependency>
21
        <dependency>
22
            <groupId>org.gvsig</groupId>
23
            <artifactId>org.gvsig.pdf.lib.impl</artifactId>
24
            <scope>runtime</scope>
25
        </dependency>
26
        <dependency>
27
            <groupId>org.gvsig</groupId>
28
            <artifactId>org.gvsig.pdf.swing.api</artifactId>
29
            <scope>compile</scope>
30
        </dependency>
31
        <dependency>
32
            <groupId>org.gvsig</groupId>
33
            <artifactId>org.gvsig.pdf.swing.impl</artifactId>
34
            <scope>runtime</scope>
35
        </dependency>
36
        <dependency>
37
            <groupId>org.icepdf.os</groupId>
38
            <artifactId>icepdf-core</artifactId>
39
            <scope>runtime</scope>
40
        </dependency>
41
        <dependency>
42
            <groupId>org.icepdf.os</groupId>
43
            <artifactId>icepdf-viewer</artifactId>
44
            <scope>runtime</scope>
45
        </dependency>
46
        <dependency>
47
            <groupId>javax.media</groupId>
48
            <artifactId>jai_core</artifactId>
49
            <scope>runtime</scope>
50
        </dependency>
51
        
52
        <dependency>
53
            <groupId>org.bouncycastle</groupId>
54
            <artifactId>bcpkix-jdk15on</artifactId>
55
            <scope>runtime</scope>
56
        </dependency>
57
        <dependency>
58
            <groupId>org.bouncycastle</groupId>
59
            <artifactId>bcprov-jdk15on</artifactId>
60
            <scope>runtime</scope>
61
        </dependency>
62
        <dependency>
63
            <groupId>org.bouncycastle</groupId>
64
            <artifactId>bcprov-ext-jdk15on</artifactId>
65
            <scope>runtime</scope>
66
        </dependency>
67
        <dependency>
68
            <groupId>org.apache.pdfbox</groupId>
69
            <artifactId>pdfbox</artifactId>
70
            <scope>runtime</scope>
71
        </dependency>
72
        <dependency>
73
            <groupId>org.apache.pdfbox</groupId>
74
            <artifactId>fontbox</artifactId>
75
            <scope>runtime</scope>
76
        </dependency>
77
        <dependency>
78
            <groupId>de.rototor.pdfbox</groupId>
79
            <artifactId>graphics2d</artifactId>
80
            <scope>runtime</scope>
81
        </dependency>
82
        <dependency>
83
            <groupId>org.apache.tika</groupId>
84
            <artifactId>tika-core</artifactId>
85
        </dependency>
86
        
87
        <dependency>
88
            <groupId>com.openhtmltopdf</groupId>
89
            <artifactId>openhtmltopdf-objects</artifactId>
90
            <scope>runtime</scope>
91
        </dependency>
92
        <dependency>
93
            <groupId>com.openhtmltopdf</groupId>
94
            <artifactId>openhtmltopdf-core</artifactId>
95
            <scope>runtime</scope>
96
        </dependency>
97
        <dependency>
98
            <groupId>com.openhtmltopdf</groupId>
99
            <artifactId>openhtmltopdf-java2d</artifactId>
100
            <scope>runtime</scope>
101
        </dependency>
102
        <dependency>
103
            <groupId>com.openhtmltopdf</groupId>
104
            <artifactId>openhtmltopdf-slf4j</artifactId>
105
            <scope>runtime</scope>
106
        </dependency>
107
        <dependency>
108
            <groupId>com.openhtmltopdf</groupId>
109
            <artifactId>openhtmltopdf-rtl-support</artifactId>
110
            <scope>runtime</scope>
111
        </dependency>
112
        <dependency>
113
            <groupId>com.openhtmltopdf</groupId>
114
            <artifactId>openhtmltopdf-svg-support</artifactId>
115
            <scope>runtime</scope>
116
        </dependency>
117
        <dependency>
118
            <groupId>com.openhtmltopdf</groupId>
119
            <artifactId>openhtmltopdf-pdfbox</artifactId>
120
            <scope>compile</scope>
121
        </dependency>
122
        <dependency>
123
            <groupId>org.apache.pdfbox</groupId>
124
            <artifactId>xmpbox</artifactId>
125
            <scope>runtime</scope>
126
            <!--<type>bundle</type>-->
127
            <version>2.0.16</version>
128
        </dependency>
129
        
130
        <!--
131
        <dependency>
132
            <groupId>com.ibm.icu</groupId>
133
            <artifactId>icu4j</artifactId>
134
            <scope>runtime</scope>
135
        </dependency>
136
        <dependency>
137
            <groupId>org.apache.xmlgraphics</groupId>
138
            <artifactId>batik-transcoder</artifactId>
139
            <scope>runtime</scope>
140
        </dependency>
141
        <dependency>
142
            <groupId>org.apache.xmlgraphics</groupId>
143
            <artifactId>batik-shared-resources</artifactId>
144
            <scope>runtime</scope>
145
        </dependency>
146
        <dependency>
147
            <groupId>org.apache.xmlgraphics</groupId>
148
            <artifactId>batik-svggen</artifactId>
149
            <scope>runtime</scope>
150
        </dependency>
151
        <dependency>
152
            <groupId>org.apache.xmlgraphics</groupId>
153
            <artifactId>batik-codec</artifactId>
154
            <scope>runtime</scope>
155
        </dependency>
156
        <dependency>
157
            <groupId>org.apache.xmlgraphics</groupId>
158
            <artifactId>xmlgraphics-commons</artifactId>
159
            <scope>runtime</scope>
160
        </dependency>
161
        -->
162
    </dependencies>
163

  
164
    <properties>
165
        <gvsig.package.info.state>testing</gvsig.package.info.state>
166
        <gvsig.package.info.official>true</gvsig.package.info.official>
167
        <gvsig.package.info.dependencies>required: org.gvsig.app -ge 2.2.0</gvsig.package.info.dependencies>
168
        <gvsig.package.info.categories />
169
        <gvsig.package.info.name>PDF framework</gvsig.package.info.name>
170
        <gvsig.package.info.description>PDF framework and basic rules</gvsig.package.info.description>
171
        <gvsig.package.info.owner>gvSIG Association</gvsig.package.info.owner>
172
        <gvsig.package.info.javaVM>j1_8</gvsig.package.info.javaVM>
173
        <gvsig.package.info.sourcesURL>${project.scm.url}</gvsig.package.info.sourcesURL>
174
        <gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-pdf/pool</gvsig.package.info.poolURL>
175
    </properties>
176

  
177
</project>
0 178

  
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.lib/org.gvsig.pdf.lib.api/src/main/java/org/gvsig/pdf/lib/api/PDFWriter.java
1
package org.gvsig.pdf.lib.api;
2

  
3
import java.awt.Graphics2D;
4

  
5
/**
6
 *
7
 * @author osc
8
 */
9
public interface PDFWriter {
10

  
11
    public static final int PAGE_LETTER = 1;
12
    public static final int PAGE_LEGAL = 2;
13
    public static final int PAGE_A4 = 4;
14
    public static final int PAGE_A5 = 5;
15

  
16
    public void open(int pageSize);
17

  
18
    public void close();
19

  
20
    public float getWidth();
21

  
22
    public float getHeight();
23

  
24
    public Graphics2D getGraphics2D();
25
    
26
    public byte[] toByteArray();
27
    
28
    public PDFDocument toDocument();
29
}
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.lib/org.gvsig.pdf.lib.api/src/main/java/org/gvsig/pdf/lib/api/PDFDocument.java
1
/*
2
 * To change this license header, choose License Headers in Project Properties.
3
 * To change this template file, choose Tools | Templates
4
 * and open the template in the editor.
5
 */
6
package org.gvsig.pdf.lib.api;
7

  
8
import java.io.IOException;
9
import java.io.InputStream;
10
import org.gvsig.tools.dispose.Disposable;
11
import org.gvsig.tools.swing.api.SimpleImage;
12

  
13
/**
14
 *
15
 * @author osc
16
 */
17
public interface PDFDocument extends Disposable {
18
    public InputStream getInputStream() throws IOException ;
19
    
20
    public void setSource(Object source);
21

  
22
    public byte[] toByteArray();
23
    
24
    public String toHexString();
25
    
26
    public int getNumberOfPages();
27
    
28
    public SimpleImage toImage();
29
    
30
    public SimpleImage toImage(int page);
31
    
32
    public SimpleImage toImage(int page, int dpis);
33
}
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.lib/org.gvsig.pdf.lib.api/src/main/java/org/gvsig/pdf/lib/api/PDFLocator.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.pdf.lib.api;
25

  
26
import org.gvsig.tools.locator.AbstractLocator;
27
import org.gvsig.tools.locator.Locator;
28
import org.gvsig.tools.locator.LocatorException;
29

  
30
@SuppressWarnings("rawtypes")
31
public class PDFLocator extends AbstractLocator {
32

  
33
	private static final String LOCATOR_NAME = "PDFLocator";
34
	
35
	public static final String PDF_MANAGER_NAME =
36
			"PDFManager";
37

  
38
	private static final String PDF_MANAGER_DESCRIPTION =
39
			"PDF Manager of gvSIG";
40
	
41
	private static final PDFLocator instance = new PDFLocator();
42

  
43
	private PDFLocator() {
44

  
45
	}
46

  
47
	/**
48
	 * Return the singleton instance.
49
	 * 
50
	 * @return the singleton instance
51
	 */
52
	public static PDFLocator getInstance() {
53
		return instance;
54
	}
55

  
56
        @Override
57
	public String getLocatorName() {
58
		return LOCATOR_NAME;
59
	}
60

  
61
	/**
62
	 * Return a reference to PDFManager.
63
	 * 
64
	 * @return a reference to PDFManager
65
	 * @throws LocatorException
66
	 *             if there is no access to the class or the class cannot be
67
	 *             instantiated
68
	 * @see Locator#get(String)
69
	 */
70
	public static PDFManager getPDFManager()
71
			throws LocatorException {
72
		return (PDFManager) getInstance().get(PDF_MANAGER_NAME);
73
	}
74

  
75
	/**
76
	 * Registers the Class implementing the PDFManager interface.
77
	 * 
78
	 * @param clazz
79
	 *            implementing the PDFManager interface
80
	 */
81
//	public static void registerPDFManager(Class clazz) {
82
//		getInstance().register(PDF_MANAGER_NAME,
83
//				PDF_MANAGER_DESCRIPTION, clazz);
84
//	}
85

  
86
	public static void registerDefaultPDFManager(Class clazz) {
87
		getInstance().registerDefault(PDF_MANAGER_NAME,
88
				PDF_MANAGER_DESCRIPTION, clazz);
89
	}
90

  
91

  
92
}
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.lib/org.gvsig.pdf.lib.api/src/main/java/org/gvsig/pdf/lib/api/PDFLibrary.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.pdf.lib.api;
25

  
26
import org.gvsig.fmap.dal.DALLibrary;
27
import org.gvsig.tools.ToolsLibrary;
28
import org.gvsig.tools.library.AbstractLibrary;
29
import org.gvsig.tools.library.LibraryException;
30

  
31
/**
32
 *
33
 * @author jjdelcerro
34
 */
35
public class PDFLibrary extends AbstractLibrary {
36

  
37
    @Override
38
    public void doRegistration() {
39
        super.doRegistration();
40
        registerAsAPI(PDFLibrary.class);
41
        this.require(ToolsLibrary.class);
42
        this.require(DALLibrary.class);
43
    }
44

  
45
    @Override
46
    protected void doInitialize() throws LibraryException {
47
    }
48

  
49
    @Override
50
    protected void doPostInitialize() throws LibraryException {
51
    }
52

  
53
}
org.gvsig.pdf/tags/org.gvsig.pdf-1.0.117/org.gvsig.pdf.lib/org.gvsig.pdf.lib.api/src/main/java/org/gvsig/pdf/lib/api/PDFManager.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.pdf.lib.api;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff