|
Thanks Paul, this is a great peace of code and really helpful!
One more thing I wanted to ask about the drop down button on the right hand side of the field. Do we need to display our own button when the input field gets focus for example, or we can reuse some stock standard button available in Patagames SDK?
Best regards, Alex.
|
|
Hello, You can intercept the click on the input field, show your own calendar and then set the value programmatically. Here is an illustration Code:
public class MyPdfViewer : PdfViewer
{
protected override void OnMouseDown(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
if (Document != null)
{
var loc = e.Location;
int idx = PointInPage(loc);
if (idx >= 0)
{
var pagePoint = ClientToPage(idx, loc);
int zOrder;
var ctrl = Document.Pages[idx].GetControlAtPoint((float)pagePoint.X, (float)pagePoint.Y, out zOrder);
if (ctrl != null && ctrl.Field.FieldType == Patagames.Pdf.Enums.FormFieldTypes.FPDF_FORMFIELD_TEXTFIELD)
{
if (FieldIsDateFormatted(Document, ctrl.Field))
{
MessageBox.Show("Show modaal calendar instead this");
//In fact, you should execute the below code after exiting the modal calendar dialog. And this is just an illustration.
Document.FormFill.ForceToKillFocus();
ctrl.Field.Value = "your own value";
Invalidate();
}
}
}
}
}
base.OnMouseDown(e);
}
private bool FieldIsDateFormatted(PdfDocument doc, PdfField field)
{
if (!field.Dictionary.ContainsKey("AA") || !field.Dictionary["AA"].Is<PdfTypeDictionary>())
return false;
var additionalAction = field.Dictionary["AA"].As<PdfTypeDictionary>();
if (additionalAction.ContainsKey("F") && additionalAction["F"].Is<PdfTypeDictionary>())
{
var beforeDisplayAction = additionalAction["F"].As<PdfTypeDictionary>();
var js = PdfAction.FromHandle(doc, beforeDisplayAction.Handle) as PdfJavaScriptAction;
if ((js.JavaScript ?? "").Contains("AFDate_Format"))
return true;
}
if (additionalAction.ContainsKey("K") && additionalAction["K"].Is<PdfTypeDictionary>())
{
var onTypeAction = additionalAction["K"].As<PdfTypeDictionary>();
var js = PdfAction.FromHandle(doc, onTypeAction.Handle) as PdfJavaScriptAction;
if ((js.JavaScript ?? "").Contains("AFDate_Keystroke"))
return true;
}
return false;
}
}
|
|
Hi,
Hope someone here could help with our issue.
We have a pdf document with a text field configured as date in custom format dd/mm/yyyy. When opened in Acrobat reader, it shows a drop down arrow which can pop up a small calendar window to choose a date from (see the image below).

When we open the same pdf in Patagames PDF viewer (4.66.2704), the arrow is missing, and date can only be entered manually.

Is there a way to achieve the same behaviour as in Acrobat reader ?
Thanks in advance.
|
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