Some test text!

Common questions and issueskeyboard_arrow_down

Common questions and issues

In this document
chevron_rightCommon Questions
chevron_rightWorking in a server context
chevron_rightRegistry access in the demo version
chevron_rightVisual Studio web server
chevron_rightIIS servers
chevron_rightFile conversions within a Windows service or ASP.Net application
chevron_rightOther common issues
chevron_rightNext steps

linkCommon Questions

Listed below are a few of the common questions and queries that receive often.

Q: Where should I call the PDFNet.Initialize()?
A:PDFNet.Initialize("YOUR_PDFTRON_LICENSE_KEY_GOES_HERE") must be called before any other call to PDFNet. The best location would be your application start-up function (such as main(), OnAppStart(), or DLLMain() etc. - depending on our application type and development platform).

Q: How should I handle the Initialize() and Terminate() calls of the PDFNet library?
A: Please see above for where Initialize() must be called. Terminate() method is currently a no-op in DotNET version and you can safely omit it. Even in C++ or Java version terminate is not required to be called. The main reason for Terminate is to clean up some resources which would be mistakenly reported as memory 'leaks' in memory tracking applications (such as Purify or BoundsChecker etc).

Q: The documentation says that Initialize() is called once, during process initialization, but I have potentially multiple clients using this library concurrently. How should I proceed?
A:Initialize() should be called in your application/library OnInitialize()/Main() method. In case you don't have such method, you could call Initialize() multiple times (PDFNet will make sure that it is initialized only once), you only need to make sure that it is called before any other PDFNet method.

Q: How should I handle the memory management in .NET? I am talking of PDF documents with ~2 thousands pages. I tried to force GC.Collect() but this is a performance penalty for me
A:GC.Collect() is not necessary. You could simply call Dispose() (or Close()) on PDFDoc, PDFDraw, ElementBuilder, ElementWriter, TextExtractor, and other larger objects. All memory will be instantly released. You can also use IDispose pattern (on 'using' C# keyword) to immediately release these resources.

Q: Is there currently "AnyCpu" version of PDFTron PDFNet SDK, or is it only available as 32bit and 64bit versions separately?
A: PDFTron SDK for .NET is a true .NET component and can be used by any .NET language (e.g. C#, VB.NET, etc). The assembly doesn't use PInvoke or COM interop and does not require/depend on other unmanaged non-system components. At the same, PDFNet for .NET, is a 'mixed' component and is not 'verifiable' since it has some native dependencies (e.g. for printer driver support, XPS printing, GDI, efficient image libs, COM interop etc - these features are by definition impossible to do in 'verifiable' .NET components).

'Any CPU' selection means different things in different versions of Visual Studio, however you can definitely make an 'AnyCPU' configuration and make the app work correctly on both x86, x64, and other platforms. The issue is not PDFNet specific any there are many solutions:

  1. The simplest option is to select 'x86' in your project solution. With this option the app will work on both x86 and x64 system.
  2. A bit more complicated option is that you select 'Any CPU' mode in your app. As part of the app install you would copy/install a version of PDFNet that matches the target hardware (i.e. x86, x64). This is possible because both versions have the same signature/cert.
  3. Alternatively you can register both the 32-bit as well as 64-bit DLLs in GAC.
  4. In case you do not want to haver any app 'installer' and you still want to use 'Any CPU' there are also multiple options some which are outlined here http://stackoverflow.com/questions/108971/using-side-by-side-assemblies-to-load-the-x64-or-x32-version-of-a-dll.

linkWorking in a server context

There are a few issues, in particular, that need to be considered when running your application as a service or in a server context. Below are some of the most common situations that you may encounter.

linkRegistry access in the demo version

While you try out PDFTron SDK without a license key, it is running in demo mode. One side effect of this is that your application will need read/write access to the registry. The licensed version does not have this requirement. This is typically a problem only when you run an app using the demo version, in an environment with restricted permissions, such as when developing a Windows service or a server application.

No restrictions in the licensed version
The demo version is not intended for use on production environments. The licensed product does not require registry access to work.

The demo version has been used on servers with tight security by modifying a config xml file that controls security settings or using 'Code Access Security Policy' tool. For more info please see:

linkVisual Studio web server

If you get a BadImageFormatException, incorrect format error, while trying to use the Web Server that comes with Visual Studio, this is because VS Web Server is 32-bit only and cannot be used with any 64-bit libraries. Please see this forum posting for solutions.

linkIIS servers

You may encounter BadImageFormatException, incorrect format exceptions when using PDFNet on IIS. One possible cause can be that you need to match the IIS 'Enable 32-bit application' setting to which version of PDFNet (32 or 64 bit) that you are using. Finally be aware that different versions of IIS default to different versions of the .NET framework, so you also need to match that with the version of PDFNet you are using (.Net 2 or 4).

linkUsing the demo version with IIS

If you are trying to run your demo on an IIS server, you can change the Application Pool’s identity to a User Account with read/write access to the registry.

  1. Go to IIS Manager, select the web server, and then Application Pools.
  2. Click on the Application Pool you are using from the list, then on the Actions panel, under Edit Application Pool, click Advanced Settings...
  3. In the Advanced Settings dialog, go to the Process Model section and click on the Identity to change it.
  4. Once the Application Pool Identity dialog shows up, select Custom account:, then click Set...
  5. Enter the user account information in the Set Credentials dialog box. Note: you may have to specify the domain of the user (i.e. MyServerDomain\MyUserAccount).
  6. Click OK until all dialog boxes are closed.

linkFile conversions within a Windows service or ASP.Net application

Please see Converting Documents for more information regarding converting files to and from PDF in a server context. It also covers MS Office Interop and virtual printer related issues.

linkOther common issues

Error: The evaluation version encountered an error in your system configuration. Please contact customer support at: sup...@pdftron.com. No reg. write rights
Solution: Please see the section above regarding use within a server context.

Error: error LNK2019: unresolved external symbol __imp__TRN_PDFNetInitialize.
Solution: You probably have mixed up the 32bit and 64bit versions of PDFNetC. Make sure that the DLL architecture matches the project platform setting.

Error: The application was unable to start correctly.
Solution: Same as above, but at runtime you have the wrong PDFNetC.dll being loaded.

linkNext steps

Please see the deployment page for more details on deployments and languages supported.

The demo/trial page has more information on demo mode limitations and licensing details.