PDFsharp & MigraDoc Forum

PDFsharp - A .NET library for processing PDF & MigraDoc - Creating documents on the fly
It is currently Tue Jul 15, 2025 1:34 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules

Also see our new Tailored Support & Services site.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Jul 11, 2025 11:34 am 
Offline

Joined: Fri Aug 09, 2024 5:06 am
Posts: 21
Hi Team,
I am using Digital Signature using certificate sample to test the signing feature. Almost all the files the Signature panel comes under left bottom of the page. But few documents, the signature panel appears at the center of the page. when i check the media box it values are like this /MediaBox[-1728.12 -1296 1728.12 1296] .Seems the page origin is centered. How to have the signature panel like the normal file( that is at left bottom). Here below the appearance handler. Any help would be great help.


Code:
        public void DrawAppearance(XGraphics gfx, XRect rect)
        {
            var font = new XFont("Times New Roman", 7.0, XFontStyleEx.Regular);
            var textFormatter = new PdfSharp.Drawing.Layout.XTextFormatter(gfx);
            double signatureHeight = rect.Height * .4;
            var point = new XPoint(rect.Width / 10, rect.Height / 10);
            point = new XPoint(point.X, rect.Height / 2d);
            textFormatter.DrawString("testsign", font, XBrushes.Black, new XRect(point.X, point.Y, rect.Width, rect.Height - point.Y), XStringFormats.TopLeft);
        }


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 14, 2025 6:28 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3132
Location: Cologne, Germany
Hi!

You don't share the code where you call "WorldToDefaultPage". Maybe that codes needs some adjustments.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 14, 2025 2:08 pm 
Offline

Joined: Fri Aug 09, 2024 5:06 am
Posts: 21
Hi Thomas
I am using the below which is in the unit test Sign_existing_file_Default.

Code:
   PdfDocument document = PdfReader.Open(filetoBeSigned);


                var options = new DigitalSignatureOptions
                {
                    ContactInfo = "jhon",
                    Location = "Seattle",
                    Reason = "License Agreement",
                    Rectangle = new(XUnit.FromCentimeter(1).Point, XUnit.FromCentimeter(0).Point,
                        XUnit.FromCentimeter(9.9).Point, XUnit.FromCentimeter(1.3).Point),
                    AppearanceHandler = new SignatureAppearanceHandler()
                };
                var pdfSignatureHandler = DigitalSignatureHandler.ForDocument(document, new PdfSharpDefaultSigner(certificate, PdfMessageDigestType.SHA256), options);
   
           


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group