The best option will depend on whether you want to keep both pages or just replace the underlying image from page 1 with the image from page 2.
In either case, your best option is probably going to be a workflow that runs an SDK Script activity to make the changes.
If you want users to be able to run this from the client, then you can set it up as a Business Process and they can copy the annotations by running the process.
Option 1 - Copy annotations and keep both pages
// Get document info object
// This configuration uses the workflow's starting entry
DocumentInfo doc = (DocumentInfo)this.BoundEntryInfo;
// Lock document to prevent other users/processes from making changes
doc.Lock(LockType.Exclusive);
// Check page count to avoid errors
if(doc.PageCount > 1){
try
{
// Add all annotations from page 1 to page 2
doc.GetPageInfo(2).AddAnnotations(doc.GetPageInfo(1).GetAnnotations());
// Save changes
doc.Save();
}
finally
{
// Always release the document even if an error occurs
doc.Unlock();
doc.Dispose();
}
}
Option 2 - Replace page 1 image with page 2 image and only keep the updated page
// Get document info object
// This configuration uses the workflow's starting entry
DocumentInfo doc = (DocumentInfo)this.BoundEntryInfo;
// Lock document to prevent other users/processes from making changes
doc.Lock(LockType.Exclusive);
// Check page count to avoid errors
if(doc.PageCount > 1){
try
{
// Create read stream to get page 2 image
using(LaserficheReadStream rs = doc.GetPageInfo(2).ReadPagePart(PagePart.Image)){
// Create stream writer for page 1 image
using(Stream writer = doc.GetPageInfo(1).WritePagePart(PagePart.Image, (int)rs.Length)){
// Seek to beginning of stream to make sure all data is captured
rs.Seek(0, SeekOrigin.Begin);
byte[] buffer = new byte[0x8000];
int count;
// Write new image data to page 1
while((count = rs.Read(buffer, 0, buffer.Length)) > 0){
writer.Write(buffer, 0, count);
}
}
}
// Delete page 2
doc.DeletePage(2);
// Save changes
doc.Save();
}
finally
{
// Always release the document even if an error occurs
doc.Unlock();
doc.Dispose();
}
}
I kind of slapped these together so you may need to make adjustments, but I tested both and they worked as expected so they will at least point you in the right direction.
NOTE: If you use Option 1, the annotations will show as being created by the Workflow user account. If you use Option 2, you're not actually changing the annotations so their original creator/metadata will remain intact.