Kunaal

Kunaal

  • NA
  • 1
  • 0

Metafile manipulations

Aug 27 2006 2:50 AM

Hi!

 

Need your ideas urgently! I have a metafile which I wish to convert to PDF on the fly. The idea is to create a metafile template with placeholder text, which will be parsed and replaced by user information at runtime before generating the PDF. When editing the metafile, I have progressed to the following steps:

 

1.      Called the Graphics.EnumerateMetaFile() method, which calls the callback method (lets call it ‘Play’)

2.      Called the callback method and obtain the record data

 

public bool Play(EmfPlusRecordType recordType, int flags, int datasize, IntPtr data, PlayRecordCallback callback)

{

byte[] dataArray = null;

      if (data != IntPtr.Zero)

      {

                  dataArray = new byte[datasize];

             Marshal.Copy(data, dataArray, 0, datasize);

      }

 

3.      Checked whether the record pertains to writing text on the wmf as follows:

 

if (recordType == EmfPlusRecordType.DrawString)

 

  1. Called the Metafile.PlayRecord() method to draw the new metafile.

 

mf.PlayRecord(recordType, flags, datasize, dataArray);

 

What I’m unable to do is, to parse the dataarray (which contains record data), such that I can replace existing text with new text.

 

Thanks a LOT for any insights.

 

Regards,

Kunaal


Answers (1)