EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Costum Signature Image

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#31952
Posted: 01/20/2015 10:33:11
by Jorge Martins (Standard support level)
Joined: 02/06/2014
Posts: 9

Hi,

I'm trying to get a custom signature image to the the PDF file, but I can't seam to get it work.

I'm using the DC module (java), and my code on the SelectServlet.java is the following:


Code
TElPDFSignature signature;
String image = "sign.jp2";   

....

signature = pdf.getSignatureEntry(pdf.addSignature());

TElPDFImage img = new TElPDFImage();
img.setImageType(TSBPDFImageType.pitJPEG2000);
img.setData(ReadFile(image));

TElPDFSignatureWidgetProps  signWidget = new  TElPDFSignatureWidgetProps();
signWidget.setBackgroundStyle(TSBPDFWidgetBackgroundStyle.pbsCustom);
signWidget.setHeight(300);
signWidget.setWidth(400);
signWidget.setOffsetX(50);
signWidget.setOffsetY(50);
signWidget.setCustomAppearance(img.getData());

signature.setInvisible(true);
signature.setHandler(handler);
signature.setSigningTime(SBUtils.utcNow());
signature.setExtraSpace(Integer.parseInt(prop.getSigExtraSpace()));

state = pdf.initiateAsyncOperation();
state.saveToStream(output, SBDCXMLEnc.dcxmlEncoding());

....


Is this correct?

How do I "connect" the signWidget object with the signature object?
I tried look at the forums and documentation, but the implementation seems different from what I can do with the classes.

For example: Sig.WidgetProps.Background.Height:= 480;

But I can't access to "WidgetProps" from within the TElPDFSignature object, how can I do that?


Thank you.
#31957
Posted: 01/20/2015 15:36:27
by Dmytro Bogatskyy (EldoS Corp.)

Thank you for contacting us.

Quote

TElPDFSignatureWidgetProps signWidget = new TElPDFSignatureWidgetProps();

You don't need to create your own instance of TElPDFSignatureWidgetProps class, simply use TElPDFSignature.getWidgetProps property getter to get instance of TElPDFSignatureWidgetProps (see: https://www.eldos.com/documentation/sb...props.html , also please refer to PDFBlackbox\Desktop\Signer or SecurePDF samples).
Quote

TElPDFImage img = new TElPDFImage();
img.setImageType(TSBPDFImageType.pitJPEG2000);
img.setData(ReadFile(image));
...
signWidget.setCustomAppearance(img.getData());

Do you want to set an image as a background? In this case use appropriate properties TElPDFSignatureWidgetProps.Background and BackgroundStyle, please refer to the article for details: https://www.eldos.com/documentation/sb...round.html
#31962
Posted: 01/21/2015 05:26:16
by Jorge Martins (Standard support level)
Joined: 02/06/2014
Posts: 9

Didn't notice the TElPDFSignature.getWidgetProps.

I may be confuse but the TElPDFSignature.getWidgetProps().Background or TElPDFSignature.getWidgetProps().BackgroundStyle properties don't exist

"Background cannot be resolved or is not a field"


Our client want's to add an image of their real signature to the PDF document, I realy don't know if what I have to do is to add background images.

I was just trying so that I could see how it works.

Is there a better way to do?

Thank You.
#31963
Posted: 01/21/2015 06:03:35
by Vsevolod Ievgiienko (EldoS Corp.)

Quote
I may be confuse but the TElPDFSignature.getWidgetProps().Background or TElPDFSignature.getWidgetProps().BackgroundStyle properties don't exist

In Java edition you should use getters/setters to access these properties: TElPDFSignature.getWidgetProps().getBackground() & TElPDFSignature.getWidgetProps().getBackgroundStyle()/setBackgroundStyle().
#33029
Posted: 04/13/2015 07:48:12
by Jorge Martins (Standard support level)
Joined: 02/06/2014
Posts: 9

Hi,

Sorry for reviving this old topic, my I had to stop working on this project, and i'm getting into it now.

I'm getting a hard time trying to set a custom backgroud image for the signature, currently I got the following code:

Code
...
signature = pdf.getSignatureEntry(pdf.addSignature());

TElPDFImage img = new TElPDFImage();
img.setImageType(TSBPDFImageType.pitJPEG);
img.setData(ReadFile(imagePath));

signature.getWidgetProps().setBackgroundStyle(TSBPDFWidgetBackgroundStyle.pbsCustom);
signature.getWidgetProps().getBackground().setData(img.getData());
signature.getWidgetProps().setWidth(200);
signature.getWidgetProps().setHeight(100);
signature.getWidgetProps().setOffsetX(100);
signature.getWidgetProps().setOffsetY(300);
signature.getWidgetProps().setSignerCaption("Testing");


signature.setSignatureType(SBPDF.stDocument);
signature.setInvisible(false);
...


but I still bet no background image for the signuture, even the setOffsetX and setOffsetY appears to not move the visible signature at all.

Can you please check if i'm doing something wrong?

Thank you.
#33030
Posted: 04/13/2015 08:38:13
by Dmytro Bogatskyy (EldoS Corp.)

Hello,

Quote
but I still bet no background image for the signuture

You need to set Height and Width properties of the background image that match the actual dimension of the image (use getBackground().setHeight() and setWidth() methods).
Quote
even the setOffsetX and setOffsetY appears to not move the visible

This question is asked frequently and we have collected instructions that would help you in this knowledgebase article: https://www.eldos.com/documentation/sb...ition.html . Please follow the information given in the article.
(Shortly speaking you need to set AutoPos property to false.)
#33034
Posted: 04/13/2015 13:07:35
by Jorge Martins (Standard support level)
Joined: 02/06/2014
Posts: 9

Thanks! Now I got it right.

Where is the code in case someone bumps with the same problem.

Code
...
signature.getWidgetProps().setBackgroundStyle(TSBPDFWidgetBackgroundStyle.pbsCustom);
signature.getWidgetProps().getBackground().setData(img.getData());
signature.getWidgetProps().getBackground().setWidth(200);
signature.getWidgetProps().getBackground().setHeight(100);
signature.getWidgetProps().getBackground().setImageType(TSBPDFImageType.pitJPEG);
signature.getWidgetProps().setAutoPos(false);
signature.getWidgetProps().setAutoSize(false);
signature.getWidgetProps().setWidth(200);
signature.getWidgetProps().setHeight(100);
signature.getWidgetProps().setOffsetX(20);
signature.getWidgetProps().setOffsetY(50);
...
Also by EldoS: RawDisk
Access locked and protected files in Windows, read and write disks and partitions and more.

Reply

Statistics

Topic viewed 1184 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!