Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop to main #44

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions ContentModification/ExtendedGraphicStates/ExtendedGraphicStates.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using Datalogics.PDFL;
using System;

/*
*
Expand All @@ -12,7 +10,7 @@
*
* This sample program shows how to use the Extended Graphic State object to add graphics parameters to an image.
*
* Copyright (c) 2007-2023, Datalogics, Inc. All rights reserved.
* Copyright (c) 2007-2024, Datalogics, Inc. All rights reserved.
*
*/

Expand All @@ -37,22 +35,34 @@ static void blendPage(Document doc, Image foregroundImage, Image backgroundImage
gsText.FillColor = new Color(0, 0, 1.0);
TextState ts = new TextState();

double spaceFactor = 18.0;
double heightOffset = height - 88.0;

for (int i = 0; i < 16; i++)
{
Image individualForegroundImage = foregroundImage.Clone();
Image individualBackgroundImage = backgroundImage.Clone();

GraphicState gs = individualForegroundImage.GraphicState;
individualForegroundImage.Scale(0.125, 0.125);
individualForegroundImage.Translate(800, 200 + height * (7 - i));
individualBackgroundImage.Scale(0.125, 0.125);
individualBackgroundImage.Translate(800, 200 + height * (7 - i));

// Halfway through, create 2nd column by shifting over and up
spaceFactor = 18.0;
if (i == 0)
{
spaceFactor = 0;
}

//Halfway through, create 2nd column by shifting over and up
if (i > 7)
{
individualForegroundImage.Translate(2400, height * 8);
individualBackgroundImage.Translate(2400, height * 8);
individualForegroundImage.Translate(400, heightOffset - (72.0 + spaceFactor) * (i - 8));
individualBackgroundImage.Translate(400, heightOffset - (72.0 + spaceFactor) * (i - 8));
}
else
{
individualForegroundImage.Translate(100, heightOffset - (72.0 + spaceFactor) * i);
individualBackgroundImage.Translate(100, heightOffset - (72.0 + spaceFactor) * i);
}

docpage.Content.AddElement(individualBackgroundImage);
Expand All @@ -62,9 +72,14 @@ static void blendPage(Document doc, Image foregroundImage, Image backgroundImage

Matrix m = new Matrix();
if (i > 7)
m = m.Translate(480, 750 - ((i - 8) * 100)); // second column
{
m = m.Translate(480, heightOffset - (72.0 + spaceFactor) * (i - 8));// second column
}
else
m = m.Translate(180, 750 - (i * 100)); // first column
{
m = m.Translate(180, heightOffset - (72.0 + spaceFactor) * i);// first column
}

m = m.Scale(12.0, 12.0);

ExtendedGraphicState xgs = new ExtendedGraphicState();
Expand Down Expand Up @@ -193,7 +208,6 @@ static void Main(string[] args)

doc.EmbedFonts();
doc.Save(SaveFlags.Full, sOutput);

}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Forms/ConvertXFAToAcroForms/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
55 changes: 55 additions & 0 deletions Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
}
53 changes: 53 additions & 0 deletions Forms/ConvertXFAToAcroForms/ConvertXFAToAcroForms.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{7e090b4f-0db4-4c40-a48a-40c0111019d5}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ConvertXFAToAcroForms</RootNamespace>
<AssemblyName>ConvertXFAToAcroForms</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="ConvertXFAToAcroForms.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Adobe.PDF.Library.FormsExtension.LM.NETFramework">
<Version>18.*</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
6 changes: 6 additions & 0 deletions Forms/ExportFormsData/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
83 changes: 83 additions & 0 deletions Forms/ExportFormsData/ExportFormsData.cs
Original file line number Diff line number Diff line change
@@ -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!");
}
}
}
}
}
}
53 changes: 53 additions & 0 deletions Forms/ExportFormsData/ExportFormsData.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
<ProjectGuid>{7e090b4f-0db4-4c40-a48a-40c0111019d5}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>ExportFormsData</RootNamespace>
<AssemblyName>ExportFormsData</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="ExportFormsData.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Adobe.PDF.Library.FormsExtension.LM.NETFramework">
<Version>18.*</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
6 changes: 6 additions & 0 deletions Forms/FlattenForms/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
Loading
Loading