Rank: Member
Groups: Registered
Joined: 2/21/2019(UTC) Posts: 15
|
Is it possible to delete an individual field from a pdf?
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 133 time(s) in 130 post(s)
|
Hi, I guess so. You should delete the widget annotation of that field. And the field itself in the Interactive Form Dictionary. For example Code:
using(var doc = PdfDocument.Load(@"e:\ABWORK\_Projects\PDFAnnotator\Shared.Tests\Files\test002.pdf", new PdfForms()))
{
var field = doc.FormFill.InterForm.Fields.Single(item => item.FullName == "Column6_Szn77rtV*0hjPOwPY0vuDA");
var dict = doc.FormFill.InterForm.Dictionary;
var fieldsArray = dict["Fields"].As<PdfTypeArray>();
var refToField = fieldsArray.Single(item => item.As<PdfTypeDictionary>().Handle == field.Dictionary.Handle);
foreach (var page in doc.Pages)
{
if (page.Annots == null)
continue;
foreach (var ctrl in field.Controls)
{
var annot = page.Annots.GetByDictionary(ctrl.Dictionary);
if (annot != null)
page.Annots.Remove(annot);
}
}
fieldsArray.Remove(refToField);
doc.Save(@"e:\36\test.pdf", SaveFlags.NoIncremental | SaveFlags.RemoveUnusedObjects);
}
|
|
|
|
|
|
Rank: Member
Groups: Registered
Joined: 2/21/2019(UTC) Posts: 15
|
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close