-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from datalogics-saharay/FORMEXT-107-add-formse…
…xt-v18-maven-samples FORMEXT-107: Add Java/Maven samples for Forms Extension
- Loading branch information
Showing
12 changed files
with
1,137 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
Forms/ConvertXFAToAcroForms/.idea/runConfigurations/ConvertXFAToAcroForms.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.datalogics.pdfl.samples</groupId> | ||
<artifactId>ConvertXFAToAcroForms</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
<profiles> | ||
<profile> | ||
<id>Windows64</id> | ||
<activation> | ||
<os> | ||
<family>windows</family> | ||
<arch>amd64</arch> | ||
</os> | ||
</activation> | ||
<properties> | ||
<jni.classifier>win-x86-64-jni</jni.classifier> | ||
</properties> | ||
</profile> | ||
<profile> | ||
<id>Linux64</id> | ||
<activation> | ||
<os> | ||
<!-- Use OS <name> instead of <family> because the "unix" <family> also includes Mac --> | ||
<name>Linux</name> | ||
<arch>amd64</arch> | ||
</os> | ||
</activation> | ||
<properties> | ||
<jni.classifier>linux-x86-64-jni</jni.classifier> | ||
</properties> | ||
</profile> | ||
</profiles> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>pdfl</artifactId> | ||
<version>18.36.0</version> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>pdfl</artifactId> | ||
<version>18.36.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>pdfl</artifactId> | ||
<version>18.36.0</version> | ||
<type>zip</type> | ||
<classifier>${jni.classifier}</classifier> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>pdfl</artifactId> | ||
<version>18.36.0</version> | ||
<type>zip</type> | ||
<classifier>resources</classifier> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>pdfl</artifactId> | ||
<version>18.36.0</version> | ||
<classifier>javadoc</classifier> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>forms-extension</artifactId> | ||
<version>18.37.0</version> | ||
<type>pom</type> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>forms-extension</artifactId> | ||
<version>18.37.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>forms-extension</artifactId> | ||
<version>18.37.0</version> | ||
<type>zip</type> | ||
<classifier>${jni.classifier}</classifier> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>forms-extension</artifactId> | ||
<version>18.37.0</version> | ||
<classifier>javadoc</classifier> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>3.0.2</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>unpack-resources</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>unpack</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>pdfl</artifactId> | ||
<classifier>resources</classifier> | ||
<type>zip</type> | ||
<outputDirectory>${project.build.directory}/lib/Resources</outputDirectory> | ||
</artifactItem> | ||
</artifactItems> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>unpack-jni</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>unpack</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>pdfl</artifactId> | ||
<classifier>${jni.classifier}</classifier> | ||
<type>zip</type> | ||
<outputDirectory>${project.build.directory}/lib</outputDirectory> | ||
</artifactItem> | ||
</artifactItems> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>unpack-forms-extension</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>unpack</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>com.datalogics.pdfl</groupId> | ||
<artifactId>forms-extension</artifactId> | ||
<classifier>${jni.classifier}</classifier> | ||
<type>zip</type> | ||
<outputDirectory>${project.build.directory}/lib</outputDirectory> | ||
</artifactItem> | ||
</artifactItems> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>com.datalogics.pdfl.samples.ConvertXFAToAcroForms</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
59 changes: 59 additions & 0 deletions
59
...onvertXFAToAcroForms/src/main/java/com/datalogics/pdfl/samples/ConvertXFAToAcroForms.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.datalogics.pdfl.samples; | ||
|
||
/* | ||
* Converts XFA (Dynamic or Static) fields to AcroForms fields and removes XFA fields. | ||
* | ||
* Copyright (c) 2007-2023, Datalogics, Inc. All rights reserved. | ||
*/ | ||
import com.datalogics.PDFL.*; | ||
import java.util.EnumSet; | ||
public class ConvertXFAToAcroForms | ||
{ | ||
|
||
public static void main(String[] args) throws Throwable { | ||
System.out.println("ConvertXFAToAcroForms sample:"); | ||
|
||
Library lib = new Library(EnumSet.of(LibraryFlags.INIT_FORMS_EXTENSION)); | ||
|
||
try | ||
{ | ||
if (!lib.isFormsExtensionAvailable()) | ||
{ | ||
System.out.println("Forms Plugins were not properly loaded!"); | ||
return; | ||
} | ||
|
||
//Must be set to true to prevent default legacy behavior of PDFL | ||
lib.setAllowOpeningXFA(true); | ||
|
||
System.out.println("Initialized the library."); | ||
|
||
//XFA document | ||
String sInput = Library.getResourceDirectory() + "Sample_Input/DynamicXFA.pdf"; | ||
String sOutput = "../ConvertXFAToAcroForms-out.pdf"; | ||
|
||
if (args.length > 0) | ||
{ | ||
sInput = args[0]; | ||
} | ||
|
||
if (args.length > 1) | ||
{ | ||
sOutput = args[1]; | ||
} | ||
|
||
Document doc = new Document(sInput); | ||
long pagesOutput = doc.convertXFAFieldsToAcroFormFields(); | ||
|
||
System.out.println("XFA document was converted into AcroForms document with " + pagesOutput + " pages."); | ||
|
||
doc.save(EnumSet.of(SaveFlags.FULL, SaveFlags.LINEARIZED), sOutput); | ||
|
||
doc.delete(); | ||
} | ||
finally { | ||
lib.delete(); | ||
} | ||
} | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
Forms/ExportFormsData/.idea/runConfigurations/ExportFormsData.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.