How to Build PDF3D-SDK C# .NET Examples with Visual Studio

How to Build PDF3D-SDK C# .NET Examples with Visual Studio

This article illustrates the process of building an example C# .NET console application from the PDF3D-SDK developer toolkit package. This goes through configuration, Compiling, Running and viewing the output 3D PDF. Using this combination of tools, new 3D PDF desktop applications for MS-Windows can be created with the ability to generate interactive 3D PDF document files. The process is broken down into 12 simple steps (for C++ see How to Build PDF3D-SDK Examples with CMake and Visual Studio SLN).


Video: Developing C# 3D PDF Apps

How to Build with C# .NET

  1. First up, install the PDF3D-SDK package and activate the license. Contact [email protected] if you’d like to discuss trying this process. Once installed, the PDF3D-SDK folder structure is available. Here there are several small C# source-code examples provided for training, getting started, and to illustrate various features available in the SDK. The SDK can be installed anywhere; however, it should be open for full read-write permissions since the example will be compiled inside this folder structure. The file-path to the C# examples is typically PDF3D-SDK/interfaces/swig/Examples/.

  1. Next startup a fresh new Microsoft Visual Studio session. In this example VS2017 is shown. Use File-New-Project to create a new application.

  1. Select a new application type as a typical generic Windows Desktop Console app using C# .NET development tools. This dialog provides type default setup application name of ConsoleApp1 at C:\Users\[username]\source\repos using Framework: .NET Framework 4.6.1.

  1. This step will create a new application development project, with default settings of Debug, Any CPU, and a short auto-generated template code sample, called ConsoleApp1.

  1. Navigate to the PDF3D-SDK/interfaces/swig/Examples/ folder and copy-paste the contents from MixedSurfaceLinesIS.cs (C# source code sample), replacing the auto-generated code, and push SAVE.

  1. The supporting reference DLLs must be added to the project, so use the right-mouse drop down menu on the ConsoleApp1 project to select the Add-Reference browser.

  1. The primary resource required is VTSL.PDF3D.Core.dll, which can typically be found in PDF3D-SDK/bin/VS2017. Select this and load it into the project references.

  1. Once the reference is specified, the new entry appears in the ConsoleApp1 project menu.

  1. A further small configuration setting should be applied to change the default “Any CPU” to “x64” as the version of PDF3D-SDK installed supports 64-bit applications. An additional package should be installed if 32-bit is required.

  1. Once the project settings and code are configured and saved, the project can be compiled to create the new app. Push “Build Solution” and note the completion message in the log window, showing that the application ConsoleApp1.exe has been created. The PDF3D-SDK comes with both release and debug libraries, so it is totally a user choice to select Debug or Release.

  1. Navigating to where the new application has been created, the executable and supporting files are typically created in the default [username]/source/repos/ConsoleApp1/ConsoleApp1/bin/x64/Debug/.
    A further DLL is required, manually copy the PDF3DCSharp.dll file typically from which can typically be found in PDF3D-SDK/bin/VS2017/ into the local folder, along side the VTSL.PDF3D.Core.dll .NET resource. NOTE: Other DLLs may be needed if additional methods are used from the PDF3D-SDK API.

  1. Once the supporting runtime files are copied, it’s time to actually run the new program! Use the Visual Studio Debug – Start Debugging menu, or just double click on the ConsoleApp1.exe program file.

  1. Once the program has run, generated the output PDF and stopped, the PDF file can be opened and viewed in the free Adobe Reader DC or Adobe Acrobat Pro. In this example it has a 3D view with a stair-step surface, blue mesh lines title, and gradient background. For this example the filename matches the example program, and is MixedSurfaceLinesIS.pdf.

Summary – C# App Builds and Generates 3D PDF File

In summary, C# .NET solutions for creating 3D PDF files are easily created for Windows desktop environments, using Microsoft Visual Studio and just a couple of files from the PDF3D-SDK package. Many of the PDF3D-SDK examples can be built in a similar way using this method, with the extensive, rich API available to precisely control the 3D PDF output contents.

Please get in touch to let us know if this walk-through is helpful, or for any further questions.

Also Watch the Video Demonstration of these steps.

For more information about PDF3D-SDK see https://www.pdf3d.com/products/pdf3d-sdk/