List of usage examples for com.itextpdf.text.pdf PushbuttonField setProportionalIcon
public void setProportionalIcon(boolean proportionalIcon)
From source file:org.smap.sdal.managers.PDFSurveyManager.java
License:Open Source License
private static void fillTemplateUserDetails(AcroFields pdfForm, User user, String basePath) throws IOException, DocumentException { try {// ww w. j av a 2s. c o m pdfForm.setField("user_name", user.name); pdfForm.setField("user_company", user.company_name); /* * User configurable data TODO This should be an array of key value pairs * As interim use a hard coded class to hold the data */ String settings = user.settings; Type type = new TypeToken<UserSettings>() { }.getType(); Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create(); UserSettings us = gson.fromJson(settings, type); if (us != null) { pdfForm.setField("user_title", us.title); pdfForm.setField("user_license", us.license); PushbuttonField ad = pdfForm.getNewPushbuttonFromField("user_signature"); if (ad != null) { ad.setLayout(PushbuttonField.LAYOUT_ICON_ONLY); ad.setProportionalIcon(true); String filename = null; try { filename = basePath + "/media/users/" + user.id + "/sig/" + user.signature; ad.setImage(Image.getInstance(filename)); } catch (Exception e) { log.info("Error: Failed to add signature " + filename + " to pdf"); } pdfForm.replacePushbuttonField("user_signature", ad.getField()); } else { //log.info("Picture field: user_signature not found"); } } } catch (Exception e) { log.log(Level.SEVERE, "Error filling template", e); } }