Changes in VPEReadDoc - images

Knowledge exchange related to the VPE Report Engine and PDF Library

Moderator: IDEAL Software Support

Changes in VPEReadDoc - images

Postby starzen » Wed Nov 19, 2014 4:37 pm

A few of our clients are running into this issue after upgrading

the code essentially batches multiple vpe documents together into a big document by using 2 VPE document objects. Object 1 creates a report and saves as a temp file. in object 2 temp files is appended by using VPEReadDoc then deletes the temp file. then object 1 creates another document and appends it to Object 2 again and deletes the temp file

this was working fine until they upgraded to 6. Now it looks like the appending works but if the temp file gets deleted after the VPEReadDoc none of the images appear in the new document

Looks like the newly created document still refers to the old documents to read the images somehow
starzen
 
Posts: 30
Joined: Tue Feb 01, 2005 12:23 am
Location: Miami, FL

Re: Changes in VPEReadDoc - images

Postby starzen » Wed Nov 19, 2014 5:05 pm

I confirmed this by writing a small test

opendoc -> doc1

loop
opendoc -> doc2
VpeWrite -> doc2
vpepicture -> doc2

VpeWriteDoc -> doc2 (temp file name)
VpeCloseDoc -> doc2

VpeReadDoc -> Doc1 (temp filename from above)

Delete Temp File
end loop

Preview Doc 1

if I delete the temp files in the loop the documents are attached but the images show an X. if I do not delete the temp files the images show but of course that isn't a solution

I tried disabling the picture cache on doc 1 and also on doc 2 which didn't make a difference
starzen
 
Posts: 30
Joined: Tue Feb 01, 2005 12:23 am
Location: Miami, FL

Re: Changes in VPEReadDoc - images

Postby IDEAL Software Support » Thu Nov 20, 2014 9:50 am

Please see our detailed explanation here: viewtopic.php?f=7&t=1161

Indeed this is related to referencing the image. Turning the caching off just instructs VPE to reload the image from hard disk each time it is required. You can solve the problem without a significant performance penalty by:

a) Open the main document (i.e. the one which shall be assembled from tmp documents)
b) Append the tmp document using ReadDoc()
c) Write the main document to disk usign WriteDoc()
d) Close the main document
e) Delete the tmp VPE document
f) Re-open the main document

You can speed up this task by using a Swap File for the main document (for the DLL call VpeOpenDocFile()). This way it does not read the whole document into memory. You can then append the tmp document by calling ReadDoc().

When the main document is based on a Swap File, do NOT call WriteDoc(), because it already creates a document file.

The call-sequence is:

a) Open the main document using VpeOpenDocFile()
b) Append the tmp document using ReadDoc()
c) Close the main document
d) Delete the tmp VPE document
e) Re-open the main document
IDEAL Software Support
 
Posts: 1633
Joined: Thu Nov 18, 2004 4:03 pm


Return to VPE Open Forum

Who is online

Users browsing this forum: No registered users and 6 guests