Example usage for com.itextpdf.text Image setIndentationLeft

List of usage examples for com.itextpdf.text Image setIndentationLeft

Introduction

In this page you can find the example usage for com.itextpdf.text Image setIndentationLeft.

Prototype

public void setIndentationLeft(final float f) 

Source Link

Document

Sets the left indentation.

Usage

From source file:org.smap.sdal.managers.PDFSurveyManager.java

License:Open Source License

private void fillNonTemplateUserDetails(Document document, User user, String basePath)
        throws IOException, DocumentException {

    String settings = user.settings;
    Type type = new TypeToken<UserSettings>() {
    }.getType();/*from www  . j  av a  2  s  .c  om*/
    Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
    UserSettings us = gson.fromJson(settings, type);

    float indent = (float) 20.0;
    addValue(document, "Completed by:", (float) 0.0);
    if (user.signature != null && user.signature.trim().length() > 0) {
        String fileName = null;
        try {
            //fileName = basePath + user.signature;

            fileName = basePath + "/media/users/" + user.id + "/sig/" + user.signature;

            Image img = Image.getInstance(fileName);
            img.scaleToFit(200, 50);
            img.setIndentationLeft(indent);

            document.add(img);

        } catch (Exception e) {
            log.info(
                    "Error: Failed to add signature (non template) " + fileName + " to pdf: " + e.getMessage());
        }
    }
    addValue(document, user.name, indent);
    addValue(document, user.company_name, indent);
    if (us != null) {
        addValue(document, us.title, indent);
        addValue(document, us.license, indent);
    }

}

From source file:org.smap.sdal.managers.PDFTableManager.java

License:Open Source License

private void fillNonTemplateUserDetails(Document document, User user, String basePath)
        throws IOException, DocumentException {

    String settings = user.settings;
    Type type = new TypeToken<UserSettings>() {
    }.getType();// w  w w  .  ja va 2  s . c o m
    Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create();
    UserSettings us = gson.fromJson(settings, type);

    float indent = (float) 20.0;
    addValue(document, "Completed by:", (float) 0.0);
    if (user.signature != null && user.signature.trim().length() > 0) {
        String fileName = null;
        try {
            fileName = basePath + File.separator + user.signature;

            Image img = Image.getInstance(fileName);
            img.scaleToFit(200, 50);
            img.setIndentationLeft(indent);

            document.add(img);

        } catch (Exception e) {
            log.info("Error: Failed to add image " + fileName + " to pdf");
        }
    }
    addValue(document, user.name, indent);
    addValue(document, user.company_name, indent);
    if (us != null) {
        addValue(document, us.title, indent);
        addValue(document, us.license, indent);
    }

}