Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 39

Previous Page 38   Index   Next Page 40

Language Bindings
Page 39 of 750
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: General Note:

Next topic: General Usage