EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Custom PDF Signature Image Stretch

Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.
#34618
Posted: 10/06/2015 13:55:03
by Jorge Martins (Standard support level)
Joined: 02/06/2014
Posts: 9

Hi,

I'm trying to resize the signature widgetprops so that it fits an image and some information of the signature, but when I resize the widgetprops the image and the text stretches, any way to solve this?


Code
...
signature.getWidgetProps().setBackgroundStyle(TSBPDFWidgetBackgroundStyle.pbsCustom);
signature.getWidgetProps().getBackground().setData(img.getData());
signature.getWidgetProps().getBackground().setWidth(100);
signature.getWidgetProps().getBackground().setHeight(35);
signature.getWidgetProps().getBackground().setImageType(TSBPDFImageType.pitJPEG);
signature.getWidgetProps().setAutoStretchBackground(true);
signature.getWidgetProps().setAutoPos(false);
signature.getWidgetProps().setAutoSize(false);
signature.getWidgetProps().setWidth(100);
signature.getWidgetProps().setHeight(70);

signature.getWidgetProps().getCustomText().add("Assinado digitalmente", 1, 55, 3, 13);

....



See attached image:

The left one is when the signature.getWidgetProps().setHeight() is the same height as the image (35)
The right one is when I double the height size (70)

Thanks


#34619
Posted: 10/06/2015 14:36:02
by Dmytro Bogatskyy (EldoS Corp.)

Thank you for contacting us.

Quote
I'm trying to resize the signature widgetprops so that it fits an image and some information of the signature, but when I resize the widgetprops the image and the text stretches, any way to solve this?
The left one is when the signature.getWidgetProps().setHeight() is the same height as the image (35) The right one is when I double the height size (70)

The inner layer of a signature widget has dimension 66x66 pts. All coordinates and sizes of the custom text are related to this "viewport". So, to compensate stretching of the signature widget you need to modify FontSizeY parameter for getCustomText().add() method. For example:
Code
signature.getWidgetProps().getCustomText().add("Assinado digitalmente", 1, 55, 3, 13.0 * 35 / 70);

To disable stretching of the background image you need to disable TElPDFSignatureWidgetProps.AutoStretchBackground property and set StretchX and StretchY properties. For example, to preserve background aspect ratio after changing widget height you need to set StretchX to 66 and StretchY to 33 (where is 66 is internal dimension of the signature widget).
#34660
Posted: 10/08/2015 06:32:19
by Jorge Martins (Standard support level)
Joined: 02/06/2014
Posts: 9

I manage to work with the numbers and it's working, what i'm not understanding is how you reach those values.

You say that the widget dimension is 66x66 pts, but how do you know that? Since the values I used where 100 for width and 35 or 70 for Height.
#34667
Posted: 10/08/2015 07:52:59
by Dmytro Bogatskyy (EldoS Corp.)

Hi,

Quote
what i'm not understanding is how you reach those values.

I have assumed that the background image stretching was ok with your previous widget width and height (100x35), so when you increased the height in two times (70) than to keep the background image at the same size you need to decrease the StretchY property by two times (from 66 to 33).

Reply

Statistics

Topic viewed 1142 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!