Some test text!
Welcome to PDFTron. Currently, .NET Framework for the PDFTron SDK is only supported on Windows.
This guide will help you run PDFTron samples and integrate a free trial of the PDFTron SDK into .NET Framework applications on Windows. Your free trial includes unlimited trial usage and support from solution engineers.
Make sure that the
.NET Desktop Development and
.NET Framework 4.5.1+ development tools workload is part of your installation.
This guide will use Visual Studio 2017.
PDFTron's C# .NET PDF Library for Windows:
This article uses
PDFNET_BASE as the path into the folder that you extracted.
PDFNET_BASE = path/to/extraction/folder/PDFNetDotNet4/
Navigate to the location of extracted contents. Find and enter the
Samples folder (
PDFNET_BASE/Samples). Here you can find sample code for a large number of features supported by the PDFTron SDK.
Samples_20XX.sln in Visual Studio. Choose an appropriate version for your Visual Studio installation.
Find the sample you want to run and set it as the Startup Project for the solution.
Run the project.
This is called the "PDFTron Hello World" application. It is easy to integrate the rest of PDFTron SDK if you are able to open, save and close a PDFDoc.
Create a new .NET Framework console application project in Visual Studio for your preferred language. You can find them under the
Visual C# or
Visual Basic category.
Navigate into your project's folder. By default, the path should be similar to:
Lib folder from
PDFNET_BASE to your project folder (the folder which contains your
Find the Solution Explorer to the right. Right-click on References and select the Add reference option. This opens a Reference Manager dialog.
Browse... at the bottom of the dialog. Navigate to the copied
Lib folder and add
PDFNetLoader.dll to the references.
Also add the appropriate version of
PDFNet.dll from the x86 folder as another reference (
path/to/your/project/folder/Lib/PDFNet/x86/PDFNet.dll). This version will allow the application to run on both 32-bit and 64-bit OS.
PDFNet.dll and set its Copy Local property to False.
Open App.config in the solution explorer and make sure the loadFromRemoteSources property is set to true:
<configuration> <runtime> <loadFromRemoteSources enabled="true" /> </runtime> </configuration>
Right click on your project and select Properties. In the left pane, select the Build Events tab. Under Post-Build Events, add the following code snippet:
xcopy $(ProjectDir)Lib\PDFNet $(TargetDir)PDFNet /S /I /Y
Replace the contents of
'Default namespace Imports System 'Majority of PDFTron SDK can be used with these namespaces Imports pdftron Imports pdftron.Common Imports pdftron.SDF Imports pdftron.PDF Module Module1 'Required for AnyCPU implementation. Dim pdfNetLoader As PDFNetLoader Sub New() pdfNetLoader = pdftron.PDFNetLoader.Instance() End Sub Sub Main() ' Initialize PDFNet before using any PDFTron related ' classes and methods (some exceptions can be found in API) PDFNet.Initialize(); ' Using PDFNet related classes and methods, ' must catch or throw PDFNetException Try Using doc As PDFDoc = New PDFDoc ' An example of creating a new page and adding it to ' doc's sequence of pages Dim page As Page = doc.PageCreate() doc.PagePushBack(newPg) ' Save as a linearized file which is most popular ' and effective format for quick PDF Viewing. doc.Save("linearized_output.pdf", SDFDoc.SaveOptions.e_linearized) Console.WriteLine("Done. Results saved in linearized_output.pdf") End Using Catch e As PDFNetException Console.WriteLine(e) End Try End Sub End Module
Build and run the project using the
Start button in Visual Studio.
You should find the "linearized_output.pdf" in your project folder with a blank page.
The steps above allow you to create an application that can support both 32bit or 64bit processes at runtime. However, this is often not needed in practice.
If you know you are targeting only 64bit, or 32bit, then reference the corresponding 32bit or 64bit PDFNet.dll assembly in your solution (make sure
copylocal:true is set), and remove both PDFNetLoader.dll and the one line of code for PDFNetLoader.
If on the other hand you are writing a client application, where you need to support both 64bit and 32bit, then simply using your installer to install the correct 32bit or 64bit PDFNet.dll, and omit PDFNetLoader.dll, is typically the best way to proceed.
In summary, PDFNetLoader.dll is not required, and is just used for AnyCPU 32bit/64bit handling. To know more about PDFNetLoader see [this post])https://www.pdftron.com/blog/dotnet/dotnet-pdf-control-nuget).
Get the answers you need: Support