ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 IEvolution RenderToGraphics
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

u.bruegelmann

Germany
2 Posts

Posted - Mar 15 2012 :  06:00:26  Show Profile  Reply
Hi there,
I'm trying to print selected pages from a multi page tiff and add an overlay to each page.
Basic idea was to use an IEMulti (instace var imIO), PrintDocument.Print and an event handler looking like this:


procedure TTComFaxThread.DoPrintPage(sender:TObject; e : PrintPageEventArgs);
var
f : System.drawing.font;
img : IEImage;
h,w : integer;

begin
f := System.drawing.font.Create('Arial',8,FontStyle.Bold);
img := imIO.ImageList.GetImage(iPageVarFromInstance-1);
h := trunc(e.PageBounds.Height/100*e.Graphics.DPIY);
w := trunc(e.PageBounds.Width /100*e.Graphics.DPIX);
img.RenderToGraphics(e.Graphics,0,0,w,h,0,0,img.Width,img.Height,255,IEResampleFilter.FastLinear,RenderOperation.Normal);
e.Graphics.DrawString('INDIV Nummer: ' + SomeInstanceVar + ' - VPC: 58506',f,brushes.Black,150,80);

e.hasMorePages := SomeInstanceVar;
end;

Problem now is, that DrawString raises an exception with the message (translated from German) "Object already in use"
Any clue as to what I could do to circumvent that?

fab

1310 Posts

Posted - Mar 15 2012 :  06:18:47  Show Profile  Reply
Hi,
this is a bug of current version of IEvolution. Please try following workaround: just after RenderToGraphics() call e.Graphics.ReleaseHdc(). For example:

...
w := trunc(e.PageBounds.Width /100*e.Graphics.DPIX);

img.RenderToGraphics(e.Graphics,0,0,w,h,0,0,img.Width,img.Height,255,IEResampleFilter.FastLinear,RenderOperation.Normal);
e.Graphics.ReleaseHdc();

e.Graphics.DrawString('INDIV Nummer: ' + SomeInstanceVar + ' - VPC: 58506',f,brushes.Black,150,80);
...
Go to Top of Page

u.bruegelmann

Germany
2 Posts

Posted - Mar 15 2012 :  23:13:55  Show Profile  Reply
Hi,

thanks a lot. Works fine now.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: