|
GetPageAsMetafile Method |
[Top] [Chapter] [Previous] [Next] |
|
Declaration int GetPageAsMetafile(int PageNr,int Options); Description 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.
Parameters: 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 Returns 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:
LoadInImage(pictureBox1, wpdllInt1.Memo.GetPageAsMetafile(0,0));
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; temp_editor.Memo.ReformatAll(true, false); 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"); } else { System.Drawing.Imaging.Metafile aMetafile = new System.Drawing.Imaging.Metafile(metaHandle, true); aMetafile.Save("c:\\page__" + i.ToString() + ".emf"); } } temp_editor.DisposeEditor();
Category |