Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Mon Aug 07, 2017 10:10 am

Can we adjust the font size or change alignment of signature content? Thanks.

PtChatuthai
 
Posts: 1
Joined: Mon Aug 07, 2017 10:04 am

Tue Aug 08, 2017 8:42 am

Hello,

Thanks for your inquiry.
In regards to your two requirements, our Spire.Pdf only supports modifying the font size at present. Please refer the following code.
Code: Select all
string sourcePDF = @"template.pdf";
            PdfDocument doc = new PdfDocument(sourcePDF);
            String pfxPath = "Demo.pfx";

            PdfPageBase page = doc.Pages[0];
            PdfCertificate digi = new PdfCertificate(pfxPath, "e-iceblue");
            PdfSignature signature = new PdfSignature(doc, page, digi, "demo");

            //change the font size of the content details, only several font is available
            signature.SignDetailsFont = new PdfFont(PdfFontFamily.Helvetica, 5f);
            signature.Bounds = new RectangleF(new PointF(10,100), new SizeF(300, 300));
            signature.IsTag = true;

            //fill the content
            signature.DigitalSignerLable= "Digitally signed by";
            signature.DigitalSigner = "Jane for Test";
            signature.DistinguishedName = "DN:";
            signature.LocationInfoLabel = "Location:";
            signature.LocationInfo = "London";
            signature.ReasonLabel = "Reason: ";
            signature.Reason = "Le document est certifie";
            signature.DateLabel = "Date: ";
            signature.Date = DateTime.Now;
            signature.ContactInfoLabel = "Contact:
            signature.ContactInfo = "123456789";
            signature.Certificated = false;

            signature.ConfigGraphicType = ConfiguerGraphicType.Picture;
            signature.ConfiguerGraphicPath = "pic.jpg";
            signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill;
            signature.GraphicsMode = GraphicMode.SignImageAndSignDetail;
            doc.SaveToFile("11309.pdf");


If there's still any doubt, welcome to contact us.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Mon Sep 25, 2017 9:57 am

Hello PtChatuthai,

Glad to inform that the new feature, setting text alignment of signature content, is available now. Please download the hotfix Spire.PDF Pack(Hot Fix) Version:3.9.360 and use the code below to have a test.
Code: Select all
signature.SignTextAlignment=SignTextAlignment.Right;


Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Wed Nov 20, 2019 6:48 am

Can I change the font color of the signature content?

sayan1995
 
Posts: 7
Joined: Wed Sep 18, 2019 7:35 am

Wed Nov 20, 2019 7:26 am

Hi,

Thanks for your inquiry.
Please refer to following code to change font color.
Code: Select all
            signature.SignFontColor = Color.Red;


Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Nov 21, 2019 6:46 am

Hi, I am facing an issue with Spire pdf digital signature and that is : We are trying to position the digital signature at the top left corner of all pdfs but when ut seems the position of the signature is varying from one pdf to another also the PointF(0,0) location is supposed to be at the left bottom corner according to my understanding but at PointF(0,0) location the Signature is being stamped at left most lower middle section. Can you please let us understand How we can put the digital signature on the top left corner no matter what is the page dimension and size. Thanks

sayan1995
 
Posts: 7
Joined: Wed Sep 18, 2019 7:35 am

Thu Nov 21, 2019 9:22 am

Hi,

Thanks for your inquiry.
In general, the PointF(0,0) location is top left corner. As for your issue, the PointF(0,0) location is left most lower middle section, please provide your input PDF and the full code you were using for further investigation.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Nov 21, 2019 10:15 am

