I apologize I don't know how layers work in Gimp or Photoshop, so correct me if I wrong. Do I understand correctly that you need to combine two images with text, black on white, so that the text from both pages gets combined, while the extensions of the page stays the same? If so, then you need to combine them using binary "and" operator. I'm sure that ImageMagick can do that trick, I just was never curious about how exactly, but I can give you code that works with Prima, and you can try it and tell if it does the right thing:
use Prima;
my $a = Prima::Image-> load('a.tif');
my $b = Prima::Image-> load('b.tif');
$a-> put_image(0,0,$b,rop::AndPut);
$a-> save('c.tif');