From 2ecf6ea22fe6b6a971a1b2bdb5253e07d10ea2d6 Mon Sep 17 00:00:00 2001 From: Joseph Argento Date: Tue, 3 Dec 2024 10:12:58 -0600 Subject: [PATCH 1/2] Add FormsExtension .NET Framework samples. --- Forms/ConvertXFAToAcroForms/App.config | 6 ++ .../ConvertXFAToAcroForms.cs | 55 ++++++++++++ .../ConvertXFAToAcroForms.csproj | 54 ++++++++++++ Forms/ExportFormsData/App.config | 6 ++ Forms/ExportFormsData/ExportFormsData.cs | 83 +++++++++++++++++ Forms/ExportFormsData/ExportFormsData.csproj | 54 ++++++++++++ Forms/FlattenForms/App.config | 6 ++ Forms/FlattenForms/FlattenForms.cs | 72 +++++++++++++++ Forms/FlattenForms/FlattenForms.csproj | 54 ++++++++++++ Forms/ImportFormsData/App.config | 6 ++ Forms/ImportFormsData/ImportFormsData.cs | 88 +++++++++++++++++++ Forms/ImportFormsData/ImportFormsData.csproj | 54 ++++++++++++ Forms/README.md | 40 +++++++++ 13 files changed, 578 insertions(+) create mode 100644 Forms/ConvertXFAToAcroForms/App.config create mode 100644 Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.cs create mode 100644 Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj create mode 100644 Forms/ExportFormsData/App.config create mode 100644 Forms/ExportFormsData/ExportFormsData.cs create mode 100644 Forms/ExportFormsData/ExportFormsData.csproj create mode 100644 Forms/FlattenForms/App.config create mode 100644 Forms/FlattenForms/FlattenForms.cs create mode 100644 Forms/FlattenForms/FlattenForms.csproj create mode 100644 Forms/ImportFormsData/App.config create mode 100644 Forms/ImportFormsData/ImportFormsData.cs create mode 100644 Forms/ImportFormsData/ImportFormsData.csproj create mode 100644 Forms/README.md diff --git a/Forms/ConvertXFAToAcroForms/App.config b/Forms/ConvertXFAToAcroForms/App.config new file mode 100644 index 0000000..aad6a5e --- /dev/null +++ b/Forms/ConvertXFAToAcroForms/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.cs b/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.cs new file mode 100644 index 0000000..8e17c88 --- /dev/null +++ b/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.cs @@ -0,0 +1,55 @@ +using System; +using Datalogics.PDFL; + +/* + * + * The ConvertXFAToAcroForms sample demonstrates how to convert XFA into AcroForms. + * Converts XFA (Dynamic or Static) fields to AcroForms fields and removes XFA fields. + * Copyright (c) 2024, Datalogics, Inc. All rights reserved. + * + */ +namespace ConvertXFAToAcroForms +{ + class ConvertXFAToAcroForms + { + static void Main(string[] args) + { + Console.WriteLine("ConvertXFAToAcroForms Sample:"); + + using (Library lib = new Library(LibraryFlags.InitFormsExtension)) + { + if (!lib.IsFormsExtensionAvailable()) + { + System.Console.Out.WriteLine("Forms Plugins were not properly loaded!"); + return; + } + + lib.AllowOpeningXFA = true; + + Console.WriteLine("Initialized the library."); + + String sInput = Library.ResourceDirectory + "Sample_Input/DynamicXFA.pdf"; + String sOutput = "../ConvertXFAToAcroForms-out.pdf"; + + if (args.Length > 0) + { + sInput = args[0]; + } + + if (args.Length > 1) + { + sOutput = args[1]; + } + + using (Document doc = new Document(sInput)) + { + UInt32 pagesOutput = doc.ConvertXFAFieldsToAcroFormFields(); + + Console.WriteLine("XFA document was converted into an AcroForms document with {0} pages.", pagesOutput); + + doc.Save(SaveFlags.Full | SaveFlags.Linearized, sOutput); + } + } + } + } +} diff --git a/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj b/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj new file mode 100644 index 0000000..9887c2e --- /dev/null +++ b/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj @@ -0,0 +1,54 @@ + + + + + Debug + x64 + {7e090b4f-0db4-4c40-a48a-40c0111019d5} + Exe + ConvertXFAToAcroForms + ConvertXFAToAcroForms + v4.7.2 + 512 + true + true + + + + + x64 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x64 + pdbonly + false + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + 18.* + + + + diff --git a/Forms/ExportFormsData/App.config b/Forms/ExportFormsData/App.config new file mode 100644 index 0000000..aad6a5e --- /dev/null +++ b/Forms/ExportFormsData/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Forms/ExportFormsData/ExportFormsData.cs b/Forms/ExportFormsData/ExportFormsData.cs new file mode 100644 index 0000000..7431b45 --- /dev/null +++ b/Forms/ExportFormsData/ExportFormsData.cs @@ -0,0 +1,83 @@ +using System; +using Datalogics.PDFL; + +/* + * The ExportFormsData sample demonstrates how to Export forms data from XFA and AcroForms documents: + * + * - Export data from a XFA (Dynamic or Static) document, the types supported include XDP, XML, or XFD + * - Export data from an AcroForms document, the types supported include XFDF, FDF, or XML + * + * Copyright (c) 2024, Datalogics, Inc. All rights reserved. + * + */ +namespace ExportFormsData +{ + class ExportFormsData + { + static void Main(string[] args) + { + Console.WriteLine("ExportFormsData Sample:"); + + using (Library lib = new Library(LibraryFlags.InitFormsExtension)) + { + if (!lib.IsFormsExtensionAvailable()) + { + System.Console.Out.WriteLine("Forms Plugins were not properly loaded!"); + return; + } + + lib.AllowOpeningXFA = true; + + Console.WriteLine("Initialized the library."); + + //XFA document + String sInput = Library.ResourceDirectory + "Sample_Input/DynamicXFA.pdf"; + String sOutput = "../ExportFormsDataXFA.xdp"; + + if (args.Length > 0) + { + sOutput = args[0]; + } + + using (Document doc = new Document(sInput)) + { + //Export the data while specifying the type, in this case XDP + bool result = doc.ExportXFAFormsData(sOutput, XFAFormExportType.XDP); + + if (result) + { + Console.Out.WriteLine("Forms data was exported!"); + } + else + { + Console.Out.WriteLine("Exporting of Forms data failed!"); + } + } + + //AcroForms document + sInput = Library.ResourceDirectory + "Sample_Input/AcroForm.pdf"; + sOutput = "../ExportFormsDataAcroForms.xfdf"; + + if (args.Length > 1) + { + sOutput = args[1]; + } + + using (Document doc = new Document(sInput)) + { + //Export the data while specifying the type, in this case XFDF + bool result = doc.ExportAcroFormsData(sOutput, AcroFormExportType.XFDF); + + if (result) + { + Console.Out.WriteLine("Forms data was exported!"); + } + else + { + Console.Out.WriteLine("Exporting of Forms data failed!"); + } + } + } + } + } +} diff --git a/Forms/ExportFormsData/ExportFormsData.csproj b/Forms/ExportFormsData/ExportFormsData.csproj new file mode 100644 index 0000000..1cedfa9 --- /dev/null +++ b/Forms/ExportFormsData/ExportFormsData.csproj @@ -0,0 +1,54 @@ + + + + + Debug + x64 + {7e090b4f-0db4-4c40-a48a-40c0111019d5} + Exe + ExportFormsData + ExportFormsData + v4.7.2 + 512 + true + true + + + + + x64 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x64 + pdbonly + false + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + 18.* + + + + diff --git a/Forms/FlattenForms/App.config b/Forms/FlattenForms/App.config new file mode 100644 index 0000000..aad6a5e --- /dev/null +++ b/Forms/FlattenForms/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Forms/FlattenForms/FlattenForms.cs b/Forms/FlattenForms/FlattenForms.cs new file mode 100644 index 0000000..f87c778 --- /dev/null +++ b/Forms/FlattenForms/FlattenForms.cs @@ -0,0 +1,72 @@ +using System; +using Datalogics.PDFL; + +/* + * + * The FlattenForms sample demonstrates how to Flatten XFA into AcroForms. + * + * - Flatten XFA (Dynamic or Static) to regular page content which converts and expands XFA fields to regular PDF content and removes the XFA fields. + * - Flatten AcroForms to regular page content which converts AcroForm fields to regular page content and removes the AcroForm fields. + * Copyright (c) 2024, Datalogics, Inc. All rights reserved. + * + */ +namespace FlattenForms +{ + class FlattenForms + { + static void Main(string[] args) + { + Console.WriteLine("FlattenForms Sample:"); + + using (Library lib = new Library(LibraryFlags.InitFormsExtension)) + { + if (!lib.IsFormsExtensionAvailable()) + { + System.Console.Out.WriteLine("Forms Plugins were not properly loaded!"); + return; + } + + //Must be set to true to prevent default legacy behavior of PDFL + lib.AllowOpeningXFA = true; + + Console.WriteLine("Initialized the library."); + + //XFA document + String sInput = Library.ResourceDirectory + "Sample_Input/DynamicXFA.pdf"; + String sOutput = "../FlattenXFA-out.pdf"; + + if (args.Length > 0) + { + sInput = args[0]; + } + + if (args.Length > 1) + { + sOutput = args[1]; + } + + using (Document doc = new Document(sInput)) + { + UInt32 pagesOutput = doc.FlattenXFAFormFields(); + + Console.WriteLine("XFA document was expanded into {0} Flattened pages.", pagesOutput); + + doc.Save(SaveFlags.Full | SaveFlags.Linearized, sOutput); + } + + //AcroForms document + sInput = Library.ResourceDirectory + "Sample_Input/AcroForm.pdf"; + sOutput = "../FlattenAcroForms-out.pdf"; + + using (Document doc = new Document(sInput)) + { + doc.FlattenAcroFormFields(); + + Console.WriteLine("AcroForms document was Flattened."); + + doc.Save(SaveFlags.Full | SaveFlags.Linearized, sOutput); + } + } + } + } +} diff --git a/Forms/FlattenForms/FlattenForms.csproj b/Forms/FlattenForms/FlattenForms.csproj new file mode 100644 index 0000000..2b9b927 --- /dev/null +++ b/Forms/FlattenForms/FlattenForms.csproj @@ -0,0 +1,54 @@ + + + + + Debug + x64 + {7e090b4f-0db4-4c40-a48a-40c0111019d5} + Exe + FlattenForms + FlattenForms + v4.7.2 + 512 + true + true + + + + + x64 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x64 + pdbonly + false + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + 18.* + + + + diff --git a/Forms/ImportFormsData/App.config b/Forms/ImportFormsData/App.config new file mode 100644 index 0000000..aad6a5e --- /dev/null +++ b/Forms/ImportFormsData/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Forms/ImportFormsData/ImportFormsData.cs b/Forms/ImportFormsData/ImportFormsData.cs new file mode 100644 index 0000000..e8a35bd --- /dev/null +++ b/Forms/ImportFormsData/ImportFormsData.cs @@ -0,0 +1,88 @@ +using System; +using Datalogics.PDFL; + +/* + * The ImportFormsData sample demonstrates how to Import forms data into XFA and AcroForms documents: + * + * - Import data into a XFA (Dynamic or Static) document, the types supported include XDP, XML, or XFD + * - Import data into an AcroForms document, the types supported include XFDF, FDF, or XML + * + * Copyright (c) 2024, Datalogics, Inc. All rights reserved. + */ +namespace ImportFormsData +{ + class ImportFormsData + { + static void Main(string[] args) + { + Console.WriteLine("ImportFormsData Sample:"); + + using (Library lib = new Library(LibraryFlags.InitFormsExtension)) + { + if (!lib.IsFormsExtensionAvailable()) + { + System.Console.Out.WriteLine("Forms Plugins were not properly loaded!"); + return; + } + + lib.AllowOpeningXFA = true; + + Console.WriteLine("Initialized the library."); + + //XFA document + String sInput = Library.ResourceDirectory + "Sample_Input/DynamicXFA.pdf"; + String sInputData = Library.ResourceDirectory + "Sample_Input/DynamicXFA_data.xdp"; + String sOutput = "../ImportFormsDataXFA-out.pdf"; + + if (args.Length > 0) + { + sOutput = args[0]; + } + + using (Document doc = new Document(sInput)) + { + //Import the data, acceptable types include XDP, XML, and XFD + bool result = doc.ImportXFAFormsData(sInputData); + + if (result) + { + Console.Out.WriteLine("Forms data was imported!"); + + doc.Save(SaveFlags.Full | SaveFlags.Linearized, sOutput); + } + else + { + Console.Out.WriteLine("Importing of Forms data failed!"); + } + } + + //AcroForms document + sInput = Library.ResourceDirectory + "Sample_Input/AcroForm.pdf"; + sInputData = Library.ResourceDirectory + "Sample_Input/AcroForm_data.xfdf"; + sOutput = "../ImportFormsDataAcroForms-out.pdf"; + + if (args.Length > 1) + { + sOutput = args[1]; + } + + using (Document doc = new Document(sInput)) + { + //Import the data while specifying the type, in this case XFDF + bool result = doc.ImportAcroFormsData(sInputData, AcroFormImportType.XFDF); + + if (result) + { + Console.Out.WriteLine("Forms data was imported!"); + + doc.Save(SaveFlags.Full | SaveFlags.Linearized, sOutput); + } + else + { + Console.Out.WriteLine("Importing of Forms data failed!"); + } + } + } + } + } +} diff --git a/Forms/ImportFormsData/ImportFormsData.csproj b/Forms/ImportFormsData/ImportFormsData.csproj new file mode 100644 index 0000000..0a9a753 --- /dev/null +++ b/Forms/ImportFormsData/ImportFormsData.csproj @@ -0,0 +1,54 @@ + + + + + Debug + x64 + {7e090b4f-0db4-4c40-a48a-40c0111019d5} + Exe + ImportFormsData + ImportFormsData + v4.7.2 + 512 + true + true + + + + + x64 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x64 + pdbonly + false + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + 18.* + + + + diff --git a/Forms/README.md b/Forms/README.md new file mode 100644 index 0000000..ea01757 --- /dev/null +++ b/Forms/README.md @@ -0,0 +1,40 @@ +![LatestVersion](https://img.shields.io/nuget/v/Adobe.PDF.Library.FormsExtension.LM.NETFramework?color=informational&label=latest&style=plastic) +![Download Counter](https://img.shields.io/nuget/dt/Adobe.PDF.Library.FormsExtension.LM.NETFramework?color=blue&label=downloads&logo=NuGet&style=plastic) +![Windows](https://img.shields.io/badge/Windows-✓-blue?style=plastic&logo=windows&labelColor=blue) +![VisualStudio](https://img.shields.io/badge/Visual%20Studio-✓-blue?style=plastic&logo=visualstudio&labelColor=blue) +# ![Logo](https://raw.github.com/datalogics/dl-icons/develop/DLBanner_Nuget.png) +# Adobe PDF Library Forms Extension for .NET Framework, 64-bit, Free Trial + +To activate the free trial: +1. Visit [Free Trial](https://www.datalogics.com/pdf-form-functions) to obtain an activation key. +2. A prompt will appear on your console when executing Datalogics sample code. + +Alternatively, you may provide the activation key via the LicenseKey member of the Library class: +``` +Library.LicenseKey = "xxxx-xxxx-xxxx-xxxx"; +using (Library lib = new Library()) +{ + //APDFL Code +} +``` +This package supports **x64** Windows and is a full-featured version of the product that will expire after some time. Contact **evalsupport@datalogics.com** to extend the evaluation. + +[Samples](https://github.com/datalogics/apdfl-csharp-dotnet-framework-samples/tree/main/Forms) | [Documentation](https://docs.datalogics.com/apdfl18/DotNetFramework/index.html) | [Release Notes](https://dev.datalogics.com/adobe-pdf-library/release-notes) | [Support](https://www.datalogics.com/tech-support-pdfs) | [Homepage](https://www.datalogics.com/) + +Forms Extension SDK is an Adobe PDF Library addition that helps users who work with PDF forms to efficiently manage their forms processes. Import and export form data, lock completed forms to prevent editing and provide consistent viewing experiences across all devices. + +Forms Extension Uses: + +* Adobe PDF Library customers who need additional forms support +* Incorporating forms functionality into your own applications +* Processing PDFs containing XFA form content +* Using dynamic forms that require customization +* Using database content to populate form fields +* Exporting form data to populate databases +* Conditionally preventing form editing (for example: after submission) + +Built upon Adobe source code used for Acrobat, Datalogics Adobe PDF Library SDK provides stable, reliable code and the flexibility to develop with C# or VB (VB.NET) (interfaces are also available for C++ and Java). APDFL is the most complete SDK for PDF creation, manipulation and management. Leading choice for enterprise/larger organizations of developers and independent software vendors (ISVs) who need to incorporate Adobe's PDF functionality into their own internal or external applications. + +Live support from PDF development experts. + +Licensing and Pricing options are customized to your usage and requirements. For OEM and SaaS customers we will provide you with a non-license managed software package for easier distribution embedded within your applications. From 7be8ad5dda9313434091facd02634c7182d06607 Mon Sep 17 00:00:00 2001 From: Joseph Argento Date: Tue, 3 Dec 2024 13:09:35 -0600 Subject: [PATCH 2/2] Update url of release notes and fix project settings. --- Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj | 1 - Forms/ExportFormsData/ExportFormsData.csproj | 1 - Forms/FlattenForms/FlattenForms.csproj | 1 - Forms/ImportFormsData/ImportFormsData.csproj | 1 - README.md | 2 +- 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj b/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj index 9887c2e..ac50b63 100644 --- a/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj +++ b/Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj @@ -40,7 +40,6 @@ - diff --git a/Forms/ExportFormsData/ExportFormsData.csproj b/Forms/ExportFormsData/ExportFormsData.csproj index 1cedfa9..e57924d 100644 --- a/Forms/ExportFormsData/ExportFormsData.csproj +++ b/Forms/ExportFormsData/ExportFormsData.csproj @@ -40,7 +40,6 @@ - diff --git a/Forms/FlattenForms/FlattenForms.csproj b/Forms/FlattenForms/FlattenForms.csproj index 2b9b927..0e237c1 100644 --- a/Forms/FlattenForms/FlattenForms.csproj +++ b/Forms/FlattenForms/FlattenForms.csproj @@ -40,7 +40,6 @@ - diff --git a/Forms/ImportFormsData/ImportFormsData.csproj b/Forms/ImportFormsData/ImportFormsData.csproj index 0a9a753..f3f82a0 100644 --- a/Forms/ImportFormsData/ImportFormsData.csproj +++ b/Forms/ImportFormsData/ImportFormsData.csproj @@ -40,7 +40,6 @@ - diff --git a/README.md b/README.md index b14b13c..0ee6baf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![Datalogics Adobe PDF Library](https://raw.github.com/datalogics/dl-icons/develop/DLBanner_Nuget.png) -[Documentation](https://docs.datalogics.com/apdfl18/DotNetFramework/index.html)  |   [Support](https://www.datalogics.com/tech-support-pdfs/)   |   [Release Notes](https://docs.datalogics.com/apdfl18/Release_Notes.html)   |  [Homepage](https://www.datalogics.com) +[Documentation](https://docs.datalogics.com/apdfl18/DotNetFramework/index.html)  |   [Support](https://www.datalogics.com/tech-support-pdfs/)   |   [Release Notes](https://dev.datalogics.com/adobe-pdf-library/release-notes)   |  [Homepage](https://www.datalogics.com) [![Download a Free Trial on NuGet](https://img.shields.io/nuget/dt/Adobe.PDF.Library.LM.NETFramework?color=blue&label=APDFL%20.NET%20Framework%20Free%20Trial&logo=NuGet&style=plastic)](https://www.nuget.org/packages/Adobe.PDF.Library.LM.NETFramework)