public byte[] DigitallySignPdf(byte[] pdfdata, int StatusId)
{
Response response = new Response();
byte[] signedPdfdata = null;
try
{
Guid UserId = Guid.Empty;
if (Session != null)
{
UserId = Guid.Parse(Session["UserID"].ToString());
}
//Spire.License.LicenseProvider.SetLicenseKey(key);
//Spire.License.LicenseProvider.SetLicenseFileName("license.elic");
//Response res = new Response();
Spire.License.LicenseProvider.LoadLicense();
PdfDocument doc = new PdfDocument();
doc.LoadFromBytes(pdfdata);
int pageCount = doc.Pages.Count;
//Response certificateResponse = new Response();

////certificateResponse = _userService.GetUserCertificate(UserId);

UserCertificateModel ucm = new UserCertificateModel();
ucm = _userService.GetUserCertificate(UserId).obj;
ucm.Password = SecurityHelper.DecryptPassword(ucm.Password);
PdfCertificate cert = new PdfCertificate(ucm.Certificate, ucm.Password);
//PdfSignature signature = new PdfSignature(doc, doc.Pages[pageCount - 1], cert, "Signature1");
PdfSignature signature = new PdfSignature(doc, doc.Pages[0], cert, "Signature1");
signature.Bounds = new RectangleF(new PointF(0, 0), new SizeF(150, 90));
signature.GraphicsMode = GraphicMode.SignDetail;//.SignImageAndSignDetail;
signature.Location = new PointF(0, doc.PageSettings.Size.Height - 50);

signature.LocationInfo = "Ireland,Dublin";

signature.NameLabel = "Digitally Signed by:";
signature.Name = signature.Certificate.GetNameInfo(System.Security.Cryptography.X509Certificates.X509NameType.SimpleName, true);
//signature.ContactInfoLabel = "ContactInfo:";
//signature.ContactInfo = signature.Certificate.GetNameInfo(System.Security.Cryptography.X509Certificates.X509NameType.SimpleName, true);
signature.LocationInfoLabel = "Location:";
signature.SignFontColor = Color.Red;
signature.ReasonLabel = "Organisation: ";
signature.Reason = "DMS Governance";
signature.DateLabel = "Date:";
signature.Date = DateTime.Now;
signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges;
signature.Certificated = false;
signature.SignDetailsFont = new PdfFont(PdfFontFamily.TimesRoman, 5f);
signature.SignNameFont = new PdfFont(PdfFontFamily.Courier, 10);

//signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill | PdfCertificationFlags.ForbidChanges;
//save and reload
//doc.SaveToStream(stream);
//doc = new PdfDocument(stream);
using (MemoryStream to_stream = new MemoryStream())
{
doc.SaveToStream(to_stream, FileFormat.PDF);
signedPdfdata = to_stream.ToArray();
}
}
catch (Exception ex)
{
if (!(ex is CustomArgNullException) && !(ex is CustomInvalidOpException))
_exceptionHandler.HandleException(ref ex, "TaskController => DigitallySignPdf");
response.IsError = true;
response.ErrorCode = "";
response.ErrorMessage = ex.Message;
}
return signedPdfdata;
}
============================================================
Also the file(FileConatinsInvisibleSinnature) is getting a signature which is no longer visible because of the Location being PointF(0,doc.PageSettings.Size.Height).

sayan1995
 
Posts: 7
Joined: Wed Sep 18, 2019 7:35 am

Fri Nov 22, 2019 6:02 am

Hi,

Thanks for your inquiry.
I have noticed the position of PointF(0,0) is not top left corner, and logged it in our bug system. Besides, I found doc.PageSettings.Size is not the actual size of your PDF, I suggest you use doc.Pages[0].ActualSize, but the signature is also invisible when using the position PointF(0, doc.Pages[0].ActualSize.Height-90), I also posted this issue to our Dev team.
We will let you know once there is any update. Sorry for the inconvenience caused.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Mon Dec 16, 2019 9:49 am

Hi,

Glad to inform you that the issue has been fixed. Welcome to download and use the latest Spire.PDF Pack(Hot Fix) Version:5.12.15.
Our website link: https://www.e-iceblue.com/Download/down ... t-now.html
NuGet link: https://www.nuget.org/packages/Spire.PDF/5.12.15

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Aug 18, 2020 8:35 am

Hi Betsy.jiang,

The below code is not working for me. It is just replacing with white space and text is not showing. Can you please help with this?

foreach (PdfPageBase page in documents.Pages)
{
foreach (var word in dictionary)
{
result = page.FindText(word.Key, TextFindParameter.IgnoreCase).Finds;
foreach (PdfTextFind find in result)
{

PdfGraphicsState state = page.Canvas.Save();

PdfBrush brush = new PdfSolidBrush(Color.White);
RectangleF rect = find.Bounds;

//Draw a rectangle to cover the original text
page.Canvas.DrawRectangle(brush, rect);
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font(FontFamily.GenericSansSerif, 20f));
PdfBrush brush2 = PdfBrushes.Red;
PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Center);
//Draw new text
page.Canvas.DrawString(word.Value, font,new PdfPen(new PdfRGBColor(Color.Black),10), brush2, find.Bounds, format);
page.Canvas.Restore(state);


}
}
}


Thanks,
Anilkumar

anil.menta
 
Posts: 8
Joined: Tue Aug 11, 2020 9:34 am

Tue Aug 18, 2020 10:46 am

Hi Anilkumar,

Thanks for your post.
According to the information you mentioned in this post, this issue may be related to font size you set, please try setting it to a smaller value, as shown below.
Code: Select all
  PdfTrueTypeFont font = new PdfTrueTypeFont(new Font(find.FontName, 12f));


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.PDF