views:

264

answers:

1

I'm porting some C++ code to VB.NET which creates a print job consisting of several pages. Every page has a template of graphical objects (text, lines, curves, etc) which stays the same on each page, and overlaid on top of that is the different data for each page.

The template is created at the start of the print job as an in-memory metafile using CreateEnhMetaFile, and at the start of each page this metafile is drawn onto the print device context using PlayEnhMetaFile.

How can I do this in .NET? From my reading of the API so far, it seems that I can only import a Metafile from a file or stream, and not create one from scratch. Is this correct?

+1  A: 

Please take a look at the following pages ...

1) http://msdn.microsoft.com/en-us/library/zbk7dbtb.aspx
2) http://msdn.microsoft.com/en-us/library/ms536391.aspx
3) http://msdn.microsoft.com/en-us/library/1h5aa6y9.aspx

You can create a MetaFile object using the following constructor

public Metafile(Stream stream)

to take a MemoryStream as the final destination of the metafile commands.

for example

var mf = new MetaFile(new MemoryStream());

Hope this helps.

SDX2000
Thank you, that's just what I need!
You are welcome.
SDX2000