├── .gitignore ├── dist ├── lib │ └── pdfbox-0.7.3.jar ├── pdfWriteBookmarks.jar └── README.TXT ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── README.TXT ├── src └── main │ └── java │ └── pdfwritebookmarks │ ├── LevelManager.java │ ├── BookmarkItem.java │ ├── Main.java │ └── BookmarkListParser.java ├── pom.xml ├── mvnw.cmd ├── mvnw └── license.txt /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | -------------------------------------------------------------------------------- /dist/lib/pdfbox-0.7.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goerz/pdfWriteBookmarks/HEAD/dist/lib/pdfbox-0.7.3.jar -------------------------------------------------------------------------------- /dist/pdfWriteBookmarks.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goerz/pdfWriteBookmarks/HEAD/dist/pdfWriteBookmarks.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goerz/pdfWriteBookmarks/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip -------------------------------------------------------------------------------- /dist/README.TXT: -------------------------------------------------------------------------------- 1 | ======================== 2 | BUILD OUTPUT DESCRIPTION 3 | ======================== 4 | 5 | To run the project from the command line, go to the dist folder and 6 | type the following: 7 | 8 | java -jar "pdfWriteBookmarks.jar" 9 | 10 | To distribute this project, zip up the dist folder (including the lib folder) 11 | and distribute the ZIP file. 12 | -------------------------------------------------------------------------------- /README.TXT: -------------------------------------------------------------------------------- 1 | /* pdfWriteBookmarks 2 | * (c) 2006 Michael Goerz 3 | * http://www.physik.fu-berlin.de/~goerz/ 4 | * 5 | * pdfWriteBookmarks is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * pdfWriteBookmarks is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with pdfWriteBookmarks; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 | * http://www.gnu.org/copyleft/gpl.html 19 | */ 20 | 21 | /* 22 | * pdfWriteBookmarks uses the PDFBox library 23 | * http://www.pdfbox.org/ 24 | */ 25 | 26 | 27 | pdfWriteBookmarks is build with [Maven](http://maven.apache.org/). You can 28 | build it with the command 29 | 30 | ./mvnw package 31 | 32 | You will find the actual source code files in the subfolder src/pdfwritebookmarks/ 33 | 34 | The executable jar-file is in the subfolder dist/. Read /dist/README.TXT 35 | 36 | You will probably want to put this folder in a convenient location and write a simple 37 | batch file to wrap around the jar-file. -------------------------------------------------------------------------------- /src/main/java/pdfwritebookmarks/LevelManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * LevelManager.java 3 | * 4 | * Created on March 21, 2006, 7:11 PM 5 | * 6 | * (c) 2006 Michael Goerz 7 | * http://www.physik.fu-berlin.de/~goerz/programme_en.html 8 | * v1.0 9 | * 10 | */ 11 | 12 | /* This file is part of pdfWriteBookmarks 13 | * 14 | * pdfWriteBookmarks is free software; you can redistribute it and/or modify 15 | * it under the terms of the GNU General Public License as published by 16 | * the Free Software Foundation; either version 2 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * pdfWriteBookmarks is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | * GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License 25 | * along with pdfWriteBookmarks; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 | * http://www.gnu.org/copyleft/gpl.html 28 | */ 29 | 30 | /* 31 | * pdfWriteBookmarks uses the PDFBox library 32 | * http://www.pdfbox.org/ 33 | */ 34 | 35 | 36 | package pdfwritebookmarks; 37 | import org.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem; 38 | 39 | public class LevelManager { 40 | 41 | /** Creates a new instance of LevelManager */ 42 | public LevelManager() { 43 | levelstack.push(null); 44 | } 45 | 46 | private int currentlevel = 0; 47 | 48 | private java.util.Stack levelstack = new java.util.Stack(); 49 | 50 | 51 | public PDOutlineItem register(PDOutlineItem item, int level){ 52 | // adds a new bookmark to the manager at level, and returns the 53 | // parent of the new bookmark 54 | 55 | //remove all items that are not an ancestor of the current item 56 | while (level <= currentlevel){ 57 | levelstack.pop(); 58 | currentlevel--; 59 | } 60 | PDOutlineItem parent = levelstack.empty() ? null : levelstack.peek(); 61 | levelstack.push(item); 62 | currentlevel++; 63 | return parent; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | goerz 6 | pdfWriteBookmarks 7 | 0-SNAPSHOT 8 | jar 9 | 10 | 11 | 12 | GNU General Public License version 2 13 | https://opensource.org/licenses/GPL-2.0 14 | repo 15 | 16 | 17 | 18 | 19 | scm:git:git://github.com/goerz/pdfWriteBookmarks.git 20 | scm:git:git@github.com:goerz/pdfWriteBookmarks.git 21 | https://github.com/goerz/pdfWriteBookmarks/ 22 | 23 | 24 | 25 | UTF-8 26 | 27 | 28 | 29 | 30 | pdfbox 31 | pdfbox 32 | 0.7.3 33 | system 34 | ${basedir}/dist/lib/pdfbox-0.7.3.jar 35 | 36 | 37 | 38 | 39 | pdfWriteBookmarks 40 | 41 | 42 | org.apache.maven.plugins 43 | maven-jar-plugin 44 | 3.0.2 45 | 46 | 47 | 48 | pdfwritebookmarks.Main 49 | 50 | 51 | lib/pdfbox-0.7.3.jar 52 | 53 | 54 | dist 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/main/java/pdfwritebookmarks/BookmarkItem.java: -------------------------------------------------------------------------------- 1 | /* 2 | * BookmarkItem.java 3 | * 4 | * Created on March 21, 2006, 7:11 PM 5 | * 6 | * (c) 2006 Michael Goerz 7 | * http://www.physik.fu-berlin.de/~goerz/programme_en.html 8 | * v1.0 9 | * 10 | */ 11 | 12 | /* This file is part of pdfWriteBookmarks 13 | * 14 | * pdfWriteBookmarks is free software; you can redistribute it and/or modify 15 | * it under the terms of the GNU General Public License as published by 16 | * the Free Software Foundation; either version 2 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * pdfWriteBookmarks is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | * GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License 25 | * along with pdfWriteBookmarks; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 | * http://www.gnu.org/copyleft/gpl.html 28 | */ 29 | 30 | /* 31 | * pdfWriteBookmarks uses the PDFBox library 32 | * http://www.pdfbox.org/ 33 | */ 34 | 35 | 36 | package pdfwritebookmarks; 37 | 38 | 39 | public class BookmarkItem { 40 | 41 | /** Creates a new instance of BookmarkItem */ 42 | public BookmarkItem(String title, int pagenumber, int level) { 43 | this.setTitle(title); 44 | this.setPageNumber(pagenumber); 45 | this.setLevel(level); 46 | } 47 | 48 | 49 | private String title; 50 | private int pagenumber; 51 | private int level; 52 | 53 | public String getTitle(){ 54 | return title; 55 | } 56 | 57 | public void setTitle(String t){ 58 | if (t.length()<=255){ 59 | title = t; 60 | } else { 61 | System.out.println("Bookmark Title too long"); 62 | System.exit( 1 ); 63 | title = ""; 64 | } 65 | } 66 | 67 | public int getPageNumber(){ 68 | return pagenumber; 69 | } 70 | 71 | public void setPageNumber(int p){ 72 | if (p >= 0) { 73 | pagenumber = p; 74 | } else { 75 | System.out.println("Pagenumber must be greater than zero"); 76 | System.exit( 1 ); 77 | pagenumber = 0; 78 | } 79 | } 80 | 81 | public int getLevel(){ 82 | return level; 83 | } 84 | 85 | public void setLevel(int l){ 86 | if (l >= 0) { 87 | level = l; 88 | } else { 89 | System.out.println("Level must be greater than zero"); 90 | System.exit( 1 ); 91 | level = 0; 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 84 | @REM Fallback to current working directory if not found. 85 | 86 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 87 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 88 | 89 | set EXEC_DIR=%CD% 90 | set WDIR=%EXEC_DIR% 91 | :findBaseDir 92 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 93 | cd .. 94 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 95 | set WDIR=%CD% 96 | goto findBaseDir 97 | 98 | :baseDirFound 99 | set MAVEN_PROJECTBASEDIR=%WDIR% 100 | cd "%EXEC_DIR%" 101 | goto endDetectBaseDir 102 | 103 | :baseDirNotFound 104 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 105 | cd "%EXEC_DIR%" 106 | 107 | :endDetectBaseDir 108 | 109 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 110 | 111 | @setlocal EnableExtensions EnableDelayedExpansion 112 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 113 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 114 | 115 | :endReadAdditionalConfig 116 | 117 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 118 | 119 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 120 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 121 | 122 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 123 | if ERRORLEVEL 1 goto error 124 | goto end 125 | 126 | :error 127 | set ERROR_CODE=1 128 | 129 | :end 130 | @endlocal & set ERROR_CODE=%ERROR_CODE% 131 | 132 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 133 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 134 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 135 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 136 | :skipRcPost 137 | 138 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 139 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 140 | 141 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 142 | 143 | exit /B %ERROR_CODE% 144 | -------------------------------------------------------------------------------- /src/main/java/pdfwritebookmarks/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Main.java 3 | * 4 | * Created on March 21, 2006, 7:11 PM 5 | * 6 | * (c) 2006 Michael Goerz 7 | * http://www.physik.fu-berlin.de/~goerz/programme_en.html 8 | * v1.0 9 | * 10 | */ 11 | 12 | /* This file is part of pdfWriteBookmarks 13 | * 14 | * pdfWriteBookmarks is free software; you can redistribute it and/or modify 15 | * it under the terms of the GNU General Public License as published by 16 | * the Free Software Foundation; either version 2 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * pdfWriteBookmarks is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | * GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License 25 | * along with pdfWriteBookmarks; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 | * http://www.gnu.org/copyleft/gpl.html 28 | */ 29 | 30 | /* 31 | * pdfWriteBookmarks uses the PDFBox library 32 | * http://www.pdfbox.org/ 33 | */ 34 | 35 | package pdfwritebookmarks; 36 | 37 | import org.pdfbox.pdmodel.PDDocument; 38 | import org.pdfbox.pdmodel.PDPage; 39 | import org.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageFitWidthDestination; 40 | import org.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline; 41 | import org.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem; 42 | 43 | import java.util.List; 44 | 45 | import static pdfwritebookmarks.BookmarkListParser.parseBookmarks; 46 | 47 | public class Main { 48 | 49 | /** Creates a new instance of Main */ 50 | public Main() { 51 | } 52 | 53 | public static void main(String[] args) { 54 | // Parse the Commandline 55 | String bookmarkfile = ""; 56 | String pdffile = ""; 57 | String outfile = ""; 58 | if (args.length >= 2){ 59 | pdffile = args[0]; 60 | bookmarkfile = args[1]; 61 | if (args.length == 3){ 62 | outfile = args[2]; 63 | } else { 64 | outfile = pdffile; 65 | } 66 | } else { 67 | usage(); 68 | System.exit(0); 69 | } 70 | // open the pdf file 71 | PDDocument document = null; 72 | try{ 73 | document = PDDocument.load( pdffile ); 74 | if( document.isEncrypted() ){ 75 | System.err.println("Cannot add bookmarks to encrypted document."); 76 | System.exit(1); 77 | } 78 | 79 | List pages = document.getDocumentCatalog().getAllPages(); 80 | 81 | // attach new outline 82 | PDDocumentOutline outline = new PDDocumentOutline(); 83 | document.getDocumentCatalog().setDocumentOutline( outline ); 84 | 85 | // use the LevelManager 86 | LevelManager manager = new LevelManager(); 87 | 88 | //create all the bookmarks 89 | for( BookmarkItem item: parseBookmarks(bookmarkfile) ){ 90 | PDOutlineItem bookmark = new PDOutlineItem(); 91 | bookmark.setTitle(item.getTitle()); 92 | PDPage page = (PDPage)pages.get(item.getPageNumber()-1);// counting in list starts at zero! 93 | bookmark.setDestination(page); 94 | PDOutlineItem parent = manager.register(bookmark, item.getLevel()); 95 | if (parent == null){ 96 | outline.appendChild(bookmark); 97 | } else { 98 | parent.appendChild(bookmark); 99 | } 100 | } 101 | 102 | // save the document 103 | document.save(outfile); 104 | } 105 | catch (Exception e){ 106 | System.out.println(e.getMessage()); 107 | System.exit(1); 108 | 109 | } 110 | finally{ 111 | if( document != null ) 112 | { 113 | try{ 114 | document.close(); 115 | } 116 | catch(Exception e2){ 117 | System.out.println(e2.getMessage()); 118 | System.exit(1); 119 | } 120 | } 121 | } 122 | } 123 | 124 | 125 | 126 | private static void usage(){ 127 | System.out.println("pdfWriteBookmarks v1.0"); 128 | System.out.println("(c) 2006 Michael Goerz\n"); 129 | System.out.println("This program is licensed under the GPL."); 130 | System.out.println("See http://www.gnu.org/copyleft/gpl.html for details\n"); 131 | System.out.println("usage:"); 132 | System.out.println("java -jar pdfWriteBookmarks.jar inputfile.pdf bookmarks.txt [output.pdf]\n"); 133 | System.out.println("The format of bookmarks.txt must be like the output of pdftk:"); 134 | System.out.println("pdftk file.pdf dump_data\n"); 135 | System.out.println("[...]"); 136 | System.out.println("BookmarkTitle: text"); 137 | System.out.println("BookmarkLevel: 2"); 138 | System.out.println("BookmarkPageNumber: 20"); 139 | System.out.println("[...]\n"); 140 | System.out.println("Alternatively, you can use a shorter one-line format:"); 141 | System.out.println(" Bookmark Title :: pagenumber"); 142 | System.out.println("The BookmarkLevel is expressed by the indentation. There have to be"); 143 | System.out.println("exactly four spaces indentation per level"); 144 | } 145 | 146 | 147 | } 148 | -------------------------------------------------------------------------------- /src/main/java/pdfwritebookmarks/BookmarkListParser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * BookmarkList.java 3 | * 4 | * Created on March 21, 2006, 7:11 PM 5 | * 6 | * (c) 2006 Michael Goerz 7 | * http://www.physik.fu-berlin.de/~goerz/programme_en.html 8 | * v1.0 9 | * 10 | */ 11 | 12 | /* This file is part of pdfWriteBookmarks 13 | * 14 | * pdfWriteBookmarks is free software; you can redistribute it and/or modify 15 | * it under the terms of the GNU General Public License as published by 16 | * the Free Software Foundation; either version 2 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * pdfWriteBookmarks is distributed in the hope that it will be useful, 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | * GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License 25 | * along with pdfWriteBookmarks; if not, write to the Free Software 26 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 27 | * http://www.gnu.org/copyleft/gpl.html 28 | */ 29 | 30 | /* 31 | * pdfWriteBookmarks uses the PDFBox library 32 | * http://www.pdfbox.org/ 33 | */ 34 | 35 | 36 | package pdfwritebookmarks; 37 | import java.io.*; 38 | 39 | 40 | public class BookmarkListParser { 41 | 42 | /** Parses a bookmark file */ 43 | public static Iterable parseBookmarks(String inputfile) { 44 | // Parses the Inputfile and creates a list of the bookmarks in it 45 | // The format is like that in the output of pdftk: 46 | // [...] 47 | // BookmarkTitle: text 48 | // BookmarkLevel: 2 49 | // BookmarkPageNumber: 20 50 | // [...] 51 | // 52 | // Alternatively, you can use the short form 53 | // Bookmark Title :: Pagenumber 54 | // The indentation controls the level, exactly four spaces indentation 55 | // per level 56 | java.util.List bookmarks = new java.util.ArrayList(); 57 | String line = ""; 58 | String title = ""; 59 | int page = 0; 60 | int level =0; 61 | try{ 62 | //BufferedReader in = new BufferedReader(new FileReader(inputfile)); 63 | FileInputStream fis = new FileInputStream(inputfile); 64 | 65 | BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8")); 66 | 67 | while(line != null) { 68 | line = in.readLine(); 69 | if (line != null){ 70 | 71 | // TODO: translate the encoding pdftk uses for non-ascii symbols 72 | 73 | // First, check for the short bookmark format 74 | if (line.matches( "(.*)::([ 0-9]*)$" )){ 75 | // Get the indentation 76 | level = 1; 77 | while (line.startsWith(" ")){ 78 | level++; 79 | line = line.replaceFirst( "[ ]{4}", "" ); 80 | } 81 | // Get Title and Pagenumber 82 | line = line.trim(); 83 | title = line.replaceFirst("::([ 0-9]*)$", ""); 84 | try{ 85 | page = Integer.parseInt( line.substring(line.lastIndexOf(":")+1).trim() ); 86 | } 87 | catch(NumberFormatException e){ 88 | System.out.println(e.getMessage()); 89 | System.out.println("ERROR: Could not parse bookmarks"); 90 | System.exit(1); 91 | } 92 | bookmarks.add(new BookmarkItem(title, page, level)); 93 | title = ""; 94 | level = 0; 95 | page = 0; 96 | } 97 | 98 | // Now we check for the long threeline format 99 | line = line.trim(); 100 | if (line.indexOf("BookmarkTitle: ") == 0) { 101 | title = line.replaceFirst("BookmarkTitle: ",""); 102 | title.trim(); 103 | } 104 | if (line.indexOf("BookmarkLevel: ") == 0) { 105 | try{ 106 | level = Integer.parseInt(line.replaceFirst("BookmarkLevel: ","")); 107 | } 108 | catch(NumberFormatException e){ 109 | System.out.println(e.getMessage()); 110 | System.out.println("ERROR: Could not parse bookmarks"); 111 | System.exit(1); 112 | } 113 | } 114 | if (line.indexOf("BookmarkPageNumber: ") == 0) { 115 | try{ 116 | page = Integer.parseInt(line.replaceFirst("BookmarkPageNumber: ","")); 117 | if ((title != "") && (level != 0) && (page != 0)){ 118 | bookmarks.add(new BookmarkItem(title, page, level)); 119 | title = ""; 120 | level = 0; 121 | page = 0; 122 | } 123 | } 124 | catch(NumberFormatException e){ 125 | System.out.println(e.getMessage()); 126 | System.out.println("ERROR: Could not parse bookmarks"); 127 | System.exit(1); 128 | } 129 | } 130 | 131 | } 132 | } 133 | } 134 | catch(IOException e){ 135 | System.out.println("Could not read from file"); 136 | System.exit(1); 137 | } 138 | return bookmarks; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | # TODO classpath? 118 | fi 119 | 120 | if [ -z "$JAVA_HOME" ]; then 121 | javaExecutable="`which javac`" 122 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 123 | # readlink(1) is not available as standard on Solaris 10. 124 | readLink=`which readlink` 125 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 126 | if $darwin ; then 127 | javaHome="`dirname \"$javaExecutable\"`" 128 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 129 | else 130 | javaExecutable="`readlink -f \"$javaExecutable\"`" 131 | fi 132 | javaHome="`dirname \"$javaExecutable\"`" 133 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 134 | JAVA_HOME="$javaHome" 135 | export JAVA_HOME 136 | fi 137 | fi 138 | fi 139 | 140 | if [ -z "$JAVACMD" ] ; then 141 | if [ -n "$JAVA_HOME" ] ; then 142 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 143 | # IBM's JDK on AIX uses strange locations for the executables 144 | JAVACMD="$JAVA_HOME/jre/sh/java" 145 | else 146 | JAVACMD="$JAVA_HOME/bin/java" 147 | fi 148 | else 149 | JAVACMD="`which java`" 150 | fi 151 | fi 152 | 153 | if [ ! -x "$JAVACMD" ] ; then 154 | echo "Error: JAVA_HOME is not defined correctly." >&2 155 | echo " We cannot execute $JAVACMD" >&2 156 | exit 1 157 | fi 158 | 159 | if [ -z "$JAVA_HOME" ] ; then 160 | echo "Warning: JAVA_HOME environment variable is not set." 161 | fi 162 | 163 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 164 | 165 | # traverses directory structure from process work directory to filesystem root 166 | # first directory with .mvn subdirectory is considered project base directory 167 | find_maven_basedir() { 168 | 169 | if [ -z "$1" ] 170 | then 171 | echo "Path not specified to find_maven_basedir" 172 | return 1 173 | fi 174 | 175 | basedir="$1" 176 | wdir="$1" 177 | while [ "$wdir" != '/' ] ; do 178 | if [ -d "$wdir"/.mvn ] ; then 179 | basedir=$wdir 180 | break 181 | fi 182 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 183 | if [ -d "${wdir}" ]; then 184 | wdir=`cd "$wdir/.."; pwd` 185 | fi 186 | # end of workaround 187 | done 188 | echo "${basedir}" 189 | } 190 | 191 | # concatenates all lines of a file 192 | concat_lines() { 193 | if [ -f "$1" ]; then 194 | echo "$(tr -s '\n' ' ' < "$1")" 195 | fi 196 | } 197 | 198 | BASE_DIR=`find_maven_basedir "$(pwd)"` 199 | if [ -z "$BASE_DIR" ]; then 200 | exit 1; 201 | fi 202 | 203 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 204 | if [ "$MVNW_VERBOSE" = true ]; then 205 | echo $MAVEN_PROJECTBASEDIR 206 | fi 207 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 208 | 209 | # For Cygwin, switch paths to Windows format before running java 210 | if $cygwin; then 211 | [ -n "$M2_HOME" ] && 212 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 213 | [ -n "$JAVA_HOME" ] && 214 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 215 | [ -n "$CLASSPATH" ] && 216 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 217 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 218 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 219 | fi 220 | 221 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 222 | 223 | exec "$JAVACMD" \ 224 | $MAVEN_OPTS \ 225 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 226 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 227 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 228 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | 2 | GNU GENERAL PUBLIC LICENSE 3 | Version 2, June 1991 4 | 5 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 6 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 7 | Everyone is permitted to copy and distribute verbatim copies 8 | of this license document, but changing it is not allowed. 9 | 10 | Preamble 11 | 12 | The licenses for most software are designed to take away your 13 | freedom to share and change it. By contrast, the GNU General Public 14 | License is intended to guarantee your freedom to share and change free 15 | software--to make sure the software is free for all its users. This 16 | General Public License applies to most of the Free Software 17 | Foundation's software and to any other program whose authors commit to 18 | using it. (Some other Free Software Foundation software is covered by 19 | the GNU Library General Public License instead.) You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | this service if you wish), that you receive source code or can get it 26 | if you want it, that you can change the software or use pieces of it 27 | in new free programs; and that you know you can do these things. 28 | 29 | To protect your rights, we need to make restrictions that forbid 30 | anyone to deny you these rights or to ask you to surrender the rights. 31 | These restrictions translate to certain responsibilities for you if you 32 | distribute copies of the software, or if you modify it. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must give the recipients all the rights that 36 | you have. You must make sure that they, too, receive or can get the 37 | source code. And you must show them these terms so they know their 38 | rights. 39 | 40 | We protect your rights with two steps: (1) copyright the software, and 41 | (2) offer you this license which gives you legal permission to copy, 42 | distribute and/or modify the software. 43 | 44 | Also, for each author's protection and ours, we want to make certain 45 | that everyone understands that there is no warranty for this free 46 | software. If the software is modified by someone else and passed on, we 47 | want its recipients to know that what they have is not the original, so 48 | that any problems introduced by others will not reflect on the original 49 | authors' reputations. 50 | 51 | Finally, any free program is threatened constantly by software 52 | patents. We wish to avoid the danger that redistributors of a free 53 | program will individually obtain patent licenses, in effect making the 54 | program proprietary. To prevent this, we have made it clear that any 55 | patent must be licensed for everyone's free use or not licensed at all. 56 | 57 | The precise terms and conditions for copying, distribution and 58 | modification follow. 59 | 60 | GNU GENERAL PUBLIC LICENSE 61 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 62 | 63 | 0. This License applies to any program or other work which contains 64 | a notice placed by the copyright holder saying it may be distributed 65 | under the terms of this General Public License. The "Program", below, 66 | refers to any such program or work, and a "work based on the Program" 67 | means either the Program or any derivative work under copyright law: 68 | that is to say, a work containing the Program or a portion of it, 69 | either verbatim or with modifications and/or translated into another 70 | language. (Hereinafter, translation is included without limitation in 71 | the term "modification".) Each licensee is addressed as "you". 72 | 73 | Activities other than copying, distribution and modification are not 74 | covered by this License; they are outside its scope. The act of 75 | running the Program is not restricted, and the output from the Program 76 | is covered only if its contents constitute a work based on the 77 | Program (independent of having been made by running the Program). 78 | Whether that is true depends on what the Program does. 79 | 80 | 1. You may copy and distribute verbatim copies of the Program's 81 | source code as you receive it, in any medium, provided that you 82 | conspicuously and appropriately publish on each copy an appropriate 83 | copyright notice and disclaimer of warranty; keep intact all the 84 | notices that refer to this License and to the absence of any warranty; 85 | and give any other recipients of the Program a copy of this License 86 | along with the Program. 87 | 88 | You may charge a fee for the physical act of transferring a copy, and 89 | you may at your option offer warranty protection in exchange for a fee. 90 | 91 | 2. You may modify your copy or copies of the Program or any portion 92 | of it, thus forming a work based on the Program, and copy and 93 | distribute such modifications or work under the terms of Section 1 94 | above, provided that you also meet all of these conditions: 95 | 96 | a) You must cause the modified files to carry prominent notices 97 | stating that you changed the files and the date of any change. 98 | 99 | b) You must cause any work that you distribute or publish, that in 100 | whole or in part contains or is derived from the Program or any 101 | part thereof, to be licensed as a whole at no charge to all third 102 | parties under the terms of this License. 103 | 104 | c) If the modified program normally reads commands interactively 105 | when run, you must cause it, when started running for such 106 | interactive use in the most ordinary way, to print or display an 107 | announcement including an appropriate copyright notice and a 108 | notice that there is no warranty (or else, saying that you provide 109 | a warranty) and that users may redistribute the program under 110 | these conditions, and telling the user how to view a copy of this 111 | License. (Exception: if the Program itself is interactive but 112 | does not normally print such an announcement, your work based on 113 | the Program is not required to print an announcement.) 114 | 115 | These requirements apply to the modified work as a whole. If 116 | identifiable sections of that work are not derived from the Program, 117 | and can be reasonably considered independent and separate works in 118 | themselves, then this License, and its terms, do not apply to those 119 | sections when you distribute them as separate works. But when you 120 | distribute the same sections as part of a whole which is a work based 121 | on the Program, the distribution of the whole must be on the terms of 122 | this License, whose permissions for other licensees extend to the 123 | entire whole, and thus to each and every part regardless of who wrote it. 124 | 125 | Thus, it is not the intent of this section to claim rights or contest 126 | your rights to work written entirely by you; rather, the intent is to 127 | exercise the right to control the distribution of derivative or 128 | collective works based on the Program. 129 | 130 | In addition, mere aggregation of another work not based on the Program 131 | with the Program (or with a work based on the Program) on a volume of 132 | a storage or distribution medium does not bring the other work under 133 | the scope of this License. 134 | 135 | 3. You may copy and distribute the Program (or a work based on it, 136 | under Section 2) in object code or executable form under the terms of 137 | Sections 1 and 2 above provided that you also do one of the following: 138 | 139 | a) Accompany it with the complete corresponding machine-readable 140 | source code, which must be distributed under the terms of Sections 141 | 1 and 2 above on a medium customarily used for software interchange; or, 142 | 143 | b) Accompany it with a written offer, valid for at least three 144 | years, to give any third party, for a charge no more than your 145 | cost of physically performing source distribution, a complete 146 | machine-readable copy of the corresponding source code, to be 147 | distributed under the terms of Sections 1 and 2 above on a medium 148 | customarily used for software interchange; or, 149 | 150 | c) Accompany it with the information you received as to the offer 151 | to distribute corresponding source code. (This alternative is 152 | allowed only for noncommercial distribution and only if you 153 | received the program in object code or executable form with such 154 | an offer, in accord with Subsection b above.) 155 | 156 | The source code for a work means the preferred form of the work for 157 | making modifications to it. For an executable work, complete source 158 | code means all the source code for all modules it contains, plus any 159 | associated interface definition files, plus the scripts used to 160 | control compilation and installation of the executable. However, as a 161 | special exception, the source code distributed need not include 162 | anything that is normally distributed (in either source or binary 163 | form) with the major components (compiler, kernel, and so on) of the 164 | operating system on which the executable runs, unless that component 165 | itself accompanies the executable. 166 | 167 | If distribution of executable or object code is made by offering 168 | access to copy from a designated place, then offering equivalent 169 | access to copy the source code from the same place counts as 170 | distribution of the source code, even though third parties are not 171 | compelled to copy the source along with the object code. 172 | 173 | 4. You may not copy, modify, sublicense, or distribute the Program 174 | except as expressly provided under this License. Any attempt 175 | otherwise to copy, modify, sublicense or distribute the Program is 176 | void, and will automatically terminate your rights under this License. 177 | However, parties who have received copies, or rights, from you under 178 | this License will not have their licenses terminated so long as such 179 | parties remain in full compliance. 180 | 181 | 5. You are not required to accept this License, since you have not 182 | signed it. However, nothing else grants you permission to modify or 183 | distribute the Program or its derivative works. These actions are 184 | prohibited by law if you do not accept this License. Therefore, by 185 | modifying or distributing the Program (or any work based on the 186 | Program), you indicate your acceptance of this License to do so, and 187 | all its terms and conditions for copying, distributing or modifying 188 | the Program or works based on it. 189 | 190 | 6. Each time you redistribute the Program (or any work based on the 191 | Program), the recipient automatically receives a license from the 192 | original licensor to copy, distribute or modify the Program subject to 193 | these terms and conditions. You may not impose any further 194 | restrictions on the recipients' exercise of the rights granted herein. 195 | You are not responsible for enforcing compliance by third parties to 196 | this License. 197 | 198 | 7. If, as a consequence of a court judgment or allegation of patent 199 | infringement or for any other reason (not limited to patent issues), 200 | conditions are imposed on you (whether by court order, agreement or 201 | otherwise) that contradict the conditions of this License, they do not 202 | excuse you from the conditions of this License. If you cannot 203 | distribute so as to satisfy simultaneously your obligations under this 204 | License and any other pertinent obligations, then as a consequence you 205 | may not distribute the Program at all. For example, if a patent 206 | license would not permit royalty-free redistribution of the Program by 207 | all those who receive copies directly or indirectly through you, then 208 | the only way you could satisfy both it and this License would be to 209 | refrain entirely from distribution of the Program. 210 | 211 | If any portion of this section is held invalid or unenforceable under 212 | any particular circumstance, the balance of the section is intended to 213 | apply and the section as a whole is intended to apply in other 214 | circumstances. 215 | 216 | It is not the purpose of this section to induce you to infringe any 217 | patents or other property right claims or to contest validity of any 218 | such claims; this section has the sole purpose of protecting the 219 | integrity of the free software distribution system, which is 220 | implemented by public license practices. Many people have made 221 | generous contributions to the wide range of software distributed 222 | through that system in reliance on consistent application of that 223 | system; it is up to the author/donor to decide if he or she is willing 224 | to distribute software through any other system and a licensee cannot 225 | impose that choice. 226 | 227 | This section is intended to make thoroughly clear what is believed to 228 | be a consequence of the rest of this License. 229 | 230 | 8. If the distribution and/or use of the Program is restricted in 231 | certain countries either by patents or by copyrighted interfaces, the 232 | original copyright holder who places the Program under this License 233 | may add an explicit geographical distribution limitation excluding 234 | those countries, so that distribution is permitted only in or among 235 | countries not thus excluded. In such case, this License incorporates 236 | the limitation as if written in the body of this License. 237 | 238 | 9. The Free Software Foundation may publish revised and/or new versions 239 | of the General Public License from time to time. Such new versions will 240 | be similar in spirit to the present version, but may differ in detail to 241 | address new problems or concerns. 242 | 243 | Each version is given a distinguishing version number. If the Program 244 | specifies a version number of this License which applies to it and "any 245 | later version", you have the option of following the terms and conditions 246 | either of that version or of any later version published by the Free 247 | Software Foundation. If the Program does not specify a version number of 248 | this License, you may choose any version ever published by the Free Software 249 | Foundation. 250 | 251 | 10. If you wish to incorporate parts of the Program into other free 252 | programs whose distribution conditions are different, write to the author 253 | to ask for permission. For software which is copyrighted by the Free 254 | Software Foundation, write to the Free Software Foundation; we sometimes 255 | make exceptions for this. Our decision will be guided by the two goals 256 | of preserving the free status of all derivatives of our free software and 257 | of promoting the sharing and reuse of software generally. 258 | 259 | NO WARRANTY 260 | 261 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 262 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 263 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 264 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 265 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 266 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 267 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 268 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 269 | REPAIR OR CORRECTION. 270 | 271 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 272 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 273 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 274 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 275 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 276 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 277 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 278 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 279 | POSSIBILITY OF SUCH DAMAGES. 280 | 281 | END OF TERMS AND CONDITIONS 282 | 283 | How to Apply These Terms to Your New Programs 284 | 285 | If you develop a new program, and you want it to be of the greatest 286 | possible use to the public, the best way to achieve this is to make it 287 | free software which everyone can redistribute and change under these terms. 288 | 289 | To do so, attach the following notices to the program. It is safest 290 | to attach them to the start of each source file to most effectively 291 | convey the exclusion of warranty; and each file should have at least 292 | the "copyright" line and a pointer to where the full notice is found. 293 | 294 | 295 | Copyright (C) 296 | 297 | This program is free software; you can redistribute it and/or modify 298 | it under the terms of the GNU General Public License as published by 299 | the Free Software Foundation; either version 2 of the License, or 300 | (at your option) any later version. 301 | 302 | This program is distributed in the hope that it will be useful, 303 | but WITHOUT ANY WARRANTY; without even the implied warranty of 304 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 305 | GNU General Public License for more details. 306 | 307 | You should have received a copy of the GNU General Public License 308 | along with this program; if not, write to the Free Software 309 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 310 | 311 | 312 | Also add information on how to contact you by electronic and paper mail. 313 | 314 | If the program is interactive, make it output a short notice like this 315 | when it starts in an interactive mode: 316 | 317 | Gnomovision version 69, Copyright (C) year name of author 318 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 319 | This is free software, and you are welcome to redistribute it 320 | under certain conditions; type `show c' for details. 321 | 322 | The hypothetical commands `show w' and `show c' should show the appropriate 323 | parts of the General Public License. Of course, the commands you use may 324 | be called something other than `show w' and `show c'; they could even be 325 | mouse-clicks or menu items--whatever suits your program. 326 | 327 | You should also get your employer (if you work as a programmer) or your 328 | school, if any, to sign a "copyright disclaimer" for the program, if 329 | necessary. Here is a sample; alter the names: 330 | 331 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 332 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 333 | 334 | , 1 April 1989 335 | Ty Coon, President of Vice 336 | 337 | This General Public License does not permit incorporating your program into 338 | proprietary programs. If your program is a subroutine library, you may 339 | consider it more useful to permit linking proprietary applications with the 340 | library. If this is what you want to do, use the GNU Library General 341 | Public License instead of this License. 342 | --------------------------------------------------------------------------------