Conditional format in adobe Acrobat - adobe

I am new at Acrobat, Need some help in conditional Formatting,
I have 2 text fields. If I enter a number >0 but <10 the bg colour of the second box should turns yellow. If I enter a number <20 but >10 it should turns orange.
Please help to understand Acrobat DOM elements.

Let's assume the field where you enter the numbers is called "myField". Then, we would add the following to the Calculate event of the field where the background should change:
var mf = this.getField("myField") ;
if (mf.value > 0 && mf.value < 10) {
event.target.fillColor = color.yellow ;
} else {
if (mf.value >= 10 && mf.value < 20) {
event.target.fillColor = ["RGB", 1, 0, 0.2] ;
} else {
event.target.fillColor = ["T"] ;
}
}
and that should do it.
Note that there is no pre-defined orange color, and you'd have to get the correct color value array (I think the one I used is kind of an orange).
If you add the code to the calculate event of another field, you'd have to replace event.target with this.getField("myOtherField") (or whatever the field name is).

Related

add an image into datagridview based on a condition

i want to show an image in datagridview based on a condition (if the endday of subscribtion is < today then show a red cross image else show a checkmark image) , i have an sqlite database and i created a datagridviewimagecolumn called expired to shopw this images , but i'm not getting anything , here is the code
``for (int row = 0; row <= membersdashboarddatagrid.Rows.Count - 1; row++)
{
DateTime endday = Convert.ToDateTime(membersdashboarddatagrid.CurrentRow.Cells[3].Value);
if (endday < DateTime.Today)
{
((DataGridViewImageCell)membersdashboarddatagrid.Rows[row].Cells[0]).Value = Properties.Resources.delete;
}
else
{
((DataGridViewImageCell)membersdashboarddatagrid.Rows[row].Cells[0]).Value = Properties.Resources._checked;
}
}`
Hope you could help me guys !
The problem you are having is that in each iteration of the for loop, the code is checking the “SAME” Cells EndDay value. Specifically, the line of code…
DateTime endday = Convert.ToDateTime(membersdashboarddatagrid.CurrentRow.Cells[3].Value);
The portion of this that is using the same cell is…
membersdashboarddatagrid.CurrentRow.Cells[3].Value
The code above uses the SAME CurrentRow.Cell[3].Value with each iteration. Therefore, all the Expire images will be the same depending on what the CurrentRows EndDay value is. I am confident you want something like…
membersdashboarddatagrid.Rows[row].Cells[3].Value);

How can I make a button within Google Sheets that toggles the values 1 and 0 in a destination cell?

I am trying to learn to do basic buttons within a spreadsheet to help with a project at school. I am a simple teacher that is trying to find resources to help. I have learned how to create a button that adds one or subtracts one with the value which will allow me to do what I need to do, but ideally I am looking for script code to make a button that would toggle between the values of 1 and 0 upon pressing the button.
Thanks for any help.
function plus1() {
SpreadsheetApp.getActiveSheet().getRange('A1').setValue(
SpreadsheetApp.getActiveSheet().getRange('A1').getValue() + 1
);
}
I believe your goal as follows.
You want to switch the number of 1 and 0 at the cell "A1" on the active sheet by clicking a button.
In this case, at first, it is required to retrieve the value from the cell "A1" on the active sheet. And, the value is put by checking the retrieved value. So how about the following sample script?
Sample script:
function sample() {
var range = SpreadsheetApp.getActiveSheet().getRange('A1');
var value = range.getValue();
if (value == 1) {
range.setValue(0);
} else if (value == 0) {
range.setValue(1);
}
}
In this case, when the cell "A1" is not 1 or 0, the value in the cell is not modified.
References:
getValue()
setValue(value)
if...else
function toggleActiveCell() {
const sh=SpreadsheetApp.getActiveSheet();
const rg=sh.getActiveCell();
rg.setValue(rg.getValue()?0:1);
}
function toggleUniqueCell() {
const sh=SpreadsheetApp.getActiveSheet();
const rg=sh.getRange(row,col);
rg.setValue(rg.getValue()?0:1);
}

Itextsharp: Using pushbuttons to fill images

As suggested by Mr Bruno Lowagie Here, I've been using the push button field to fill images in custom templates, as such:
AcroFields form = stamper.AcroFields;
PushbuttonField logo = form.GetNewPushbuttonFromField("1");
if(logo != null)
{
logo.Layout = PushbuttonField.LAYOUT_ICON_ONLY;
logo.ProportionalIcon = true;
logo.Image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Image.jpg"));
form.ReplacePushbuttonField("1", logo.Field);
}
The problem is if I have multiple pushbuttons with field names 1, and I want to replace all of them with that same image, this only replaces the first one.
These are the push button fields before replacing their icon:
This is after I try to replace them, and only the first gets replaced:
I also saw that we can set form.GetNewPushbuttonFromField(string field, int order), where order should be the index of the field with that field name?
So for testing I tried:
PushbuttonField logo = form.GetNewPushbuttonFromField("1", 0);
if(logo != null)
{
logo.Layout = PushbuttonField.LAYOUT_ICON_ONLY;
logo.ProportionalIcon = true;
logo.Image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Image.jpg"));
form.ReplacePushbuttonField("1", logo.Field);
}
PushbuttonField logo2 = form.GetNewPushbuttonFromField("1", 1);
if (CDlogo2 != null)
{
logo2.Layout = PushbuttonField.LAYOUT_ICON_ONLY;
logo2.ProportionalIcon = true;
logo2.Image = iTextSharp.text.Image.GetInstance(Server.MapPath("~/Images/Image.jpg"));
form.ReplacePushbuttonField("1", logo2.Field);
}
However, for some reason the first pushbutton icon does not change and gets placed in the location of the second pushbutton that gets its icon changed, as such:
I need to be able to list through all of the pushbutton fields with that name field and replace all of them with that same image, how would I do that?
Thank you,
EDIT
As requested Here is a link to view the pdfs
EDIT 2
If anyone cares this is how I'm using mkl's answer to loop and fill all images: (I know it's done terribly, but it works, yes, I'm keeping it for the time being)
int n= 0;
PushbuttonField logo = form.GetNewPushbuttonFromField("1", n);
while (logo != null)
{
n++;
logo = form.GetNewPushbuttonFromField("1", n);
}
PushbuttonField logo2;
for (int z = 0; z < n; z++)
{
logo2 = form.GetNewPushbuttonFromField("1", z);
logo2.Layout = PushbuttonField.LAYOUT_ICON_ONLY;
logo2.ProportionalIcon = true;
logo2.Image = iTextSharp.text.Image.GetInstance(Server.MapPath(imagePath));
form.ReplacePushbuttonField("1", logo2.Field, z);
}
Because I couldn't find a method to get the number of pushbuttons with the same name.
You
saw that we can set form.GetNewPushbuttonFromField(string field, int order), where order should be the index of the field with that field name
which is the correct direction to look. But you still used the form.ReplacePushbuttonField overload without an order parameter:
PushbuttonField logo2 = form.GetNewPushbuttonFromField("1", 1);
...
form.ReplacePushbuttonField("1", logo2.Field);
This creates a PushbuttonField from the second form field named "1" (including the position of the second button) and uses its information to replace the first field named "1". Thus, it
gets placed in the location of the second pushbutton
So, to fix this you also have to use the form.ReplacePushbuttonField overload with an order parameter, if you use the form.GetNewPushbuttonFromField overload with an order parameter, and the values should match:
PushbuttonField logo2 = form.GetNewPushbuttonFromField("1", 1);
...
form.ReplacePushbuttonField("1", logo2.Field, 1);

Wijmo dual formatting of one column

In my Wijmo FlexGrid, in one Dropdown Column having dropdown values (decimal, Percentage). I need to show percentage symbol if I choose percentage as dropdown values, and decimal (n2) if Dropdown value is selected decimal
You need to set the format of the column based on the value using itemFormatter or formatItem event. Here is a fiddle demonstrating similar requirement: http://jsfiddle.net/5Ltfpzst/
grid.itemFormatter = function (panel, r, c, cell) {
if (panel.cellType === wijmo.grid.CellType.Cell && c == 3) {
var cellData = panel.getCellData(r, 0);
if (cellData < 5) {
panel.columns[c].format = 'n1';
} else {
panel.columns[c].format = 'p0';
}
}
}

Multiple ASP.NET DropDownLists are being set to the same value

I have 6 dropdown lists (with identical options), and I am manually setting them in my codebehind. All six should have different values. When I log the values I am setting them to, I get the correct assumed values to be set to. However, when the page renders, all six of them are set to the same freaking value.
I have tried setting the values with all of the following:
// set index, find by text
dd1.SelectedIndex = dd1.Items.IndexOf(dd1.Items.FindByText(val1));
// set with selected value
dd2.SelectedValue = val2;
// set index, find by value
dd3.SelectedIndex = dd3.Items.IndexOf(dd3.Items.FindByValue(val3));
// set list item, selected = true
((ListItem)dd4.Items.FindByValue(val4)).Selected = true;
The dropdown lists' set of options are generated prior to me trying to set them:
foreach (Station st in stations) {
ListItem li = new ListItem() { Text = st.fromto, Value = st.fromto};
dd1.Items.Add(li);
dd2.Items.Add(li);
dd3.Items.Add(li);
dd4.Items.Add(li);
dd5.Items.Add(li);
dd6.Items.Add(li);
}
I then look in the database to see if any values exist for a specific reference id in my app. If so, it indicates that I need to set one or more (up to 6) dropdowns:
var existingStations = db.LOGOPS_STATIONs.Where(x => x.XREF_LOGOP_MAIN_ID == logopRefId);
if (existingStations.Count() > 0) {
int i = 1;
foreach (LOGOPS_STATION s in existingStations) {
if (i < 7) {
string text= s.FROM_STATION;
if (i == 1) dd1.SelectedIndex = dd1.Items.IndexOf(dd1.Items.FindByText(text));
// for the heck of it, set the next one manually...
else if (i == 2) dd2.SelectedIndex = 2;
// try and set one with forcing select
else if (i == 3) ((ListItem)dd3.Items.FindByText(text)).Selected = true;
// good ol normal
else if (i == 4) dd4.SelectedValue = text;
... and so on ...
}
}
}
So, the dropdowns are all populated (when I log in the codebehind they're fully populated). And when I log the actual values when they're being set, they're set to the value as expected. However, when the page loads, they're all set to the same thing
At any rate, not sure what else to do. I have turned on and off different event validation hookups. I have disabled all JS to see if that was manipulating values, and it's not. I have tried explicitly setting like this
dd1.SelectedIndex = 2;
dd2.SelectedIndex = 8;
Oddly enough, that doesn't work either. For real, when does setting SelectedIndex to a unique control with a unique id not set the item?
I had to create a separate list item for each dropdown instead of them all sharing the same li in the foreach loop. And then a step further, had to set Selected = false in the constructor of the ListItem
I assumed that you could 'reuse' code for each instance of the dropdown population, but each dropdown needed it's own unique ListItem
Maybe there's a better way, but this solution seems to have solved the problem

Resources