Some test text!
Listed below are a few of the common questions and queries that receive often.
Q: Where should I call the PDFNet.Initialize()?
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
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?
Initialize() should be called in your application/library
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
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
GC.Collect() is not necessary. You could simply call
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:
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.
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.
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:
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.
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).
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.
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.
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.
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.