DynaPDF Manual - Page 653

Previous Page 652   Index   Next Page 654

Function Reference
Page 653 of 839
Remarks:
The function outputs errors and warnings into the error log of the corresponding PDF instance. The
caller should check for errors by calling GetErrLogMessageCount() when the function returns. The
error log can be cleared when the messages were processed with ClearErrorLog().
Return values:
When the page was fully rendered the return value is 1. When the page was not fully processed, e.g.
due to errors, the return value is 0.
Example (C#):
int PDFError(IntPtr Data, int ErrCode, IntPtr ErrMessage, int ErrType)
{
MessageBox.Show(System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ErrMessage));
return 0;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
m_PDF.SetOnErrorProc(IntPtr.Zero, new TErrorProc(PDFError));
// We don't create a PDF file in this example
m_PDF.CreateNewPDF(null);
m_PDF.SetPageCoords(TPageCoord.pcTopDown);
m_PDF.Append();
m_PDF.SetFont("Arial", TFStyle.fsRegular, 20.0, false, TCodepage.cpUnicode);
m_PDF.WriteFTextEx(
50.0,
50.0,
495.0,
-1.0,
TTextAlign.taCenter,
"A small example that shows how RenderPage() can be used...");
m_PDF.EndPage();
// Get the page object
IntPtr pagePtr = m_PDF.GetPageObject(1);
int w = pictureBox1.Width;
// The picture box was placed on the form.
int h = pictureBox1.Height;
// Calculate the image size
m_PDF.CalcPagePixelSize( pagePtr,
TPDFPageScale.psFitBest,
1.0f,
w,
h,
TRasterFlags.rfDefault,
ref w,
ref h);
// Create a bitmap in this size
Bitmap bmp = new Bitmap(w, h, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Drawing.Imaging.BitmapData bd = bmp.LockBits(
new Rectangle(0, 0, w, h),
System.Drawing.Imaging.ImageLockMode.WriteOnly,
System.Drawing.Imaging.PixelFormat.Format32bppRgb);
// Create a rasterizer for the bitmap
IntPtr ras = m_PDF.CreateRasterizer( IntPtr.Zero,
bd.Scan0,
w,
h,
 

Previous topic: How to save the image on disk?

Next topic: RenderPageEx (Rendering Engine)