Setting Opacity of TextField Annotation using Markup doesnot work.

Hi All,

I have been trying to set the opacity of a textfield (form field) using markup but it doesnot seem to take effect. What I have tried follows:

Public Sub HighlightField()

Dim textfield As Field = _pdfdoc.GetField(“EmployeeName”)
Dim annot1 As pdftron.PDF.Annots.Widget = New pdftron.PDF.Annots.Widget(textfield.GetSDFObj)

Dim m As pdftron.PDF.Annots.Markup = New pdftron.PDF.Annots.Markup(annot1)
m.SetColor(New ColorPt((255 / 255.0), (0 / 255.0), (255 / 255.0)), 3)
m.SetInteriorColor(New ColorPt((0 / 255.0), (0 / 255.0), (255 / 255.0)), 3)
m.SetOpacity(0.3)
annot1.RefreshAppearance()

_pdfview.Refresh()
_pdfview.Update()

End Sub

please review this and figureout where I am wrong.

Thanks.

I actually want to make TextField To be Transparent in PDFViewCtrl when typing text. The default is white color. Most of the PDF viewer controls support this. PDFTron does provide SetBackgroundColor for a field but with no transparency. Please advise.

Thanks

TransparentTextField.jpg

An Image is being attached to clear you what I want to achieve.
The white textbox background should be transparent as like with other form fields i.e. checkboxes which supports transparency.

Thanks.

You should not have to do anything to have a transparent background, that is the “default”. Actually most PDF viewers will auto-highlight form fields at runtime.

The following code will add a text field with no background.

`
// DEBUG - add dummy page to make the example clearer
Page blank_page = doc.PageCreate();
var builder = new ElementBuilder();
var writer = new ElementWriter();
writer.Begin(blank_page, ElementWriter.WriteMode.e_overlay);
var element = builder.CreateRect(0, 0, blank_page.GetPageWidth(), blank_page.GetPageHeight());
element.GetGState().SetFillColorSpace(ColorSpace.CreateDeviceRGB());
element.GetGState().SetFillColor(new ColorPt(1, 0, 1));
element.SetPathFill(true);
writer.WriteElement(element);
writer.End();
// END DEBUG - following code is the important part

// create field
Field emp_first_name = doc.FieldCreate(“employee.name.first”, Field.Type.e_text, doc.CreateIndirectString(“John”));

// set appearance of field. No background (Transparent) and cyan border
pdftron.PDF.Annots.Widget annot1 = pdftron.PDF.Annots.Widget.Create(doc.GetSDFDoc(), new Rect(50, 550, 350, 600), emp_first_name);
annot1.SetBorderStyle(new Annot.BorderStyle(Annot.BorderStyle.Style.e_solid, 2.0));
annot1.SetBorderColor(new ColorPt(0, 1, 1), 3);
annot1.RefreshAppearance();

// add annotation to page, and page to document
blank_page.AnnotPushBack(annot1);
doc.PagePushBack(blank_page);
`

Thanks for your reply.

I am specifically talking about when user types something in the textfield. then a white nasty textbox appears for getting user input. This white box still appears and could not be changed its tranparency. But ony its background could be set to a color, using for example:

annot1.SetBackgroundColor(New ColorPt(0, 0.4, 0.5, 3), 3)

This line change this white color when typing. but could not be transparent.

The result is still same in below image.

TransparentTyping.jpg

If the issue is with the behaviour while you are editing the text, that is not customizable.

Could you elaborate on why the non-transparent background is an issue?

Note: That our PDFViewWPF control is fully customizable in this regard. You may want to review why you are not using the newer, more customizable, PDFViewWPF class. Our SDK comes with samples for both viewers.

Thanks Ryan.

The image below clearly shows the difference of purpose of using textfields in a pdf form. The form fields in most cases are superimposed on existing pdf file. The user then provide the information through fields. The type & length of information varies with each case. Often the pdf is a approved format from government or management of companies and cannot be altered. Most of the Pdf viewer in the market have this fucntion (e.g. pdf-xchange, tall pdf components). I hope you will decide to introduce this in future. I have tried samples of PDFViewWPF which display the same whiteboxes.

TransparentTextFields.jpg

Is it possible to get access to the PDF file that you are testing with? Either here, or you can send privately to support.

I have tried samples of PDFViewWPF which display the same whiteboxes.

All of the UI code for our WPF viewer is available in the PDFViewWPFTools project. In particular, see the following function where you can change the default behaviour.FormFill.cs MapColorFont() and the mBackgroundBrush variable.