PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 4:23 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Nov 13, 2016 2:16 am 
Offline

Joined: Wed Oct 19, 2016 9:14 am
Posts: 7
Location: Australia
I have an app where I fill out Form fields using the PdfTextField objects from doc.AcroForm
this works fine.
Code:
            PdfAcroForm myForm = _qaForm.AcroForm;
            if (myForm.Elements.ContainsKey("/NeedAppearances") == false)
                myForm.Elements.Add("/NeedAppearances", new PdfBoolean(true));
            else myForm.Elements["/NeedAppearances"] = new PdfBoolean(true);

            //Getting fields on the pdf form       
            PdfTextField fProjName = (PdfTextField) (myForm.Fields["ProjectName"]);
            fProjName.Font = new XFont("Verdana", 8);


But the template form generally has more fields than I need for a particular page, so I attempt to remove those.
Code:
PdfDocument doc = page.Owner;
            var iRemoved = 0;
            foreach (PdfAnnotation annotation in page.Annotations.ToList().OfType<PdfAnnotation>())
            {
                var annotParent = annotation.Elements[PdfAcroField.Keys.Parent] as PdfReference;
                var title = (annotParent != null)
                    ? ((PdfDictionary)annotParent.Value).Elements[PdfAcroField.Keys.T].ToString()
                    : annotation.Title;
                //if title matches...
                page.Annotations.Remove(annotation);
                        iRemoved++;break;


this appears to work and indeed if I open using PDFXEditor, the fields don't show. But if open using Chrome , PDFXViewer , or try to read the file using PDFSharp, the fields are still there. Until the document is signed, then it appears they are removed.

Any ideas or better way to remove the Fields ?

_________________
Thanks

Rob


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 145 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