|
@@ -10,6 +10,7 @@ import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.math.NumberUtils; |
|
|
import org.apache.commons.lang3.math.NumberUtils; |
|
|
import org.apache.pdfbox.Loader; |
|
|
import org.apache.pdfbox.Loader; |
|
|
import org.apache.pdfbox.pdmodel.PDDocument; |
|
|
import org.apache.pdfbox.pdmodel.PDDocument; |
|
@@ -36,6 +37,7 @@ import com.itextpdf.forms.PdfAcroForm; |
|
|
import com.itextpdf.forms.fields.PdfFormField; |
|
|
import com.itextpdf.forms.fields.PdfFormField; |
|
|
import com.itextpdf.io.source.ByteArrayOutputStream; |
|
|
import com.itextpdf.io.source.ByteArrayOutputStream; |
|
|
import com.itextpdf.kernel.pdf.PdfDocument; |
|
|
import com.itextpdf.kernel.pdf.PdfDocument; |
|
|
|
|
|
import com.itextpdf.kernel.pdf.PdfName; |
|
|
import com.itextpdf.kernel.pdf.PdfReader; |
|
|
import com.itextpdf.kernel.pdf.PdfReader; |
|
|
import com.itextpdf.kernel.pdf.PdfWriter; |
|
|
import com.itextpdf.kernel.pdf.PdfWriter; |
|
|
|
|
|
|
|
@@ -255,7 +257,7 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
|
|
|
|
|
|
//logger.info("Field '" + sourceFieldName + "' as '" + sourceFieldValue + "' from source set in target PDF."); |
|
|
//logger.info("Field '" + sourceFieldName + "' as '" + sourceFieldValue + "' from source set in target PDF."); |
|
|
|
|
|
|
|
|
if (targetField != null) { |
|
|
|
|
|
|
|
|
if (targetField != null && sourceField.getFormType().equals(PdfName.Tx)) { |
|
|
targetField.setValue(sourceFieldValue); // Set the value in the target field |
|
|
targetField.setValue(sourceFieldValue); // Set the value in the target field |
|
|
} else { |
|
|
} else { |
|
|
//System.out.println("Field '" + sourceFieldName + "' from source not found in target PDF."); |
|
|
//System.out.println("Field '" + sourceFieldName + "' from source not found in target PDF."); |
|
@@ -291,216 +293,219 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
// It's highly recommended to check if the field exists before setting its value |
|
|
// It's highly recommended to check if the field exists before setting its value |
|
|
// This prevents NullPointerExceptions if a field is missing in a template |
|
|
// This prevents NullPointerExceptions if a field is missing in a template |
|
|
//temp using the remarks as form code |
|
|
//temp using the remarks as form code |
|
|
|
|
|
|
|
|
if("IDA".equals(formCode)){ // This is IDA |
|
|
if("IDA".equals(formCode)){ // This is IDA |
|
|
logger.info("Processing IDA form (ID: 1)"); |
|
|
logger.info("Processing IDA form (ID: 1)"); |
|
|
setValueIfPresent(form, "fill_6", commonField.getName(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_7", commonField.getNameChi(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_11", commonField.getIdCard(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_6", commonField.getName()); |
|
|
|
|
|
setValueIfPresent(form, "fill_7", commonField.getNameChi()); |
|
|
|
|
|
setValueIfPresent(form, "fill_11", commonField.getIdCard()); |
|
|
|
|
|
|
|
|
/* Page1 Start */ |
|
|
/* Page1 Start */ |
|
|
setValueIfPresent(form, "gender_m", commonField.getGenderMale(), null); |
|
|
|
|
|
setValueIfPresent(form, "gender_f", commonField.getGenderFemale(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "gender_m", commonField.getGenderMale()); |
|
|
|
|
|
setValueIfPresent(form, "gender_f", commonField.getGenderFemale()); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "date_dd", commonField.getDdDateOfBirth(), null); |
|
|
|
|
|
setValueIfPresent(form, "date_mm", commonField.getMmDateOfBirth(), null); |
|
|
|
|
|
setValueIfPresent(form, "date_yyyy", commonField.getYyyyDateOfBirth(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "date_dd", commonField.getDdDateOfBirth()); |
|
|
|
|
|
setValueIfPresent(form, "date_mm", commonField.getMmDateOfBirth()); |
|
|
|
|
|
setValueIfPresent(form, "date_yyyy", commonField.getYyyyDateOfBirth()); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_17", commonField.getContactNo(), null); |
|
|
|
|
|
setValueIfPresent(form, "edu_pri", commonField.getEduPri(), null); |
|
|
|
|
|
setValueIfPresent(form, "edu_sec", commonField.getEduSec(), null); |
|
|
|
|
|
setValueIfPresent(form, "edu_post_sec", commonField.getEduPostSec(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_17", commonField.getContactNo()); |
|
|
|
|
|
setValueIfPresent(form, "edu_pri", commonField.getEduPri()); |
|
|
|
|
|
setValueIfPresent(form, "edu_sec", commonField.getEduSec()); |
|
|
|
|
|
setValueIfPresent(form, "edu_post_sec", commonField.getEduPostSec()); |
|
|
/* Page1 End */ |
|
|
/* Page1 End */ |
|
|
/* Page2 Start */ |
|
|
/* Page2 Start */ |
|
|
setValueIfPresent(form, "own_income", commonField.getOwn_income(), null); |
|
|
|
|
|
setValueIfPresent(form, "savings", commonField.getSavings(), null); |
|
|
|
|
|
setValueIfPresent(form, "premium_financing", commonField.getPremium_financing(), null); |
|
|
|
|
|
setValueIfPresent(form, "others_funds", commonField.getOthers_funds(), null); |
|
|
|
|
|
setValueIfPresent(form, "others_funds_desc", commonField.getOthers_funds_desc(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "own_income", commonField.getOwn_income()); |
|
|
|
|
|
setValueIfPresent(form, "savings", commonField.getSavings()); |
|
|
|
|
|
setValueIfPresent(form, "premium_financing", commonField.getPremium_financing()); |
|
|
|
|
|
setValueIfPresent(form, "others_funds", commonField.getOthers_funds()); |
|
|
|
|
|
setValueIfPresent(form, "others_funds_desc", commonField.getOthers_funds_desc()); |
|
|
/* Page2 End */ |
|
|
/* Page2 End */ |
|
|
/* Page3 Start */ |
|
|
/* Page3 Start */ |
|
|
setValueIfPresent(form, "fill_26_4", commonField.getFna_c1a_amount(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_26_4", commonField.getFna_c1a_amount()); |
|
|
/* Page3 End */ |
|
|
/* Page3 End */ |
|
|
/* Page4 Start */ |
|
|
/* Page4 Start */ |
|
|
setValueIfPresent(form, "total_asset", commonField.getFna_c2a_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_56", commonField.getFna_c2b_amount(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "total_asset", commonField.getFna_c2a_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fill_56", commonField.getFna_c2b_amount()); |
|
|
|
|
|
|
|
|
} else if("FNA".equals(formCode)){ // This is FNA |
|
|
} else if("FNA".equals(formCode)){ // This is FNA |
|
|
//logger.info("Processing FNA form (ID: 2)"); |
|
|
//logger.info("Processing FNA form (ID: 2)"); |
|
|
/* Page1 Start */ |
|
|
/* Page1 Start */ |
|
|
setValueIfPresent(form, "fna_a_name", commonField.getName(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_birth", commonField.getDateOfBirth(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_occupation", commonField.getOccupation(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_primary", commonField.getEduPri(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_secondary", commonField.getEduSec(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_tertiary", commonField.getEduTer(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_a_tertiary", commonField.getEduTer(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_marital", commonField.getMaritalStatus(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_contact", commonField.getContactNo(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_dependents", commonField.getNoOfDependents(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c1a_amount", commonField.getFna_c1a_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1b_amount", commonField.getFna_c1b_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1c_1_amount", commonField.getFna_c1c_1_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1c_2_amount", commonField.getFna_c1c_2_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1c_3_amount", commonField.getFna_c1c_3_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1d_amount", commonField.getFna_c1d_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2a_amount", commonField.getFna_c2a_amount(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c2b_amount", commonField.getFna_c2b_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2c_amount", commonField.getFna_c2c_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2d_amount", commonField.getFna_c2d_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2e_amount", commonField.getFna_c2e_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_a", commonField.getFna_b1_a(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_a_amount", commonField.getFna_b1_a_amount(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b1_b", commonField.getFna_b1_b(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1a_4_amount", commonField.getFna_b1a_4_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_c", commonField.getFna_b1_c(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_d", commonField.getFna_b1_d(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b1_d_year", commonField.getFna_b1_d_year(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_d_amount", commonField.getFna_b1_d_amount(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_a_name", commonField.getName()); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_birth", commonField.getDateOfBirth()); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_occupation", commonField.getOccupation()); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_primary", commonField.getEduPri()); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_secondary", commonField.getEduSec()); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_tertiary", commonField.getEduTer()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_a_tertiary", commonField.getEduTer()); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_marital", commonField.getMaritalStatus()); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_contact", commonField.getContactNo()); |
|
|
|
|
|
setValueIfPresent(form, "fna_a_dependents", commonField.getNoOfDependents()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c1a_amount", commonField.getFna_c1a_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1b_amount", commonField.getFna_c1b_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1c_1_amount", commonField.getFna_c1c_1_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1c_2_amount", commonField.getFna_c1c_2_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1c_3_amount", commonField.getFna_c1c_3_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1d_amount", commonField.getFna_c1d_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2a_amount", commonField.getFna_c2a_amount()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c2b_amount", commonField.getFna_c2b_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2c_amount", commonField.getFna_c2c_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2d_amount", commonField.getFna_c2d_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2e_amount", commonField.getFna_c2e_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_a", commonField.getFna_b1_a()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_a_amount", commonField.getFna_b1_a_amount()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b1_b", commonField.getFna_b1_b()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1a_4_amount", commonField.getFna_b1a_4_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_c", commonField.getFna_b1_c()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_d", commonField.getFna_b1_d()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b1_d_year", commonField.getFna_b1_d_year()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_d_amount", commonField.getFna_b1_d_amount()); |
|
|
/* Page1 End */ |
|
|
/* Page1 End */ |
|
|
/* Page2 Start */ |
|
|
/* Page2 Start */ |
|
|
setValueIfPresent(form, "fna_b1_e", commonField.getFna_b1_e(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_f", commonField.getFna_b1_f(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_f_other", commonField.getFna_b1_f_other(), null); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_f_desc", commonField.getFna_b1_f_desc(), "on"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b2_a", commonField.getFna_b2_a(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_b", commonField.getFna_b2_b(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_d", commonField.getFna_b2_d(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_e", commonField.getFna_b2_e(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_f", commonField.getFna_b2_f(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_g", commonField.getFna_b2_g(), "on"); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b1_e", commonField.getFna_b1_e()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_f", commonField.getFna_b1_f()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_f_other", commonField.getFna_b1_f_other()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b1_f_desc", commonField.getFna_b1_f_desc()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_b2_a", commonField.getFna_b2_a()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_b", commonField.getFna_b2_b()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_d", commonField.getFna_b2_d()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_e", commonField.getFna_b2_e()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_f", commonField.getFna_b2_f()); |
|
|
|
|
|
setValueIfPresent(form, "fna_b2_g", commonField.getFna_b2_g()); |
|
|
/* Page2 End */ |
|
|
/* Page2 End */ |
|
|
/* Page3 Start */ |
|
|
/* Page3 Start */ |
|
|
setValueIfPresent(form, "fna_c1e_10", commonField.getFna_c1e_10(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_10_20", commonField.getFna_c1e_10_20(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_21_30", commonField.getFna_c1e_21_30(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_31_40", commonField.getFna_c1e_31_40(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_41_50", commonField.getFna_c1e_41_50(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_50", commonField.getFna_c1e_50(), "on"); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_10", commonField.getFna_c1e_10()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_10_20", commonField.getFna_c1e_10_20()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_21_30", commonField.getFna_c1e_21_30()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_31_40", commonField.getFna_c1e_31_40()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_41_50", commonField.getFna_c1e_41_50()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c1e_50", commonField.getFna_c1e_50()); |
|
|
/* Page3 End */ |
|
|
/* Page3 End */ |
|
|
/* Page4 Start */ |
|
|
/* Page4 Start */ |
|
|
setValueIfPresent(form, "fna_c2f_10", commonField.getFna_c2f_10(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_10_20", commonField.getFna_c2f_10_20(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_21_30", commonField.getFna_c2f_21_30(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_31_40", commonField.getFna_c2f_31_40(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_41_50", commonField.getFna_c2f_41_50(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_50", commonField.getFna_c2f_50(), "on"); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_10", commonField.getFna_c2f_10()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_10_20", commonField.getFna_c2f_10_20()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_21_30", commonField.getFna_c2f_21_30()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_31_40", commonField.getFna_c2f_31_40()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_41_50", commonField.getFna_c2f_41_50()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c2f_50", commonField.getFna_c2f_50()); |
|
|
/* Page4 End */ |
|
|
/* Page4 End */ |
|
|
/* Page5 End */ |
|
|
/* Page5 End */ |
|
|
setValueIfPresent(form, "fna_c3a_2_5", commonField.getFna_c3a_2_5(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_6_10", commonField.getFna_c3a_6_10(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_11_15", commonField.getFna_c3a_11_15(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_16_20", commonField.getFna_c3a_16_20(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_20", commonField.getFna_c3a_20(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_life", commonField.getFna_c3a_life(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_single_pay", commonField.getFna_c3a_single_pay(), "on"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_a_retire", commonField.getFna_a_retire(), "on"); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_salary", commonField.getFna_c3b_salary(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_income", commonField.getFna_c3b_income(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_saving", commonField.getFna_c3b_saving(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_investments", commonField.getFna_c3b_investments(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_policy", commonField.getFna_c3b_policy(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_others", commonField.getFna_c3b_others(), "on"); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_desc", commonField.getFna_c3b_desc(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_2_5", commonField.getFna_c3a_2_5()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_6_10", commonField.getFna_c3a_6_10()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_11_15", commonField.getFna_c3a_11_15()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_16_20", commonField.getFna_c3a_16_20()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_20", commonField.getFna_c3a_20()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_life", commonField.getFna_c3a_life()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3a_single_pay", commonField.getFna_c3a_single_pay()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_a_retire", commonField.getFna_a_retire()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_salary", commonField.getFna_c3b_salary()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_income", commonField.getFna_c3b_income()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_saving", commonField.getFna_c3b_saving()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_investments", commonField.getFna_c3b_investments()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_policy", commonField.getFna_c3b_policy()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_others", commonField.getFna_c3b_others()); |
|
|
|
|
|
setValueIfPresent(form, "fna_c3b_desc", commonField.getFna_c3b_desc()); |
|
|
/* Page5 End */ |
|
|
/* Page5 End */ |
|
|
|
|
|
|
|
|
} else if("HSBCFIN".equals(formCode)){ // This is HSBCFIN |
|
|
} else if("HSBCFIN".equals(formCode)){ // This is HSBCFIN |
|
|
//logger.info("Processing HSBCFIN form (ID: 3)"); |
|
|
//logger.info("Processing HSBCFIN form (ID: 3)"); |
|
|
/* Page1 Start */ |
|
|
/* Page1 Start */ |
|
|
setValueIfPresent(form, "fill_3", commonField.getName(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_4", commonField.getNameChi(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_5", commonField.getGender(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_6", commonField.getDateOfBirth(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_9", commonField.getOccupation(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_7", commonField.getMaritalStatus(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_8", commonField.getNoOfDependents(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_10", commonField.getContactNo(), null);; |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_3", commonField.getName()); |
|
|
|
|
|
setValueIfPresent(form, "fill_4", commonField.getNameChi()); |
|
|
|
|
|
setValueIfPresent(form, "fill_5", commonField.getGender()); |
|
|
|
|
|
setValueIfPresent(form, "fill_6", commonField.getDateOfBirth()); |
|
|
|
|
|
setValueIfPresent(form, "fill_9", commonField.getOccupation()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_7", commonField.getMaritalStatus()); |
|
|
|
|
|
setValueIfPresent(form, "fill_8", commonField.getNoOfDependents()); |
|
|
|
|
|
setValueIfPresent(form, "fill_10", commonField.getContactNo());; |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "toggle_1", commonField.getEduPri(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_2", commonField.getEduSec(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_3", commonField.getEduPostSec(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_3", commonField.getEduTer(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "toggle_1", commonField.getEduPri()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_2", commonField.getEduSec()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_3", commonField.getEduPostSec()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_3", commonField.getEduTer()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_11", NumberUtils.toScaledBigDecimal(NumberUtils.toScaledBigDecimal(commonField.getFna_c1a_amount(), 0, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(12))).toString() , null); //annual |
|
|
|
|
|
setValueIfPresent(form, "fill_12", NumberUtils.toScaledBigDecimal(NumberUtils.toScaledBigDecimal(commonField.getFna_c1b_amount(), 0, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(12))).toString() , null); //annual |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_12a", commonField.getFna_c1c_3_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_13", commonField.getFna_c1c_3_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_14", commonField.getFna_c1c_2_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_16", commonField.getFna_c1d_amount(), null); |
|
|
|
|
|
|
|
|
if(StringUtils.isNotEmpty(commonField.getFna_c1a_amount())){ |
|
|
|
|
|
setValueIfPresent(form, "fill_11", NumberUtils.toScaledBigDecimal(NumberUtils.toScaledBigDecimal(commonField.getFna_c1a_amount(), 0, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(12))).toString() ); //annual |
|
|
|
|
|
} |
|
|
|
|
|
if(StringUtils.isNotEmpty(commonField.getFna_c1b_amount())){ |
|
|
|
|
|
setValueIfPresent(form, "fill_12", NumberUtils.toScaledBigDecimal(NumberUtils.toScaledBigDecimal(commonField.getFna_c1b_amount(), 0, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(12))).toString() ); //annual |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_12a", commonField.getFna_c1c_3_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fill_13", commonField.getFna_c1c_3_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fill_14", commonField.getFna_c1c_2_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fill_16", commonField.getFna_c1d_amount()); |
|
|
/* Page1 End */ |
|
|
/* Page1 End */ |
|
|
/* Page2 Start */ |
|
|
/* Page2 Start */ |
|
|
setValueIfPresent(form, "fill_01", commonField.getFna_c2a_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_02", commonField.getFna_c2b_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_03", commonField.getFna_c2c_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_04", commonField.getFna_c2d_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_05", commonField.getFna_c2e_amount(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "Financial Protection", commonField.getFna_b1_a(), null); |
|
|
|
|
|
setValueIfPresent(form, "Preparation", commonField.getFna_b1_b(), null); |
|
|
|
|
|
setValueIfPresent(form, "Providing", commonField.getFna_b1_c(), null);; |
|
|
|
|
|
setValueIfPresent(form, "Saving", commonField.getFna_b1_d(), null); |
|
|
|
|
|
setValueIfPresent(form, "Investment", commonField.getFna_b1_e(), null); |
|
|
|
|
|
setValueIfPresent(form, "Others", commonField.getFna_b1_f(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_8_2", commonField.getFna_b1_f_other(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_8_21", commonField.getFna_b1_f_desc(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "fill_01", commonField.getFna_c2a_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fill_02", commonField.getFna_c2b_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fill_03", commonField.getFna_c2c_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fill_04", commonField.getFna_c2d_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fill_05", commonField.getFna_c2e_amount()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "Financial Protection", commonField.getFna_b1_a()); |
|
|
|
|
|
setValueIfPresent(form, "Preparation", commonField.getFna_b1_b()); |
|
|
|
|
|
setValueIfPresent(form, "Providing", commonField.getFna_b1_c());; |
|
|
|
|
|
setValueIfPresent(form, "Saving", commonField.getFna_b1_d()); |
|
|
|
|
|
setValueIfPresent(form, "Investment", commonField.getFna_b1_e()); |
|
|
|
|
|
setValueIfPresent(form, "Others", commonField.getFna_b1_f()); |
|
|
|
|
|
setValueIfPresent(form, "fill_8_2", commonField.getFna_b1_f_other()); |
|
|
|
|
|
setValueIfPresent(form, "fill_8_21", commonField.getFna_b1_f_desc()); |
|
|
/* Page2 End */ |
|
|
/* Page2 End */ |
|
|
/* Page3 Start */ |
|
|
/* Page3 Start */ |
|
|
setValueIfPresent(form, "toggle_91", commonField.getFna_b1_a(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4", commonField.getFna_b1_a_amount(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4b", commonField.getFna_b1_b(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_93", commonField.getFna_b1_d(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4c", commonField.getFna_b1_d_year(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4d", commonField.getFna_b1_d_year(), null); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4e", commonField.getFna_b1_d_amount(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "toggle_4_2", commonField.getFna_b2_a(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_5", commonField.getFna_b2_b(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_6", commonField.getFna_b2_c(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_7", commonField.getFna_b2_d(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_8", commonField.getFna_b2_e(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_9", commonField.getFna_b2_f(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_10", commonField.getFna_b2_g(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "toggle_91", commonField.getFna_b1_a()); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4", commonField.getFna_b1_a_amount()); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4b", commonField.getFna_b1_b()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_93", commonField.getFna_b1_d()); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4c", commonField.getFna_b1_d_year()); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4d", commonField.getFna_b1_d_year()); |
|
|
|
|
|
setValueIfPresent(form, "fill_1_4e", commonField.getFna_b1_d_amount()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "toggle_4_2", commonField.getFna_b2_a()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_5", commonField.getFna_b2_b()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_6", commonField.getFna_b2_c()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_7", commonField.getFna_b2_d()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_8", commonField.getFna_b2_e()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_9", commonField.getFna_b2_f()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_10", commonField.getFna_b2_g()); |
|
|
/* Page3 End */ |
|
|
/* Page3 End */ |
|
|
/* Page4 Start */ |
|
|
/* Page4 Start */ |
|
|
setValueIfPresent(form, "toggle_1_2", commonField.getFna_c3a_2_5(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_2_2", commonField.getFna_c3a_6_10(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_3_2", commonField.getFna_c3a_11_15(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_4_3", commonField.getFna_c3a_16_20(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_5_2", commonField.getFna_c3a_20(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_6_2", commonField.getFna_c3a_life(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_6_2_sum", commonField.getFna_c3a_2_5(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "toggle_1_2", commonField.getFna_c3a_2_5()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_2_2", commonField.getFna_c3a_6_10()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_3_2", commonField.getFna_c3a_11_15()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_4_3", commonField.getFna_c3a_16_20()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_5_2", commonField.getFna_c3a_20()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_6_2", commonField.getFna_c3a_life()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_6_2_sum", commonField.getFna_c3a_2_5()); |
|
|
/* Page4 End */ |
|
|
/* Page4 End */ |
|
|
/* Page5 Start */ |
|
|
/* Page5 Start */ |
|
|
setValueIfPresent(form, "toggle_1f", commonField.getFna_c3b_income(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_1g", commonField.getFna_c3b_saving(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_1h", commonField.getFna_c3b_policy(), null); |
|
|
|
|
|
setValueIfPresent(form, "toggle_1i56", commonField.getFna_c3b_others(), null); |
|
|
|
|
|
setValueIfPresent(form, "Text3", commonField.getFna_c3b_desc(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "Check Box6", commonField.getFna_c1e_10(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box7", commonField.getFna_c1e_10_20(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box8", commonField.getFna_c1e_21_30(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box9", commonField.getFna_c1e_31_40(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box10", commonField.getFna_c1e_41_50(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box11", commonField.getFna_c1e_50(), null); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "Check Box12", commonField.getFna_c2f_10(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box13", commonField.getFna_c2f_10_20(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box14", commonField.getFna_c2f_21_30(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box15", commonField.getFna_c2f_31_40(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box16", commonField.getFna_c2f_41_50(), null); |
|
|
|
|
|
setValueIfPresent(form, "Check Box17", commonField.getFna_c2f_50(), null); |
|
|
|
|
|
|
|
|
setValueIfPresent(form, "toggle_1f", commonField.getFna_c3b_income()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_1g", commonField.getFna_c3b_saving()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_1h", commonField.getFna_c3b_policy()); |
|
|
|
|
|
setValueIfPresent(form, "toggle_1i56", commonField.getFna_c3b_others()); |
|
|
|
|
|
setValueIfPresent(form, "Text3", commonField.getFna_c3b_desc()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "Check Box6", commonField.getFna_c1e_10()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box7", commonField.getFna_c1e_10_20()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box8", commonField.getFna_c1e_21_30()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box9", commonField.getFna_c1e_31_40()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box10", commonField.getFna_c1e_41_50()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box11", commonField.getFna_c1e_50()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form, "Check Box12", commonField.getFna_c2f_10()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box13", commonField.getFna_c2f_10_20()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box14", commonField.getFna_c2f_21_30()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box15", commonField.getFna_c2f_31_40()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box16", commonField.getFna_c2f_41_50()); |
|
|
|
|
|
setValueIfPresent(form, "Check Box17", commonField.getFna_c2f_50()); |
|
|
/* Page5 End */ |
|
|
/* Page5 End */ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -520,6 +525,153 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
// logger.error("Error processing PDF with iText for ID: " + id, e); |
|
|
// logger.error("Error processing PDF with iText for ID: " + id, e); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try (PDDocument sourceDoc = Loader.loadPDF(modifiedPdfBytes); |
|
|
|
|
|
//PDDocument pdfDoc = Loader.loadPDF(modifiedPdfBytes); |
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { |
|
|
|
|
|
|
|
|
|
|
|
PDAcroForm sourceForm2 = sourceDoc.getDocumentCatalog().getAcroForm(); |
|
|
|
|
|
PDAcroForm form2 = sourceDoc.getDocumentCatalog().getAcroForm(); |
|
|
|
|
|
|
|
|
|
|
|
if (form2 != null) { |
|
|
|
|
|
if (sourceForm2 != null) { |
|
|
|
|
|
for (PDField sourceField : sourceForm2.getFields()) { |
|
|
|
|
|
String sourceFieldName = sourceField.getPartialName(); |
|
|
|
|
|
if (sourceFieldName != null) { |
|
|
|
|
|
String sourceFieldValue = sourceField.getValueAsString(); |
|
|
|
|
|
PDField targetField = form2.getField(sourceFieldName); |
|
|
|
|
|
|
|
|
|
|
|
//only do for check box |
|
|
|
|
|
if ("Btn".equals(sourceField.getFieldType()) || "Ch".equals(sourceField.getFieldType()) |
|
|
|
|
|
&& targetField != null && sourceFieldValue != null) { |
|
|
|
|
|
targetField.setValue(sourceFieldValue); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Long commonFieldId = commonFieldService.getByClientId(clientId); |
|
|
|
|
|
CommonField commonField = commonFieldService.find(commonFieldId).orElse(null); |
|
|
|
|
|
|
|
|
|
|
|
if (commonField != null) { |
|
|
|
|
|
if ("IDA".equals(formCode)) { |
|
|
|
|
|
setValueIfPresent(form2, "gender_m", commonField.getGenderMale()); |
|
|
|
|
|
setValueIfPresent(form2, "gender_f", commonField.getGenderFemale()); |
|
|
|
|
|
|
|
|
|
|
|
setValueIfPresent(form2, "edu_pri", commonField.getEduPri()); |
|
|
|
|
|
setValueIfPresent(form2, "edu_sec", commonField.getEduSec()); |
|
|
|
|
|
setValueIfPresent(form2, "edu_post_sec", commonField.getEduPostSec()); |
|
|
|
|
|
setValueIfPresent(form2, "own_income", commonField.getOwn_income()); |
|
|
|
|
|
setValueIfPresent(form2, "savings", commonField.getSavings()); |
|
|
|
|
|
setValueIfPresent(form2, "premium_financing", commonField.getPremium_financing()); |
|
|
|
|
|
setValueIfPresent(form2, "others_funds", commonField.getOthers_funds()); |
|
|
|
|
|
setValueIfPresent(form2, "others_funds_desc", commonField.getOthers_funds_desc()); |
|
|
|
|
|
|
|
|
|
|
|
} else if ("FNA".equals(formCode)) { |
|
|
|
|
|
setValueIfPresent(form2, "fna_a_primary", commonField.getEduPri()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_a_secondary", commonField.getEduSec()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_a_tertiary", commonField.getEduTer()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b1_a", commonField.getFna_b1_a()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b1_a_amount", commonField.getFna_b1_a_amount()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b1_b", commonField.getFna_b1_b()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b1_c", commonField.getFna_b1_c()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b1_d", commonField.getFna_b1_d()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b1_e", commonField.getFna_b1_e()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b1_f", commonField.getFna_b1_f()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b2_a", commonField.getFna_b2_a()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b2_b", commonField.getFna_b2_b()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b2_d", commonField.getFna_b2_d()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b2_e", commonField.getFna_b2_e()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b2_f", commonField.getFna_b2_f()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_b2_g", commonField.getFna_b2_g()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c1e_10", commonField.getFna_c1e_10()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c1e_10_20", commonField.getFna_c1e_10_20()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c1e_21_30", commonField.getFna_c1e_21_30()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c1e_31_40", commonField.getFna_c1e_31_40()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c1e_41_50", commonField.getFna_c1e_41_50()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c1e_50", commonField.getFna_c1e_50()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c2f_10", commonField.getFna_c2f_10()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c2f_10_20", commonField.getFna_c2f_10_20()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c2f_21_30", commonField.getFna_c2f_21_30()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c2f_31_40", commonField.getFna_c2f_31_40()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c2f_41_50", commonField.getFna_c2f_41_50()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c2f_50", commonField.getFna_c2f_50()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3a_2_5", commonField.getFna_c3a_2_5()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3a_6_10", commonField.getFna_c3a_6_10()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3a_11_15", commonField.getFna_c3a_11_15()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3a_16_20", commonField.getFna_c3a_16_20()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3a_20", commonField.getFna_c3a_20()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3a_life", commonField.getFna_c3a_life()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3a_single_pay", commonField.getFna_c3a_single_pay()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_a_retire", commonField.getFna_a_retire()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3b_salary", commonField.getFna_c3b_salary()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3b_income", commonField.getFna_c3b_income()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3b_saving", commonField.getFna_c3b_saving()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3b_investments", commonField.getFna_c3b_investments()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3b_policy", commonField.getFna_c3b_policy()); |
|
|
|
|
|
setValueIfPresent(form2, "fna_c3b_others", commonField.getFna_c3b_others()); |
|
|
|
|
|
|
|
|
|
|
|
} else if ("HSBCFIN".equals(formCode)) { |
|
|
|
|
|
setValueIfPresent(form2, "toggle_1", commonField.getEduPri()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_2", commonField.getEduSec()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_3", commonField.getEduPostSec()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_3", commonField.getEduTer()); |
|
|
|
|
|
setValueIfPresent(form2, "Financial Protection", commonField.getFna_b1_a()); |
|
|
|
|
|
setValueIfPresent(form2, "Preparation", commonField.getFna_b1_b()); |
|
|
|
|
|
setValueIfPresent(form2, "Providing", commonField.getFna_b1_c()); |
|
|
|
|
|
setValueIfPresent(form2, "Saving", commonField.getFna_b1_d()); |
|
|
|
|
|
setValueIfPresent(form2, "Investment", commonField.getFna_b1_e()); |
|
|
|
|
|
setValueIfPresent(form2, "Others", commonField.getFna_b1_f()); |
|
|
|
|
|
setValueIfPresent(form2, "fill_8_2", commonField.getFna_b1_f_other()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_91", commonField.getFna_b1_a()); |
|
|
|
|
|
setValueIfPresent(form2, "fill_1_4b", commonField.getFna_b1_b()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_93", commonField.getFna_b1_d()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_4_2", commonField.getFna_b2_a()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_5", commonField.getFna_b2_b()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_6", commonField.getFna_b2_c()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_7", commonField.getFna_b2_d()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_8", commonField.getFna_b2_e()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_9", commonField.getFna_b2_f()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_10", commonField.getFna_b2_g()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_1_2", commonField.getFna_c3a_2_5()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_2_2", commonField.getFna_c3a_6_10()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_3_2", commonField.getFna_c3a_11_15()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_4_3", commonField.getFna_c3a_16_20()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_5_2", commonField.getFna_c3a_20()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_6_2", commonField.getFna_c3a_life()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_6_2_sum", commonField.getFna_c3a_2_5()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_1f", commonField.getFna_c3b_income()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_1g", commonField.getFna_c3b_saving()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_1h", commonField.getFna_c3b_policy()); |
|
|
|
|
|
setValueIfPresent(form2, "toggle_1i56", commonField.getFna_c3b_others()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box6", commonField.getFna_c1e_10()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box7", commonField.getFna_c1e_10_20()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box8", commonField.getFna_c1e_21_30()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box9", commonField.getFna_c1e_31_40()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box10", commonField.getFna_c1e_41_50()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box11", commonField.getFna_c1e_50()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box12", commonField.getFna_c2f_10()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box13", commonField.getFna_c2f_10_20()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box14", commonField.getFna_c2f_21_30()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box15", commonField.getFna_c2f_31_40()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box16", commonField.getFna_c2f_41_50()); |
|
|
|
|
|
setValueIfPresent(form2, "Check Box17", commonField.getFna_c2f_50()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Save the modified document to the output stream |
|
|
|
|
|
sourceDoc.save(outputStream); |
|
|
|
|
|
sourceDoc.close(); |
|
|
|
|
|
return outputStream.toByteArray(); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
return pdfBytes; // Return original bytes if no form found |
|
|
|
|
|
} |
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
// logger.error("Error processing PDF with iText for ID: " + id, e); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// try (InputStream is = pdfFile.getInputStream()) { |
|
|
// try (InputStream is = pdfFile.getInputStream()) { |
|
|
// return pdfBytes; |
|
|
// return pdfBytes; |
|
|
// } catch (Exception e) { |
|
|
// } catch (Exception e) { |
|
@@ -898,10 +1050,10 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
//logger.info("closed"); |
|
|
//logger.info("closed"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void setValueIfPresent(PdfAcroForm form, String fieldName, String value, String doOnlyIfValue) { |
|
|
|
|
|
|
|
|
private void setValueIfPresent(PdfAcroForm form, String fieldName, String value) { |
|
|
PdfFormField field = form.getField(fieldName); |
|
|
PdfFormField field = form.getField(fieldName); |
|
|
if (field != null) { |
|
|
if (field != null) { |
|
|
if ((doOnlyIfValue == null || doOnlyIfValue.equals(value)) && value != null) { |
|
|
|
|
|
|
|
|
if (value != null && field.getFormType().equals(PdfName.Tx)) { |
|
|
try { |
|
|
try { |
|
|
field.setValue(value); |
|
|
field.setValue(value); |
|
|
// logger.info("Set field '{}' to value '{}' (from {})", fieldName, value, valueSource); |
|
|
// logger.info("Set field '{}' to value '{}' (from {})", fieldName, value, valueSource); |
|
@@ -915,4 +1067,24 @@ public class PdfService extends AbstractBaseEntityService<Pdf, Long, PdfReposito |
|
|
// logger.warn("PDF field '{}' not found in the document. Skipping setting value.", fieldName); |
|
|
// logger.warn("PDF field '{}' not found in the document. Skipping setting value.", fieldName); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void setValueIfPresent(PDAcroForm form, String fieldName, String value) { |
|
|
|
|
|
PDField field = form.getField(fieldName); |
|
|
|
|
|
if (field != null) { |
|
|
|
|
|
//only do for check box |
|
|
|
|
|
if ("Btn".equals(field.getFieldType()) || "Ch".equals(field.getFieldType())){ |
|
|
|
|
|
if (value != null) { |
|
|
|
|
|
try { |
|
|
|
|
|
logger.info("writing2 " + fieldName + " " + value); |
|
|
|
|
|
field.setValue(value); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
// Handle exception if needed |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |