Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AcroForm is always null #100

Open
BergenSoft opened this issue Aug 26, 2019 · 4 comments
Open

AcroForm is always null #100

BergenSoft opened this issue Aug 26, 2019 · 4 comments

Comments

@BergenSoft
Copy link

I want to create a pdf with fields in it.
I use MigraDoc but my problem is related to pdfSharp classes.

        Document document = new Document();

        Section section = document.AddSection();
        section.AddParagraph("Signature Test");


        PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(false, PdfFontEmbedding.Always);
        pdfRenderer.Document = document;
        pdfRenderer.RenderDocument();

        // NullPointerException: AcroForm is null
        pdfRenderer.PdfDocument.AcroForm.Elements.Add(PdfAcroForm.Keys.SigFlags, new PdfInteger(3));

        const string filename = "HelloWorld.pdf";
        pdfRenderer.PdfDocument.Save(filename);
        Process.Start(filename);

My problem is that the pdfRenderer.PdfDocument.AcroForm is always null and there is no possibility to create a new object.
Unfortunately there is no example on the homepage.

@AnthonyWillekens
Copy link

i've exactly the same problem.
Any issue since this post?

@KC7465128305
Copy link

I have exactly the same problem. I have AcroForm equal to null and there is no help on the internet.

@BergenSoft
Copy link
Author

I found a workaround for my problem. Maybe it helps also you. See here: https://stackoverflow.com/a/57670391/5772381

@KC7465128305
Copy link

Thanks! Just what I need. I also found this
https://stackoverflow.com/questions/54486608/c-create-pdf-form-acroform-using-pdfsharp

This one is adding a text field instead of a signature field.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants