Cloning VPEControl

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Cloning VPEControl

Postby hilmar » Fri Apr 25, 2008 9:23 am

Using C# I'm trying to clone an extended (inherited) VPEControl

I have a class VPEDocument which inherits from VPEControl ( public class VPEDocument : IDEALSoftware.VpeProfessional.VpeControl )

I have made a VPEDocument.Clone() function which does the following:

Code: Select all
public VPEDocument Clone()
{

   IDEALSoftware.VpeProfessional.TVPEStream stream = this.CreateMemoryStream(0);

   if (!this.WriteDocStream(stream))
   {
      stream.Close();
      throw new Exception("Clone: Error writing to stream. VPEError = " + this.LastError);
   }

   VPEDocument newDoc = new VPEDocument();
   newDoc.OpenDoc();
   if (!newDoc.ReadDocStream(stream))
   {
      stream.Close();
      throw new Exception("Clone:Error reading from stream. VPEError = " + newDoc.LastError);
   }

   stream.Close();
   return newDoc;

}


When I call the newDoc.ReadDocStream(stream) I get an FileDocVersion error.

How can i avoid this? I'm currently using the VPE professional version (trial).

(I have lots of free RAM)

Cheers,
Marius
hilmar
 
Posts: 7
Joined: Tue Apr 22, 2008 8:12 am

Postby hilmar » Fri Apr 25, 2008 10:04 am

Debug info of TVPEStream after the ReadDocStream(stream) call

The State, which was True before ReadDocStream, is now False.

Code: Select all
System.IO.Stream {IDEALSoftware.VpeProfessional.TVPEStream}
      CanRead   true   bool
      CanSeek   true   bool
      CanWrite   true   bool
      IsEof   true   bool
      Length   0x0000000000000000   long
      ObjectHandle   0x00000000   int
      Position   0x0000000000000000   long
      State   false   bool
hilmar
 
Posts: 7
Joined: Tue Apr 22, 2008 8:12 am

Postby IDEAL Software Support » Fri Apr 25, 2008 10:45 am

Did you modify the property DocExportType before? Please make sure it is either "Auto" (this is the default) or "VPE" before calling WriteDocStream().

You must also call stream.Seek(0, Begin) before calling ReadDocStream(), because after calling WriteDocStream() the position within the stream is at the end of the stream.

If this does not help, please let me know and we will examine the case.
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm

Postby hilmar » Fri Apr 25, 2008 10:52 am

IDEAL Software Support wrote:You must also call stream.Seek(0, Begin) before calling ReadDocStream(), because after calling WriteDocStream() the position within the stream is at the end of the stream.


Thanks, that did the trick!

You have got a new customer ;)
hilmar
 
Posts: 7
Joined: Tue Apr 22, 2008 8:12 am


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 14 guests

cron