Rotating PDF Signature

Hi all!

is there any way to rotate a drawn signature in page?

I had tried to use signature.Appearance.Normal.Graphics.RotateTransform(-90) just before save the document and I had no effect at all.

Of course, I'm using a signature with logo and text created using the Syncfusion libraries and methods...  everything is ok except by the rotation.

Thanks!

11 Replies 1 reply marked as answer

SL Sowmiya Loganathan Syncfusion Team July 8, 2020 10:05 AM UTC

Hi David,   
  
Thank you for contacting Syncfusion support.   
  
We have created the sample to achieve your requirement of insert image with rotation in signature appearance. Please find the download link from below,  
  
  
Please try the sample in your end and let us know the result.   
  
Regards,  
Sowmiya Loganathan  




DA DavidBS July 8, 2020 01:08 PM UTC

Hi Sowmiya!!

Thank you - I'll try the code right in minutes.


DA DavidBS July 8, 2020 01:12 PM UTC

Sowmiya, when I try these links I've "The Syncfusion account you logged in to is not associated with this download. Please use the Syncfusion account associated with the file you are trying to download."


If you prefer, you can send it to me using the TRACK-BUG-REPORT option...


SL Sowmiya Loganathan Syncfusion Team July 9, 2020 06:40 AM UTC

Hi David,  
 
Sorry for the inconvenience.  
 
Please find the download link for the same from below,  
 
 
Regards, 
Sowmiya Loganathan 


Marked as answer

DA DavidBS July 9, 2020 12:03 PM UTC

Hi Sowmiya,

Don't excuse!  It's clear to me it was just a normal mistake...

I sincerely thank you for your whole support, all the time!

I will see the code right now and return to a status on it.

Kindest regards,
David


DA DavidBS July 9, 2020 01:57 PM UTC

Hi Sowmiya!

Follows some intesting thing I have here:

1) I'm using the code before proceed to sign the document. The "Translate" and "Rotate" occurs before some lines of DrawImage and DrawString I have here. The signature rotates well, but:

     a) if using signature.Appearance.Normal.Graphics.TranslateTransform(signature.Appearance.Normal.Height, signature.Appearance.Normal.Width) it appears croped, like a square instead a rectangle (which it is originally).

     b) if I swap WIDTH and HEIGHT, the field appears (I see the changed cursor over it) but no one text/image appears there.

Follows a piece of code:


Dim State As PdfGraphicsState = signature.Appearance.Normal.Graphics.Save()

signature.Appearance.Normal.Graphics.TranslateTransform(signature.Appearance.Normal.Height, signature.Appearance.Normal.Width)
signature.Appearance.Normal.Graphics.RotateTransform(-90)

signature.Appearance.Normal.Graphics.DrawString(Label1.Text & Label9.Text.Trim, Font, Pblue, BRblue, 100, 200)
signature.Appearance.Normal.Graphics.DrawString(Label2.Text & Label10.Text.Trim, Fonte, Pblue, BRblue, 100, 220)
signature.Appearance.Normal.Graphics.DrawString(Label3.Text & Label11.Text.Trim, Fonte, Pblue, BRblue, 100, 230)

signature.Appearance.Normal.Graphics.Restore()

loadedDocument.Save(Destino)
loadedDocument.Close(True)
loadedDocument.Dispose()



2) As I said above, I'm using your code just before DRAW anything. But I was wondering if would be better to SAVE the document with the original signature position and size and, right after, open it, translate and rotate the field and save it again with a new name.  Do you see any advantage to perform the rotation this way?

I appreciate your help Sowmiya.

Warm hugs!






DA DavidBS July 9, 2020 05:04 PM UTC

Sowmiya,

I can't rotate the rectangular custom label made to the signature without crop it...  I guess the problem is related to the SIGNATURE field itself, which is not a square (and really it cannot be since there are other fields in the same page). 

I was wondering if would be interesting to create all graphic text and images (logo) using DRAWSTRING and DRAWIMAGE as I perform now, but instead to use it directly into the SIGNATURE field as I do, make them in a graphic space (how can I get it?), then save it as a PNG and only after these steps load the image into a vertical SIGNATURE field.

What do you think about it?

Thanks!!



DA DavidBS July 10, 2020 02:46 AM UTC

Sowmyia,

I tried using BITMAP and ROTATECLIP method of Graphics successfully getting the rotated image into the signature field.

But even using Hi-Quality settings of antialiases, I can't have the text using the same quality I see if using PDFBrush, PDFPen and the Drawstring method of PDFSignature.Appearance.Normal.

Look my attachment to see the ugly image I have, even using the below code:

bmp.SetResolution(300, 300)

Dim graphics__1 As Graphics = Graphics.FromImage(bmp)

graphics__1.PageUnit = GraphicsUnit.Pixel
graphics__1.CompositingQuality = CompositingQuality.HighQuality
graphics__1.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
graphics__1.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
graphics__1.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality
graphics__1.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit

