remove the blank space around the images and scale them well in PDF

Bug #1165621
Bug #1165616

Change-Id: Ia0028c051e61f5ed521fc162103c261a99064689
Merge "remove the blank space around the images and scale them well in PDF"