DynaPDF Manual - Page 43

Previous Page 42   Index   Next Page 44

Language Bindings
Page 43 of 839
int ErrType)
{
// The error type is a bitmask.
Console.Write("{0}\n", PtrToStringAnsi(ErrMessage));
Console.Write("\n");
return 0; // We try to continue if an error occurs.
}
[STAThread]
static void Main(string[] args)
{
try
{
String outFile = "c:/c#out.pdf";
CPDF pdf = new CPDF();
// Error messages are passed to the callback function.
pdf.SetOnErrorProc(IntPtr.Zero, new DynaPDF.TErrorProc(PDFError));
// We open the output file later if no error occurs.
pdf.CreateNewPDF(null);
// We use top down coordinates in this example
pdf.SetPageCoords(DynaPDF.TPageCoord.pcTopDown);
// Add an empty page to the file
pdf.Append();
// Before printing text you must set a font
pdf.SetFont("Arial", DynaPDF.TFStyle.fsItalic, 20, true, DynaPDF.TCodepage.cp1252);
pdf.WriteText(50.0, 50.0, "My first PDF output...");
pdf.WriteText(50.0, 80.0, "File created: " + DateTime.Now.ToString());
pdf.EndPage(); // Close the open page
// No fatal error occurred?
if (pdf.HaveOpenDoc())
{
// OK, now we can open the output file.
if (!pdf.OpenOutputFile(outFile))
{
// An error message was already passed to the error callback function
Console.Read();
return;
}
if (pdf.CloseFile())
{
Console.Write("PDF file \"{0}\" successfully created!\n", outFile);
}
}
pdf = null;
}catch(Exception e)
{
Console.Write(e.Message);
}
Console.Read();
}
}
}
 

Previous topic: General Note:, Data types in C#

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