EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Problem with font size in PDF signature

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#35982
Posted: 02/23/2016 07:35:00
by Martin ANDRES (Standard support level)
Joined: 09/25/2014
Posts: 18

Hi,
I've created a PDF signature but the signature text is truncated so I would like to use a smaller font size with TitleFontSize, SectionTextFontSize and SectionTitleFontSize. It seems that those properties are not taken into account when the signature is created.
i'm using Delphi and this is the code that I'm using:

Code
   numberPages := Document.PageInfoCount;
  // adding the signature and setting up property values
  Index := Document.AddSignature;
  Sig := Document.Signatures[Index];
  Sig.Handler := PublicKeyHandler;
  Sig.AuthorName := 'SIMP Civil';
  Sig.SigningTime := LocalTimeToUTCTime(Now);
  Sig.Reason := '';

  Sig.WidgetProps.ShowOnAllPages := true;
  Sig.WidgetProps.Print := true;

  Sig.WidgetProps.AutoText := False;
  Sig.WidgetProps.AutoSize := False;
  Sig.WidgetProps.AutoStretchBackground := False;
  Sig.WidgetProps.AutoFontSize := False;

  Sig.WidgetProps.TitleFontSize := 1;
  Sig.WidgetProps.SectionTextFontSize := 1;
  Sig.WidgetProps.SectionTitleFontSize := 1;

  Sig.WidgetProps.AutoPos := true;

  Sig.WidgetProps.ShowTimestamp := false;
  Sig.WidgetProps.HideDefaultText := True;

  //Set the position according to data
  posicion := 51;
  if (cargo = '') then
    posicion := posicion - 10;
  if (dependencia = '') then
    posicion := posicion - 10;

  Sig.WidgetProps.CustomText.Add(_cert.SubjectName.CommonName, 58, posicion, 12);

  if (cargo <> '' ) then
    if (dependencia <> '') then
      Sig.WidgetProps.CustomText.Add(cargo, 58, 41, 10)
    else
      Sig.WidgetProps.CustomText.Add(cargo, 58, 31, 10);

  if (dependencia <> '') then
    Sig.WidgetProps.CustomText.Add(dependencia, 58, 31, 10);

  Sig.WidgetProps.CustomText.Add(_cert.SubjectName.Organization, 58, 21, 10);

  Sig.WidgetProps.CustomText.Add(GetEmail(_cert.Extensions.SubjectAlternativeName), 58, 11, 10);

  Sig.WidgetProps.BackgroundStyle := pbsCustom;
  Sig.WidgetProps.Background.Height := 81;
  Sig.WidgetProps.Background.Width :=  79;

  //Use image in the signature
  stream := TMemoryStream.Create;
  Image1.Picture.Graphic.SaveToStream(stream);
  stream.Position := 0;
  SetLength(HoldArray, stream.Size);
  stream.Read(HoldArray[0], Stream.Size);
  stream.Free;
  Sig.WidgetProps.Background.Data := HoldArray;
  Sig.WidgetProps.Background.ImageType :=  pitJPEG;

  Sig.WidgetProps.Width := 400;
  // visible document signature
  Sig.Invisible := false;


  // Adding Type 1 font
  SimpleFont := TElPDFSimpleFont.Create;
  SimpleFont.BaseFont := 'Arial';
  Sig.WidgetProps.AddFont(SimpleFont);
  //Manejo el encoding
  // "A fonts encoding is the association between character codes and glyph descriptions."
  // "Some character sets consist of more than 256 characters, including ligatures, accented characters,"
  // "and other symbols required for high-quality typography or non-Latin writing systems."
  // "Different encodings may select different subsets of the same character set."
  // Adding encoding object
  SimpleFont.EncodingObject := TElPDFEncoding.Create;
  Sig.WidgetProps.AddFontObject(SimpleFont.EncodingObject);
  // You can use one of predefined pdf encodings: StandardEncoding, MacRomanEncoding, WinAnsiEncoding or nothing
  SimpleFont.EncodingObject.BaseEncoding := 'WinAnsiEncoding';


I attach an image of the resulting PDF.

Why the signature don't use a smaller font size?.
We have SecureBlackbox 12 VCL.

I really appreciate your help.

Regards,
Martin
#35983
Posted: 02/23/2016 07:41:22
by Martin ANDRES (Standard support level)
Joined: 09/25/2014
Posts: 18

I attach the resulting PDF

Regards,
Martin


#35984
Posted: 02/23/2016 07:49:45
by Dmytro Bogatskyy (EldoS Corp.)

Thank you for contacting us,

Quote
I've created a PDF signature but the signature text is truncated so I would like to use a smaller font size with TitleFontSize, SectionTextFontSize and SectionTitleFontSize. It seems that those properties are not taken into account when the signature is created.

–źdditionally, you need to set TElPDFSignatureWidgetProps.AutoFontSize property to "false" value. See: https://www.eldos.com/documentation/sb...tsize.html
#35985
Posted: 02/23/2016 07:56:42
by Martin ANDRES (Standard support level)
Joined: 09/25/2014
Posts: 18

Thanks for your reply.

I've already set TElPDFSignatureWidgetProps.AutoFontSize to false in my code with:

Sig.WidgetProps.AutoFontSize := False;

You can check it in my original post.
This is the property that you're talking about?

Thanks and regards,
Martin
#35986
Posted: 02/23/2016 08:46:49
by Dmytro Bogatskyy (EldoS Corp.)

Hi,

Quote
Sig.WidgetProps.AutoFontSize := False;

You can check it in my original post.
This is the property that you're talking about?

Yes, that's right. TitleFontSize, SectionTextFontSize and SectionTitleFontSize properties has only effect on the default text in the signature widget, but you have hidden the default text by using HideDefaultText property and then you are adding a text using CustomText property. In this case the font size of a custom text is controlled by fourth and fifth parameters in the Add() method, see: https://www.eldos.com/documentation/sb...d_add.html
Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages

Reply

Statistics

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