graphics__1.Clear(Color.Transparent)

So, I guess I'm in a corner now:

- if using Syncfusion methods, I get the best text resolution but cannot rotate the signature if I have a rectangular field (mainly if it has small height).  

- to rotate image using my own bitmap and RotateFlip method of Graphics (simples and efficient) to achieve what I want, either using Drawstring or Path I have a "blur" text on my image (see attachment).

Do you have any idea of how can I bypass that problem?

Thanks in advance!


Attachment: Sowmyia_829e6a77.zip


SL Sowmiya Loganathan Syncfusion Team July 10, 2020 11:42 AM UTC

Hi David,   
  
1) I'm using the code before proceed to sign the document. The "Translate" and "Rotate" occurs before some lines of DrawImage and DrawString I have here. The signature rotates well, but:  


  
     a) if using signature.Appearance.Normal.Graphics.TranslateTransform(signature.Appearance.Normal.Height, signature.Appearance.Normal.Width) it appears cropped, like a square instead a rectangle (which it is originally).

  
  
     b) if I swap WIDTH and HEIGHT, the field appears (I see the changed cursor over it) but no one text/image appears there.  
  
2) As I said above, I'm using your code just before DRAW anything. But I was wondering if would be better to SAVE the document with the original signature position and size and, right after, open it, translate and rotate the field and save it again with a new name.  Do you see any advantage to perform the rotation this way?  
  
While adding text or image in signature appearance with translate transform, we need to calculate the correct bounds (based on the translate transform bounds) and add it in DrawString method. We have created the sample to achieve your requirement and please download link,   
  
  
Please try the above sample in and let us know the result.   
  
Regarding second query: The rotation of string can be handled in draw string method of signature appearance. So there is no need to save the PDF and again with rotation.   
I can't rotate the rectangular custom label made to the signature without crop it...  I guess the problem is related to the SIGNATURE field itself, which is not a square (and really it cannot be since there are other fields in the same page).   
  
I was wondering if would be interesting to create all graphic text and images (logo) using DRAWSTRING and DRAWIMAGE as I perform now, but instead to use it directly into the SIGNATURE field as I do, make them in a graphic space (how can I get it?), then save it as a PNG and only after these steps load the image into a vertical SIGNATURE field.  
  
What do you think about it?  
  
Could you please let us know the further details about your requirement. It will helpful for us to provide the precise solution on this.   
I tried using BITMAP and ROTATECLIP method of Graphics successfully getting the rotated image into the signature field.  
  
But even using Hi-Quality settings of antialiases, I can't have the text using the same quality I see if using PDFBrush, PDFPen and the Drawstring method of PDFSignature.Appearance.Normal.  


  
Look my attachment to see the ugly image I have, even using the below code:  
  
                             bmp.SetResolution(300, 300)  
  
                             Dim graphics__1 As Graphics = Graphics.FromImage(bmp)  
  
                             graphics__1.PageUnit = GraphicsUnit.Pixel  
                             graphics__1.CompositingQuality = CompositingQuality.HighQuality  
                             graphics__1.SmoothingMode = Drawing2D.SmoothingMode.HighQuality  
                             graphics__1.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic  
                             graphics__1.PixelOffsetMode = Drawing2D.PixelOffsetMode.HighQuality  
                             graphics__1.TextRenderingHint = Drawing.Text.TextRenderingHint.ClearTypeGridFit  
  
                             graphics__1.Clear(Color.Transparent)  
                               
  
So, I guess I'm in a corner now:  


  
- if using Syncfusion methods, I get the best text resolution but cannot rotate the signature if I have a rectangular field (mainly if it has small height).    


  
- to rotate image using my own bitmap and RotateFlip method of Graphics (simples and efficient) to achieve what I want, either using Drawstring or Path I have a "blur" text on my image (see attachment).  
  
Do you have any idea of how can I bypass that problem?  
  
We have analyzed the provided image file and found that the blur text in image file itself. Due to this only this issue occurs. However, we can able to add image in rotated signature with rectangular field (small height) by resizing the image. Please refer the below sample for your reference,   
  
  
  
  
If you have facing any issues in your end, please revert us with the below details, it will helpful for us to provide the precise solution on this.  
  
  • Modified sample
  • Output document
  • Input image file
  • Expected Output
  
Regards,  
Sowmiya Loganathan  
 



DA DavidBS July 10, 2020 12:17 PM UTC

Hi Sowmyia,

Thank you again for yor whole attention.

I'll check your code during this day and tomorrow and I'll return to you some details.

Have a very good week end.

Kindest regards and hugs!


DA DavidBS July 11, 2020 04:29 PM UTC

Solved Sowmiya.

Again, thank you very much for complete cooperation.

Warm hugs!


Loader.
Up arrow icon