DynaPDF Manual - Page 40

Previous Page 39   Index   Next Page 41

Language Bindings
Page 40 of 777
However, C# uses a very restrictive data type handling that causes that already signed integers
cannot be passed to unsigned integer variables of the same type without explicit conversion.
To make the usage of DynaPDF less complicated most function parameters which would
normally declared as unsigned integer, e.g. PDF object handles, are declared as signed integer
to get rid of permanent explicit data type conversions.
The usage of DynaPDF with C# is nearly identical in comparison to C++. The interface does
generally not use events like in VB .Net because callback functions work very well in C#.
Data types in C#
All structures and enums used by DynaPDF are declared in the namespace DynaPDF. Because
it is not possible to declare constants in a namespace, such constants are declared in the class
CPDF. All data types, structures, and constants are defined in the file CPDF.cs. No further files
are required to use DynaPDF.
Example (Visual C#):
using System;
using DynaPDF;
using System.Runtime.InteropServices.Marshal;
namespace hello_world
class Hello_World
// Error callback function.
static int PDFError(IntPtr Data, int ErrCode, IntPtr ErrMessage,
int ErrType)
// The error type is a bitmask.
Console.Write("{0}\n", PtrToStringAnsi(ErrMessage));
return 0; // We try to continue if an error occurs.
static void Main(string[] args)
String outFile = "c:/c#out.pdf";
CPDF pdf = new CPDF();
// Error messages are passed to the callback function.
pdf.SetOnErrorProc(IntPtr.Zero, new
// We open the output file later if no error occurs.

Previous topic: Visual C#, 64 Bit Applications, General Note:

Next topic: Embarcadero Delphi, 64 Bit Applications, General Usage