GetPageAsMetafile Method

[Top]  [Chapter]  [Previous]  [Next]


int GetPageAsMetafile(int PageNr,int Options);


Creates a meta file from a certain page and returns the handle. Please call Memo.ReformatAll(false,false) if the editor was dynamically created.


To create a file use SavePageAsMetafile.


Also see the commands to create bitmap files (BMP, PNG and TIFF).



PageNr :        The number of the page to be saved. The first is 0.

Options:        a bit field:

4: display a frame for the page margins

8: optimized for PDF export. We recommend to always set this bit!

16: also print selection marker

32: do not print watermarks

64: do not print header and footer

128: do not print images

256: print table grid lines.

512: Export embedded meta-files as bitmaps

1024: Create a metafile with current screen resolution, otherwise the resolution is 600


The handle to an enhanced metafile. If an error happens the return value is 0. The handle must be freed by the caller.


This C# function can be used to load a metafile from a handle into picture box:


private void LoadInImage(System.Windows.Forms.PictureBox PictureBox, int MetaHandle)


 if (MetaHandle!=0)


  Metafile aMetafile=new Metafile(new IntPtr(MetaHandle), true);

  PictureBox.Image = aMetafile;

  PictureBox.SizeMode =  PictureBoxSizeMode.StretchImage;


 else PictureBox.Image = null;



You can use it in code like this:






Example using a dynamic editor:


   WPDLLInt temp_editor = new WPDLLInt(); 

   temp_editor.Memo.LoadFromString( data_provided_as_string , false"AUTO");

   temp_editor.SpecialTextAttr(SpecialTextSel.wpInsertpoints).Hidden = true;


   for(int i = 0; i < temp_editor.Memo.TextCursor.PageCount; i++)


            IntPtr metaHandle = temp_editor.Memo.GetPageAsMetafile(i, 8);

            if (metaHandle.ToInt32() == 0)


                     Console.WriteLine("page " + i.ToString() + " not loaded");




                     System.Drawing.Imaging.Metafile aMetafile = new System.Drawing.Imaging.Metafile(metaHandle, true);

                     aMetafile.Save("c:\\page__" + i.ToString() + ".emf");







Load and Save

[idh_iwpmemo_getpageasmetafile.htm]    Copyright © 2007 by WPCubed GmbH