Source Code Cross Referenced for FDFGenerator.java in  » J2EE » Sofia » com » salmonllc » acrobat » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » Sofia » com.salmonllc.acrobat 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //** Copyright Statement ***************************************************
002:        //The Salmon Open Framework for Internet Applications (SOFIA)
003:        // Copyright (C) 1999 - 2002, Salmon LLC
004:        //
005:        // This program is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU General Public License version 2
007:        // as published by the Free Software Foundation;
008:        // 
009:        // This program is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:        // GNU General Public License for more details.
013:        // 
014:        // You should have received a copy of the GNU General Public License
015:        // along with this program; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:        // 
018:        // For more information please visit http://www.salmonllc.com
019:        //** End Copyright Statement ***************************************************
020:        package com.salmonllc.acrobat;
021:
022:        import java.net.*;
023:        import java.util.*;
024:        import java.io.*;
025:
026:        /**
027:         * FDFGenerator is a class to generate an FDF file which will 
028:         * contain fieldnames and values for the fields for a form in a PDF File.
029:         * To use create an Instance of FDFGenerator with a URL to the PDF File containing the Form with Fields defined,
030:         * and a Fully specified path & filename of the generated FDF file.
031:         * Then set the values of the fields using setValue method.
032:         * After setting all values, make a call to createFDFFile, this will generated the FDF specified in the constructor.
033:         * To display the PDF with the specified data, redirect to a URL specifying the web location of the FDF file which was generated.
034:         * Creation date: (1/15/02 12:18:16 PM)
035:         * @author: Fred Cahill
036:         */
037:        public class FDFGenerator {
038:            private static final String _HEADER = "%FDF-1.2\n1 0 obj <<\n/FDF <<\n/Fields\n[";
039:            private static final String _FOOTER = ">>\n>>\nendobj\ntrailer\n<</Root 1 0 R>>\n%%EOF";
040:
041:            private URL _PDFTemplate;
042:            private String _FDFOutputFile;
043:
044:            private Hashtable _htFields = new Hashtable();
045:
046:            /**
047:             * This create an FDFGenerator object for the PDF Template.
048:             * @param uPDFTemplate A Url pointing to a PDF Template Form
049:             * @param sFDFOutputFile The filename of the generated FDF file.
050:             */
051:            public FDFGenerator(URL uPDFTemplate, String sFDFOutputFile) {
052:                super ();
053:                _PDFTemplate = uPDFTemplate;
054:                _FDFOutputFile = sFDFOutputFile;
055:            }
056:
057:            /**
058:             * This method clears a field value in the template.
059:             * @param sFieldName The name of a field in the Template.
060:             */
061:            public void clearField(String sFieldName) {
062:                _htFields.remove(sFieldName);
063:            }
064:
065:            /**
066:             * This method generates the FDF file for the template containing the values for the fields. The name of the generated file was specified in the constructor.
067:             */
068:            public void createFDFFile() throws FDFGeneratorException {
069:                File fFDFOutputFile = new File(_FDFOutputFile);
070:                try {
071:                    FileOutputStream fosFDF = new FileOutputStream(
072:                            fFDFOutputFile);
073:                    PrintWriter pw = new PrintWriter(fosFDF);
074:                    pw.println(_HEADER);
075:                    Enumeration enumFields = _htFields.keys();
076:                    while (enumFields.hasMoreElements()) {
077:                        String sField = (String) enumFields.nextElement();
078:                        pw.println("<<\n/T (" + sField + ")\n/V ("
079:                                + (String) _htFields.get(sField) + ")\n>>");
080:                    }
081:                    pw.println(getPDFFileLocation());
082:                    pw.println(_FOOTER);
083:                    pw.close();
084:                    fosFDF.close();
085:                } catch (Exception e) {
086:                    throw new FDFGeneratorException(e.getMessage());
087:                }
088:            }
089:
090:            private String getPDFFileLocation() {
091:                return "]\n/F (" + _PDFTemplate + ")";
092:            }
093:
094:            /**
095:             * This method sets the value of a field in the template.
096:             * @param sFieldName The name of a field in the Template.
097:             * @param sValue The value to set the field to in the Template.
098:             */
099:            public void setValue(String sFieldName, String sValue) {
100:                _htFields.put(sFieldName, sValue);
101:            }
102:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.