PDF Generation Template Editor
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.
Enter the sample folder and run the example from the command line:
If you receive an error message bash:/ Test. sh: Permission denied, you need to enter the following command:
chmod +x run.shYou can follow the manual or nuget integration described below for operation. This section will help you build your first ComPDFKit application. If you can open, save, and close PDFDoc, you can easily integrate the rest of the ComPDF PDF SDK.
Create a new project named ComPDFKit Demo_ through the console
mkdir ComPDFKitDemo
cd ComPDFKitDemo
dotnet new console -o "ComPDFKit Demo"Copy the ComPDFKitNative.dylib file and the ComPDFKit.NET.dll file to the project folder.
Add the following code to the .csproj file:
<ItemGroup>
<Reference Include="ComPDFKit.NET.dll">
<HintPath>ComPDFKit.NET.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="ComPDFKitNative.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>Your final ComPDFKit Demo.csproj file should look like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Reference Include="ComPDFKit.NET.dll">
<HintPath>ComPDFKit.NET.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Content Include="ComPDFKitNative.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>Create a new project named ComPDFKit Demo in the console:
mkdir ComPDFKitDemo
cd ComPDFKitDemo
dotnet new console -o "ComPDFKit Demo"Go to the project folder and install the ComPDFKit.NetCore NuGet package:
dotnet add package ComPDFKit.NetCoreWe have completed all the preparation steps. Now let us use ComPDF PDF SDK to create a PDF file with a blank page. Replace your Program.cs file with the following code. Note: You need to specify the path to your license key XML file in the LicenseVerify() method.
using ComPDFKit.NativeMethod;
using ComPDFKit.PDFDocument;
using System.Reflection.Metadata;
namespace ComPDFKit_Demo
{
public class Program
{
private static bool LicenseVerify()
{
if (!CPDFSDKVerifier.LoadNativeLibrary())
return false;
string xmlPath = "The path to your license key XML file";
LicenseErrorCode verifyResult = CPDFSDKVerifier.LicenseVerify(xmlPath);
return (verifyResult == LicenseErrorCode.E_LICENSE_SUCCESS);
}
public static void Main()
{
LicenseVerify();
CPDFDocument document = CPDFDocument.CreateDocument();
int pageIndex = 0;
int pageWidth = 595;
int pageHeight = 842;
document.InsertPage(pageIndex, pageWidth, pageHeight, "");
document.WriteToFilePath("new_file.pdf");
Console.WriteLine("Done. Results saved in new_file.pdf");
}
}
}Now you can run the program from the command line:
dotnet runYou will now find the new_file.pdf file in the program output directory, which is a PDF file with a blank page.