EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PDF Signing - setting the background image

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#11975
Posted: 12/20/2009 04:10:50
by Yehiel Isakov (Basic support level)
Joined: 12/20/2009
Posts: 1

Hi Eugene,
I am sorry to bother you ... but I have a little problem with setting a background image for PDF signature. Here is a code snipplet;

// "image" contains an image file path. I especially chose JPEG2000 images
TElPDFImage img = new TElPDFImage();

if ((image != null) && (File.Exists(image)))
{
img.ImageType = TSBPDFImageType.pitJPEG2000;
img.Data = ReadFile(image);
Sig.WidgetProps.BackgroundStyle = TSBPDFWidgetBackgroundStyle.pbsCustom;
Sig.WidgetProps.Background.Height = img.Height;
Sig.WidgetProps.Background.Width = img.Width;
Sig.WidgetProps.Background.Data = img.Data;
// Sig.WidgetProps.AutoStretchBackground = true;
}

Here is "ReagFile" code (it simply reads the whole file contents into a byte array):

public static byte[] ReadFile(string filePath)

{
byte[] buffer;
FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);

try
{
int length = (int)fileStream.Length; // get file length
buffer = new byte[length]; // create buffer

int count; // actual number of bytes read
int sum = 0; // total number of bytes read


// read until Read method returns 0 (end of the stream has been reached)
while ((count = fileStream.Read(buffer, sum, length - sum)) > 0)

sum += count; // sum is a buffer offset for next reading
}
finally
{
fileStream.Close();
}
return buffer;

}

I also used File.ReadAllBytes - and the result was the same.


Maybe there is a problem within the system with setting an image background ?! Width and Height values
were 0 as I checked them in a debugger.


Thank you for your time and I hope that you can help me.

With respect,
Isakov Yehiel.


P.S.:
Could you provide some more code snipplets on signature location (as a function of document width and height), signature form, visibility, printability, image formats and image usage etc. ? ;-) This will be most helpful
#11976
Posted: 12/20/2009 14:50:35
by Dmytro Bogatskyy (EldoS Corp.)

Quote
ut I have a little problem with setting a background image for PDF signature. Here is a code snipplet;

// "image" contains an image file path. I especially chose JPEG2000 images
TElPDFImage img = new TElPDFImage();

if ((image != null) && (File.Exists(image)))
{
img.ImageType = TSBPDFImageType.pitJPEG2000;
img.Data = ReadFile(image);
Sig.WidgetProps.BackgroundStyle = TSBPDFWidgetBackgroundStyle.pbsCustom;
Sig.WidgetProps.Background.Height = img.Height;
Sig.WidgetProps.Background.Width = img.Width;
Sig.WidgetProps.Background.Data = img.Data;
// Sig.WidgetProps.AutoStretchBackground = true;
}

You need to set the Width and Height properties of Sig.WidgetProps.Background object by yourself. The TElPDFImage class doesn't extract them automatically at the moment (we have this in out ToDo list).
P.S. In fact you don't need to create an instance of TElPDFImage, because Sig.WidgetProps.Background is an instance of TElPDFImage. So you can set Data, Height, Width properties directly.
Quote
P.S.:
Could you provide some more code snipplets on signature location (as a function of document width and height)

You need to calculate signature location based on the target page width and height, check the documentation:
http://www.eldos.com/documentation/sb...einfo.html
http://www.eldos.com/documentation/sb...infos.html
Quote
signature form, visibility, printability, image formats and image usage etc. ? ;-)

Check this:
http://www.eldos.com/documentation/sb..._sign.html
http://www.eldos.com/documentation/sb...sible.html
http://www.eldos.com/documentation/sb...anges.html
http://www.eldos.com/documentation/sb...sions.html

What exactly do yo need?

Reply

Statistics

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