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.

Wed Aug 30, 2023 12:59 am

Trying to add Name only as signature but the text gets cut off to half the width Bounds.
I assume this is normally to allow details to go next to the Name but in this case it's SignNameOnly.

Dim signature As New PdfSignature(doc, page, cert, userDesc)
signature.GraphicsMode = GraphicMode.SignNameOnly
signature.Bounds = New RectangleF(point, New SizeF(120, 30))

Kevin.Cox
 
Posts: 8
Joined: Mon Aug 28, 2023 6:17 am

Wed Aug 30, 2023 5:44 am

Hi,

Thank you for your inquiry.
I tested the code you provided and encountered the same problem as you.
As you guessed, GraphicMode. SignNameOnly cut off to half Bounds
The GraphicMode. SignNameAndSignDetail method will match the entire text box.
These are my test screenshots:
GraphicMode. SignNameOnly:
9.png

GraphicMode. SignNameAndSignDetail:
10.png

Please choose the method you want based on your actual situation.
If you have any issue just feel free to contact us.

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Wed Aug 30, 2023 6:43 am

Thanks for your reply.
I only want the Name visible on the PDF.
Am I incorrect in assuming that SignNameAndSignDetail will add the certificate details?

Kevin.Cox
 
Posts: 8
Joined: Mon Aug 28, 2023 6:17 am

Wed Aug 30, 2023 8:03 am

Hi,

Thank you for your more inquiry
For your issue of “ SignNameAndSignDetail will add certificate details”?
Yes.If you only want to display the name in the PDF,you still choose SignNameOnly .
If you have any issue just feel free to contact us.

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Wed Aug 30, 2023 12:44 pm

Issue is that SignNameOnly is cropped.
The width could be doubled to allow the full name but that looks very unprofessional and may also overlap another signature.
When I try to use Name only in another program like PDF XChange it allows full width for the name.

Kevin.Cox
 
Posts: 8
Joined: Mon Aug 28, 2023 6:17 am

Thu Aug 31, 2023 3:26 am

Hi,

Thank you for your more inquiry.
Our products follow the rules of Adobe software. When we manually add a signature with only signName in Adobe software, your signature will also be truncated to half the width Bounds. Therefore, this is a normal phenomenon.
If you have any issue just feel free to contact us。

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Thu Aug 31, 2023 5:53 am

Text to fills the frame but the bottom is clipped because the text is not centred vertically.

signature.Bounds = New RectangleF(point, New SizeF(120, 30))
signature.SignDetailsFont = New PdfTrueTypeFont(New System.Drawing.Font("Arial Unicode MS", 26.0F, System.Drawing.FontStyle.Regular))

Kevin.Cox
 
Posts: 8
Joined: Mon Aug 28, 2023 6:17 am

Thu Aug 31, 2023 10:35 am

Hi

Thank you for your feedback.
Since the PDF content is drawn on the page canvas, if your fixed the rectangle box size and the font size is too large, the content may not be able to fit completely within the box. To avoid this issue, you can reduce the font size appropriately.
Below is the sample code for your reference:
Code: Select all
Dim doc As New PdfDocument()
doc.LoadFromFile("ABC123-01-DW-0000-QC-CON-0003.pdf")
Dim cert As New PdfCertificate("test.pfx", "key")
Dim signature As New PdfSignature(doc, doc.Pages(0), cert, "signature")
signature.Bounds = New RectangleF(New PointF(-595, 421), New SizeF(120, 30))
Dim recWidth As Single = signature.Bounds.Width
signature.SignTextAlignment = SignTextAlignment.Center
      Dim text As String = "Kevin.Cox"
      signature.Name = text
      Dim fontsize As Single = 26.0F
      Do While fontsize > 0F
         Dim f1 As New Font("Arial Unicode MS", fontsize, FontStyle.Regular)
         Dim font As New PdfTrueTypeFont(f1, fontsize)
         Dim fontWidth As Single = font.MeasureString(text).Width

         If recWidth / 4 > fontWidth Then
            signature.SignDetailsFont = font
            Exit Do
         Else
            fontsize -= 1
         End If
      Loop
      signature.DocumentPermissions = PdfCertificationFlags.AllowFormFill Or PdfCertificationFlags.ForbidChanges
      signature.GraphicsMode = GraphicMode.SignNameOnly
doc.SaveToFile("out.pdf")

The screenshot is as follows:
11.png

If there is still any issues, please share your desired effect screenshot to help us do further investigation. Thank you in advance.

Sincerely
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Mon Sep 25, 2023 6:31 am

Hi

I would like to know if the solution we provide can help you solve the problem you are encountering, and I hope to have more communication with you. if the issue still exists, please offer your file to help us do further investigation, you can attach here or send it to us via email ([email protected] ). Thank you in advance.

Sincerely,
Ula
E-iceblue support team
User avatar

Ula.wang
 
Posts: 282
Joined: Mon Aug 07, 2023 1:38 am

Return to Spire.PDF