logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
paleise  
#1 Posted : Thursday, July 19, 2018 10:56:45 AM(UTC)
paleise

Rank: Advanced Member

Groups: Registered
Joined: 10/13/2017(UTC)
Posts: 32
Germany
Location: Freiburg

Thanks: 1 times
Hi,
is it possible to hide a button of a form via PdfViewer?
Sample:
Code:
pdfViewer1.LoadDocument(pdfFile);
PdfDocument pdfDocument = this.pdfViewer1.Document;
PdfInteractiveForms pdfForm = pdfDocument.FormFill.InterForm;
PdfField field = pdfForm.Fields.FirstOrDefault(x => x.FullName == "XXX");
field.hide()


Thank you for your time!

Regards Peter

Edited by moderator Thursday, July 19, 2018 9:33:56 PM(UTC)  | Reason: Not specified

Paul Rayman  
#2 Posted : Thursday, July 19, 2018 10:02:28 PM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 743

Thanks: 1 times
Was thanked: 90 time(s) in 89 post(s)
Hi,

Yes it is possible.

Please look at code below

Code:
PdfDocument pdfDocument = this.pdfViewer1.Document;
PdfInteractiveForms pdfForm = pdfDocument.FormFill.InterForm;
PdfField field = pdfForm.Fields.FirstOrDefault(x => x.FullName == "Push Button0");
foreach(var ctrl in field.Controls)
{
    ctrl.Dictionary["F"] = PdfTypeNumber.Create(32); //Bit 6 - NoView. If set, do not display the annotation on the screen or allow it to interact with the user. 
                                                     //The annotation may be printed (depending on the setting of the Print flag) but should 
                                                     //be considered hidden for purposes of onscreen display and user interaction.
}
pdfViewer1.Invalidate();


Each field can have one or more views on one or more pages.
These views are called "controls" and are essentially the WidgetAnnotations.
And you can set the visibility flag (among other things) for these annotations.

For example, the above code sets the invisibility flag to all controls on the found field.

The value of the annotation dictionary’s F entry is an unsigned 32-bit integer containing flags specifying various characteristics of the annotation. Bit positions within the flag word are numbered from 1 (low-order) to 32 (high-order).

Bit Position - Name
1 - Invisible
2 - Hidden
3 - Print
4 - NoZoom
5 - NoRotate
6 - NoView
7 - ReadOnly
8 - Locked
9 - ToggleNoView
10 - LockedContents

More info about annotation flags you may found on page 608 here:
http://archimedespalimps...al/pdf_reference_1-7.pdf

Edited by user Thursday, July 19, 2018 10:09:04 PM(UTC)  | Reason: Not specified

thanks 1 user thanked Paul Rayman for this useful post.
paleise on 7/20/2018(UTC)
paleise  
#3 Posted : Friday, July 20, 2018 2:12:40 AM(UTC)
paleise

Rank: Advanced Member

Groups: Registered
Joined: 10/13/2017(UTC)
Posts: 32
Germany
Location: Freiburg

Thanks: 1 times
Hi Paul,
thank you very much for the quick help! Great!
Peter
Users browsing this topic
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.