How to apply Signature Image to a Signature Field


#1

Hello Support

I want to use your Java API to fill in a signature field in an existing PDF document. I support a workflow application which I want to enhance by appending the signature of an approver in teh sinature field that is pre-created in a pdf.

I have looked at your examples in the downloaded kit, and I have so far not found an appropriate example. I also looked at the Java docs and I do not find an appropriate class to do this. Please let me know if such functionality exists and I have missed it.

Your sample.form.AutoFilling example applies Text to the fields and your examples in teh samples.mend package apply images on the coordinates.

I need to do a mix of both i.e apply siganture image in a .JPG file to a field in the PDF.

Is this supported.

Thanks in advance

Look forward to hear from you.


#2

Thanks for considering Aspose.

Here is a sample code to apply images to a field.

+++++++++++++++++++++++++++++++++++++++

//Open the document and create a Form object
Form form = new Form(path + "Online.pdf", path + "Online_image.pdf");
//Paste a image onto the existing button field
form.fillImageField("photo", path+"watermark.jpg");
//Close the document
form.close();

+++++++++++++++++++++++++++++++++++++++

Resource files are attached including Online.pdf and watermark.jpg.


#3

Dear rbhogal ,

Thanks for considering Aspose.Pdf.Kit for Java.

As Kavin has metioned, Kit can paste an image in JPG/BMP/GIF/TIFF/PNG onto an existed push button field (so called image field) by Form.fillImageField( ). Details can be referred to our API.

I am not sure whether this method can fully meet your requirement, because I wonder what a Signature Image really mean. Please try it yourself as what Kavin replied, or you can attach the image so that I can test it for you.

Best regards.


#4

Thanks Kevin and Lake for your replies.

I was able to find your example that executes the above code, I find that it is extremely slow in instantiating your Form object. It takes 4 to 5 minutes just to instantiate the Object. I am running on 1.86 GHz CPU with 2 GB RAM on a WinXP system. At the time of running these examples I had 1 GB free RAM availlable on my system and 96% CPU availlable.

I ran two of your examples one after the other ImagePaste and CreatePdfDocumentLink, I had modified your examples with some debug statements printing the time stamp. The CreatePdfDocumentLink runs without any performance problem.

I have uploaded the modified source files and the output from the console.

Do you have any suggestions as to why it is so slow, unfortunately it will be very difficult to run this on a production environment.

Thanks in advance.

Rajeev Bhogal


#5

Thanks for considering Aspose.

I've test your updated codes, but performance is good. Here is the output debug informations.

[CreatePdfDocumentLink.java]

---Entered samples.form.ImagePaste.Main at 2006-05-26 11:04:44

-----Instantiated PdfEditor at 2006-05-26 11:04:44

-------Bound Editor to pdf file at 2006-05-26 11:04:44

-------Instantiated Rectangle at 2006-05-26 11:04:44

---------Created Pdf Document Link at 2006-05-26 11:04:45

-----------Saved Pdf Document to file system at 2006-05-26 11:04:45

[ImagePaste.java]

---Entered samples.form.ImagePaste.Main at 2006-05-26 11:06:21

-----Created Form at 2006-05-26 11:06:22

-------Filled Image field on Form at 2006-05-26 11:06:23

---------Closed Form at 2006-05-26 11:06:23

My test condition is:

CPU: 2.80GHz, 90% Free Ram: 1GB, 425MB Free OS: Win2000

So I guess there must be some other reasons to increase the running time.


#6

Thanks Kevin

Very interestingly it works fine if the resources directory is on yoru local hard drive, In the first case I was running with all Aspose files including your sample java classes, compiled class files and resources on my private network H: drive, in the second test now I copied everything on to my local hard drive and test results are very good.

C:\Documents\Phase 1.3\Aspose>java samples.form.ImagePaste
---Entered samples.form.ImagePaste.Main at 2006-05-26 01:07:28
-----Created Form at 2006-05-26 01:07:28
-------Filled Image field on Form at 2006-05-26 01:07:28
---------Closed Form at 2006-05-26 01:07:28

The invoked Java is installed on the local system C:\ drive, I can understand that anytime you access a fie on the network, it can make things a little slow but I can not understand why it should be 4 minutes to instantiate the class, however the other test case CreatePdfDocumentLink did not expereince this degradation in performance even though the editor.bindPdf(path + "example1.pdf"); was accessing example.pdf on the network drive. Can you do a similar test by running the code on a network drive.

Thanks

Rajeev Bhogal


#7

Dear rbhogal ,

It seems that our product can fullfill your requirement functionally, but the perform is terrible. As you mentioned above, there Do exist big difference between local resource and remote one. Furthermore, different network may induce different performance.

Essentially, Form class has the same mechanism with PdfContentEditor to read input data. The reason for huge performance difference lies in the size of the demo PDF document. You can examine that: Online.pdf--->180KB, while example1.pdf---> 11KB!

Please play another test only replacing Online.pdf with a much smaller one. I think the problem won't be occured again. Yet, further problems are still welcomed till you satisfy with it.

Best regards.


#8

Thanks Luke

I think the major reason to teh Performance hit is the Netwok access. As you can see even with the 182 KB file it takes less then a second when the resources are on the local drive.

Our actual environment is on Unix, and the resource will have to be in an Oracle database. I don't know how slow or fast it would be. This remains to be investigated.

Regards

Rajeev


#9

You are welcomeSmile [:)]

Aspose.Pdf.Kit for Java works on Unix as well as on Windows. And hope for your evaluation. We cannot appreciate your experience any more 'cause it will really benefit us a lot for product evolution and promotion.

Best regards.