Print Page | Close Window

Problem with signing a PDF

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3657
Printed Date: 28 Mar 24 at 12:29PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Problem with signing a PDF
Posted By: R-S
Subject: Problem with signing a PDF
Date Posted: 03 Jan 19 at 9:42AM
hey all,
I'm currently busy with figuring out how to sign a pdf.
I first convert a document type to pdf and then will try to sign the file with a pfx file.

public override string[] Convert(string[] bitmaps)
        {
            string filename = CoState.CreateWorkingFilename();

            using (mGenerator = new PDFProcessor())
            {
                PrepareGenerator();

                mGenerator.NewPages(bitmaps.Length - 1);

                mPageId = 1;
                
                ProcessPages(bitmaps);

                mGenerator.SaveToFile(filename);
                SignPFD(filename);

            }

            return new string[] { filename };
        }
public void SignPFD(string filename)
        {
            int temp;
            temp = mGenerator.SignFile(filename, "", "Tempfield", "C", "Certificate.pfx", "PASSWORD", "j", "i", "z");
            System.Console.Write(temp + "signfile output \n");
        }
but i get a Error:
    Exception thrown: 'System.AccessViolationException'
    An unhandled exception of type 'System.AccessViolationException'
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
when the programs tries to run the code SignFile.
Am i overlooking something?

PS. all the other things do work. The problems is only with signing the file

EDIT:
i have also tried another approach:
            mGenerator.DrawText(100, 700, "This is the file to be signed");
            mGenerator.SaveToFile("TheUnsignedFile.pdf");

            int SignProcessID = mGenerator.NewSignProcessFromFile("TheUnsignedFile.pdf", "");
            if (SignProcessID > 0) {
                mGenerator.SetSignProcessPFXFromFile(SignProcessID, "Certificate.pfx", "PASSWORD");
                mGenerator.SetSignProcessInfo(SignProcessID, "To test digital signatures", "The World", "Contact me");
                mGenerator.SetSignProcessField(SignProcessID, "Contract Signature");
                mGenerator.SetSignProcessFieldBounds(SignProcessID, 100, 600, 200, 100);
                mGenerator.SetSignProcessFieldImageFromFile(SignProcessID, "visualsignature.jpg", 0);
                mGenerator.EndSignProcessToFile(SignProcessID, "TheSignedFile.pdf");
            }
but i get the same Error at the function EndSignProcessToFile.



Replies:
Posted By: Ingo
Date Posted: 03 Jan 19 at 8:13PM
Hi Rens,

the described error is a very common one - reasons could be many for it...
Some things you should think over:
Which is your development-ID/...language?
How strings are handled inside?
String-handling in QuickPDF is always in unicode-format.
QuickPDF comes along as dll- and activex-version - which one you're using?
32- or 64-bit... system32- or syswow64-path...?
and so on... a lot to do for you first... Sorry ;-)
The online-reference, developer-guide and samples you've already found?

Cheers and welcome here,
Ingo



-------------
Cheers,
Ingo



Posted By: R-S
Date Posted: 04 Jan 19 at 8:37AM
Hey Ingo,

Thank for you reply.

I'm programming in C3 with visualstudio 2017.
As for the string handling. I looked it up and don't find a problem with the unicode-format.
The build target is set to any-cpu and VS is a 32-bit installation.
Also, i'm using the Dll version 9.16 got both 32 and 64 dll's

And yes, i have found the examples ans such. Thanks ^^

I hope this will give a little bit extra information.
I keep searching for the solution myself further.

Greeting,


Posted By: Ingo
Date Posted: 04 Jan 19 at 10:47AM
Hi Rens,

the additions won't help.
It's like you're telling me that your car doesn't drive and that the reason is that the motor doesn't start. Sorry ;-)
Perhaps it has to do with the mixed installation... perhaps...
Try to separate 64/32 bit...
I don't think that you'll get another hint here...



-------------
Cheers,
Ingo



Posted By: R-S
Date Posted: 14 Jan 19 at 2:19PM
Hi Ingo,

I have been continue searching for the problem. It seems to be a problem with bit type you are using. If i call the function in a 32bit solution, the function works fine. But if i build a 64 bit solution i get the memory problem.

I also have tested it with a new project. Making a simple pdf en then trying to sign it. There the same problem occurs. 32bit works, 64 bit doesn't work.

Can it be that there is something wrong with variables that are parsed wrong in the libary if you use a 64 bit?

Also, the same problem also come with the function RenderPageToDC, but there the 64bit version works and the 32 bit version doesn't work.

I hope this might help people and maybe it is a bug?


Posted By: Ingo
Date Posted: 14 Jan 19 at 8:58PM
Hi Rens,

you shouldn't write these things to me.
I'm only a user...
I you think that there's an error in the library you should post it on the official support page of the publishers:
https://www.debenu.com/products/development/debenu-pdf-library/



-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk