|
@@ -40,6 +40,7 @@ import com.compdfkit.ui.attribute.CPDFStrikeoutAttr;
|
|
import com.compdfkit.ui.attribute.CPDFTextAttr;
|
|
import com.compdfkit.ui.attribute.CPDFTextAttr;
|
|
import com.compdfkit.ui.attribute.CPDFUnderlineAttr;
|
|
import com.compdfkit.ui.attribute.CPDFUnderlineAttr;
|
|
import com.compdfkit.ui.attribute.IAttributeCallback;
|
|
import com.compdfkit.ui.attribute.IAttributeCallback;
|
|
|
|
+import com.compdfkit.ui.attribute.IAttributeUpdateCallback;
|
|
import com.compdfkit.ui.attribute.form.CPDFCheckboxAttr;
|
|
import com.compdfkit.ui.attribute.form.CPDFCheckboxAttr;
|
|
import com.compdfkit.ui.attribute.form.CPDFComboboxAttr;
|
|
import com.compdfkit.ui.attribute.form.CPDFComboboxAttr;
|
|
import com.compdfkit.ui.attribute.form.CPDFListboxAttr;
|
|
import com.compdfkit.ui.attribute.form.CPDFListboxAttr;
|
|
@@ -49,6 +50,8 @@ import com.compdfkit.ui.attribute.form.CPDFSignatureWidgetAttr;
|
|
import com.compdfkit.ui.attribute.form.CPDFTextfieldAttr;
|
|
import com.compdfkit.ui.attribute.form.CPDFTextfieldAttr;
|
|
import com.compdfkit.ui.reader.CPDFReaderView;
|
|
import com.compdfkit.ui.reader.CPDFReaderView;
|
|
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Date;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.LinkedHashSet;
|
|
|
|
|
|
public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements CStyleProvider {
|
|
public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements CStyleProvider {
|
|
@@ -207,6 +210,7 @@ public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements
|
|
textFieldAttr.setBorderWidth(params.getBorderWidth());
|
|
textFieldAttr.setBorderWidth(params.getBorderWidth());
|
|
textFieldAttr.setBorderColor(params.getLineColor());
|
|
textFieldAttr.setBorderColor(params.getLineColor());
|
|
textFieldAttr.setFillColor(params.getFillColor());
|
|
textFieldAttr.setFillColor(params.getFillColor());
|
|
|
|
+ textFieldAttr.setiAttributeUpdateCallback(() -> getDefaultFiledName("Text Field_"));
|
|
String textFieldFontName = CPDFTextAttribute.FontNameHelper.obtainFontName(params.getFontType(), params.isFontBold(), params.isFontItalic());
|
|
String textFieldFontName = CPDFTextAttribute.FontNameHelper.obtainFontName(params.getFontType(), params.isFontBold(), params.isFontItalic());
|
|
textFieldAttr.setTextAttribute(new CPDFTextAttribute(textFieldFontName, params.getFontSize(), params.getTextColor()));
|
|
textFieldAttr.setTextAttribute(new CPDFTextAttribute(textFieldFontName, params.getFontSize(), params.getTextColor()));
|
|
textFieldAttr.setMultiline(params.isFormMultiLine());
|
|
textFieldAttr.setMultiline(params.isFormMultiLine());
|
|
@@ -233,6 +237,7 @@ public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements
|
|
checkboxAttr.setBorderColor(params.getLineColor());
|
|
checkboxAttr.setBorderColor(params.getLineColor());
|
|
checkboxAttr.setFillColor(params.getFillColor());
|
|
checkboxAttr.setFillColor(params.getFillColor());
|
|
checkboxAttr.setChecked(params.isChecked());
|
|
checkboxAttr.setChecked(params.isChecked());
|
|
|
|
+ checkboxAttr.setiAttributeUpdateCallback(() -> getDefaultFiledName("Check Button_"));
|
|
break;
|
|
break;
|
|
case FORM_RADIO_BUTTON:
|
|
case FORM_RADIO_BUTTON:
|
|
CPDFRadiobuttonAttr radiobuttonAttr = attribute.getRadiobuttonAttr();
|
|
CPDFRadiobuttonAttr radiobuttonAttr = attribute.getRadiobuttonAttr();
|
|
@@ -242,6 +247,7 @@ public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements
|
|
radiobuttonAttr.setBorderColor(params.getLineColor());
|
|
radiobuttonAttr.setBorderColor(params.getLineColor());
|
|
radiobuttonAttr.setFillColor(params.getFillColor());
|
|
radiobuttonAttr.setFillColor(params.getFillColor());
|
|
radiobuttonAttr.setChecked(params.isChecked());
|
|
radiobuttonAttr.setChecked(params.isChecked());
|
|
|
|
+ radiobuttonAttr.setiAttributeUpdateCallback(() -> getDefaultFiledName("Radio Button_"));
|
|
break;
|
|
break;
|
|
case FORM_LIST_BOX:
|
|
case FORM_LIST_BOX:
|
|
CPDFListboxAttr listBoxAttr = attribute.getListboxAttr();
|
|
CPDFListboxAttr listBoxAttr = attribute.getListboxAttr();
|
|
@@ -250,6 +256,7 @@ public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements
|
|
listBoxAttr.setFillColor(params.getFillColor());
|
|
listBoxAttr.setFillColor(params.getFillColor());
|
|
listBoxAttr.setBorderWidth(params.getBorderWidth());
|
|
listBoxAttr.setBorderWidth(params.getBorderWidth());
|
|
listBoxAttr.setBorderColor(params.getLineColor());
|
|
listBoxAttr.setBorderColor(params.getLineColor());
|
|
|
|
+ listBoxAttr.setiAttributeUpdateCallback(() -> getDefaultFiledName("List Choice_"));
|
|
break;
|
|
break;
|
|
case FORM_COMBO_BOX:
|
|
case FORM_COMBO_BOX:
|
|
CPDFComboboxAttr comboBoxAttr = attribute.getComboboxAttr();
|
|
CPDFComboboxAttr comboBoxAttr = attribute.getComboboxAttr();
|
|
@@ -258,6 +265,7 @@ public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements
|
|
comboBoxAttr.setFontColor(params.getTextColor());
|
|
comboBoxAttr.setFontColor(params.getTextColor());
|
|
comboBoxAttr.setBorderWidth(params.getBorderWidth());
|
|
comboBoxAttr.setBorderWidth(params.getBorderWidth());
|
|
comboBoxAttr.setBorderColor(params.getLineColor());
|
|
comboBoxAttr.setBorderColor(params.getLineColor());
|
|
|
|
+ comboBoxAttr.setiAttributeUpdateCallback(() -> getDefaultFiledName("Combox Choice_"));
|
|
break;
|
|
break;
|
|
case FORM_PUSH_BUTTON:
|
|
case FORM_PUSH_BUTTON:
|
|
CPDFPushButtonAttr pushButtonAttr = attribute.getPushButtonAttr();
|
|
CPDFPushButtonAttr pushButtonAttr = attribute.getPushButtonAttr();
|
|
@@ -267,6 +275,7 @@ public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements
|
|
pushButtonAttr.setFontColor(params.getTextColor());
|
|
pushButtonAttr.setFontColor(params.getTextColor());
|
|
pushButtonAttr.setFontSize(params.getFontSize());
|
|
pushButtonAttr.setFontSize(params.getFontSize());
|
|
pushButtonAttr.setButtonTitle(params.getFormDefaultValue());
|
|
pushButtonAttr.setButtonTitle(params.getFormDefaultValue());
|
|
|
|
+ pushButtonAttr.setiAttributeUpdateCallback(() -> getDefaultFiledName("Push Button_"));
|
|
break;
|
|
break;
|
|
case FORM_SIGNATURE_FIELDS:
|
|
case FORM_SIGNATURE_FIELDS:
|
|
CPDFSignatureWidgetAttr signatureWidgetAttr = attribute.getSignatureWidgetAttr();
|
|
CPDFSignatureWidgetAttr signatureWidgetAttr = attribute.getSignatureWidgetAttr();
|
|
@@ -274,6 +283,7 @@ public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements
|
|
signatureWidgetAttr.setBorderColor(params.getLineColor());
|
|
signatureWidgetAttr.setBorderColor(params.getLineColor());
|
|
signatureWidgetAttr.setBorderStyle(CPDFWidget.BorderStyle.BS_Solid);
|
|
signatureWidgetAttr.setBorderStyle(CPDFWidget.BorderStyle.BS_Solid);
|
|
signatureWidgetAttr.setFillColor(params.getFillColor());
|
|
signatureWidgetAttr.setFillColor(params.getFillColor());
|
|
|
|
+ signatureWidgetAttr.setiAttributeUpdateCallback(() -> getDefaultFiledName("Signature__"));
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
@@ -457,4 +467,11 @@ public class CPDFGlobalAnnotStyle extends CBasicOnStyleChangeListener implements
|
|
}
|
|
}
|
|
return style;
|
|
return style;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ protected String getDefaultFiledName(String widgetType) {
|
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
+ Date date = new Date(System.currentTimeMillis());
|
|
|
|
+ String dateStr = simpleDateFormat.format(date);
|
|
|
|
+ return String.format("%s%s", widgetType, dateStr);
|
|
|
|
+ }
|
|
}
|
|
}
|