Example usage for com.lowagie.text.pdf PdfWriter ALLOW_DEGRADED_PRINTING

List of usage examples for com.lowagie.text.pdf PdfWriter ALLOW_DEGRADED_PRINTING

Introduction

In this page you can find the example usage for com.lowagie.text.pdf PdfWriter ALLOW_DEGRADED_PRINTING.

Prototype

int ALLOW_DEGRADED_PRINTING

To view the source code for com.lowagie.text.pdf PdfWriter ALLOW_DEGRADED_PRINTING.

Click Source Link

Document

The operation permitted when the document is opened with the user password

Usage

From source file:org.allcolor.yahp.cl.converter.CDocumentReconstructor.java

License:Open Source License

/**
 * return the itext security flags for encryption
 * //from   w  ww  .  j a  v  a 2  s. c om
 * @param properties
 *            the converter properties
 * 
 * @return the itext security flags
 */
private static final int getSecurityFlags(final Map properties) {
    int securityType = 0;
    securityType = "true".equals(properties.get(IHtmlToPdfTransformer.PDF_ALLOW_PRINTING))
            ? (securityType | PdfWriter.ALLOW_PRINTING)
            : securityType;
    securityType = "true".equals(properties.get(IHtmlToPdfTransformer.PDF_ALLOW_MODIFY_CONTENTS))
            ? (securityType | PdfWriter.ALLOW_MODIFY_CONTENTS)
            : securityType;
    securityType = "true".equals(properties.get(IHtmlToPdfTransformer.PDF_ALLOW_COPY))
            ? (securityType | PdfWriter.ALLOW_COPY)
            : securityType;
    securityType = "true".equals(properties.get(IHtmlToPdfTransformer.PDF_ALLOW_MODIFT_ANNOTATIONS))
            ? (securityType | PdfWriter.ALLOW_MODIFY_ANNOTATIONS)
            : securityType;
    securityType = "true".equals(properties.get(IHtmlToPdfTransformer.PDF_ALLOW_FILLIN))
            ? (securityType | PdfWriter.ALLOW_FILL_IN)
            : securityType;
    securityType = "true".equals(properties.get(IHtmlToPdfTransformer.PDF_ALLOW_SCREEN_READERS))
            ? (securityType | PdfWriter.ALLOW_SCREENREADERS)
            : securityType;
    securityType = "true".equals(properties.get(IHtmlToPdfTransformer.PDF_ALLOW_ASSEMBLY))
            ? (securityType | PdfWriter.ALLOW_ASSEMBLY)
            : securityType;
    securityType = "true".equals(properties.get(IHtmlToPdfTransformer.PDF_ALLOW_DEGRADED_PRINTING))
            ? (securityType | PdfWriter.ALLOW_DEGRADED_PRINTING)
            : securityType;

    return securityType;
}

From source file:org.lucee.extension.pdf.util.PDFUtil.java

License:Open Source License

/**
 * convert a string defintion of a permision in a integer Constant (PdfWriter.ALLOW_XXX)
 * /*from   ww w  .  j ava  2 s .c o  m*/
 * @param strPermission
 * @return
 * @throws ApplicationException
 */
public static int toPermission(String strPermission) throws PageException {
    strPermission = strPermission.trim().toLowerCase();
    if ("allowassembly".equals(strPermission))
        return PdfWriter.ALLOW_ASSEMBLY;
    else if ("none".equals(strPermission))
        return 0;
    else if ("all".equals(strPermission))
        return PERMISSION_ALL;
    else if ("assembly".equals(strPermission))
        return PdfWriter.ALLOW_ASSEMBLY;
    else if ("documentassembly".equals(strPermission))
        return PdfWriter.ALLOW_ASSEMBLY;
    else if ("allowdegradedprinting".equals(strPermission))
        return PdfWriter.ALLOW_DEGRADED_PRINTING;
    else if ("degradedprinting".equals(strPermission))
        return PdfWriter.ALLOW_DEGRADED_PRINTING;
    else if ("printing".equals(strPermission))
        return PdfWriter.ALLOW_DEGRADED_PRINTING;
    else if ("allowfillin".equals(strPermission))
        return PdfWriter.ALLOW_FILL_IN;
    else if ("fillin".equals(strPermission))
        return PdfWriter.ALLOW_FILL_IN;
    else if ("fillingform".equals(strPermission))
        return PdfWriter.ALLOW_FILL_IN;
    else if ("allowmodifyannotations".equals(strPermission))
        return PdfWriter.ALLOW_MODIFY_ANNOTATIONS;
    else if ("modifyannotations".equals(strPermission))
        return PdfWriter.ALLOW_MODIFY_ANNOTATIONS;
    else if ("allowmodifycontents".equals(strPermission))
        return PdfWriter.ALLOW_MODIFY_CONTENTS;
    else if ("modifycontents".equals(strPermission))
        return PdfWriter.ALLOW_MODIFY_CONTENTS;
    else if ("allowcopy".equals(strPermission))
        return PdfWriter.ALLOW_COPY;
    else if ("copy".equals(strPermission))
        return PdfWriter.ALLOW_COPY;
    else if ("copycontent".equals(strPermission))
        return PdfWriter.ALLOW_COPY;
    else if ("allowprinting".equals(strPermission))
        return PdfWriter.ALLOW_PRINTING;
    else if ("printing".equals(strPermission))
        return PdfWriter.ALLOW_PRINTING;
    else if ("allowscreenreaders".equals(strPermission))
        return PdfWriter.ALLOW_SCREENREADERS;
    else if ("screenreaders".equals(strPermission))
        return PdfWriter.ALLOW_SCREENREADERS;

    else
        throw CFMLEngineFactory.getInstance().getExceptionUtil()
                .createApplicationException("invalid permission [" + strPermission
                        + "], valid permission values are [AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations, AllowFillIn, AllowScreenReaders, AllowAssembly, AllowDegradedPrinting]");
}

From source file:org.pdfsam.console.business.parser.validators.EncryptCmdValidator.java

License:Open Source License

/**
 * @param encryptionType encryption algorithm
 * @return The permissions map based on the chosen encryption
 *///from w w  w . ja va 2  s  .  c  o m
private Hashtable getPermissionsMap(String encryptionType) {
    Hashtable retMap = new Hashtable(12);
    if (EncryptParsedCommand.E_RC4_40.equals(encryptionType)) {
        retMap.put(EncryptParsedCommand.E_PRINT, new Integer(PdfWriter.ALLOW_PRINTING));
        retMap.put(EncryptParsedCommand.E_MODIFY, new Integer(PdfWriter.ALLOW_MODIFY_CONTENTS));
        retMap.put(EncryptParsedCommand.E_COPY, new Integer(PdfWriter.ALLOW_COPY));
        retMap.put(EncryptParsedCommand.E_ANNOTATION, new Integer(PdfWriter.ALLOW_MODIFY_ANNOTATIONS));
    } else {
        retMap.put(EncryptParsedCommand.E_PRINT, new Integer(PdfWriter.ALLOW_PRINTING));
        retMap.put(EncryptParsedCommand.E_MODIFY, new Integer(PdfWriter.ALLOW_MODIFY_CONTENTS));
        retMap.put(EncryptParsedCommand.E_COPY, new Integer(PdfWriter.ALLOW_COPY));
        retMap.put(EncryptParsedCommand.E_ANNOTATION, new Integer(PdfWriter.ALLOW_MODIFY_ANNOTATIONS));
        retMap.put(EncryptParsedCommand.E_FILL, new Integer(PdfWriter.ALLOW_FILL_IN));
        retMap.put(EncryptParsedCommand.E_SCREEN, new Integer(PdfWriter.ALLOW_SCREENREADERS));
        retMap.put(EncryptParsedCommand.E_ASSEMBLY, new Integer(PdfWriter.ALLOW_ASSEMBLY));
        retMap.put(EncryptParsedCommand.E_DPRINT, new Integer(PdfWriter.ALLOW_DEGRADED_PRINTING));
    }

    return retMap;
}

From source file:org.pdfsam.guiclient.commons.business.loaders.callable.AddPdfDocument.java

License:Open Source License

/**
 * It gives a human readable version of the document permissions
 * @param permissions//from   w  ww  . j  a  v  a2  s.  co m
 * @return
 */
private String getPermissionsVerbose(int permissions) {
    StringBuffer buf = new StringBuffer();
    if ((PdfWriter.ALLOW_PRINTING & permissions) == PdfWriter.ALLOW_PRINTING)
        buf.append(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Print"));
    if ((PdfWriter.ALLOW_MODIFY_CONTENTS & permissions) == PdfWriter.ALLOW_MODIFY_CONTENTS)
        buf.append(
                ", " + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "Modify"));
    if ((PdfWriter.ALLOW_COPY & permissions) == PdfWriter.ALLOW_COPY)
        buf.append(", " + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Copy or extract"));
    if ((PdfWriter.ALLOW_MODIFY_ANNOTATIONS & permissions) == PdfWriter.ALLOW_MODIFY_ANNOTATIONS)
        buf.append(", " + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Add or modify text annotations"));
    if ((PdfWriter.ALLOW_FILL_IN & permissions) == PdfWriter.ALLOW_FILL_IN)
        buf.append(", " + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Fill form fields"));
    if ((PdfWriter.ALLOW_SCREENREADERS & permissions) == PdfWriter.ALLOW_SCREENREADERS)
        buf.append(", " + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Extract for use by accessibility dev."));
    if ((PdfWriter.ALLOW_ASSEMBLY & permissions) == PdfWriter.ALLOW_ASSEMBLY)
        buf.append(", " + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Manipulate pages and add bookmarks"));
    if ((PdfWriter.ALLOW_DEGRADED_PRINTING & permissions) == PdfWriter.ALLOW_DEGRADED_PRINTING)
        buf.append(", " + GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(),
                "Low quality print"));
    return buf.toString();
}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfDocumentWriter.java

License:Open Source License

/**
 * Extracts the permissions for this PDF. The permissions are returned as flags in the integer value. All permissions
 * are defined as properties which have to be set before the target is opened.
 *
 * @return the permissions.//from  w ww . ja  v  a  2s .  com
 */
private int getPermissions() {
    final String printLevel = config.getConfigProperty(
            "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.PrintLevel");

    final boolean allowPrinting = "none".equals(printLevel) == false;
    final boolean allowDegradedPrinting = "degraded".equals(printLevel);

    final boolean allowModifyContents = "true".equals(config.getConfigProperty(
            "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.AllowModifyContents"));
    final boolean allowModifyAnn = "true".equals(config.getConfigProperty(
            "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.AllowModifyAnnotations"));

    final boolean allowCopy = "true".equals(config.getConfigProperty(
            "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.AllowCopy"));
    final boolean allowFillIn = "true".equals(config.getConfigProperty(
            "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.AllowFillIn"));
    final boolean allowScreenReaders = "true".equals(config.getConfigProperty(
            "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.AllowScreenReader"));
    final boolean allowAssembly = "true".equals(config.getConfigProperty(
            "org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.AllowAssembly"));

    int permissions = 0;
    if (allowPrinting) {
        permissions |= PdfWriter.ALLOW_PRINTING;
    }
    if (allowModifyContents) {
        permissions |= PdfWriter.ALLOW_MODIFY_CONTENTS;
    }
    if (allowModifyAnn) {
        permissions |= PdfWriter.ALLOW_MODIFY_ANNOTATIONS;
    }
    if (allowCopy) {
        permissions |= PdfWriter.ALLOW_COPY;
    }
    if (allowFillIn) {
        permissions |= PdfWriter.ALLOW_FILL_IN;
    }
    if (allowScreenReaders) {
        permissions |= PdfWriter.ALLOW_SCREENREADERS;
    }
    if (allowAssembly) {
        permissions |= PdfWriter.ALLOW_ASSEMBLY;
    }
    if (allowDegradedPrinting) {
        permissions |= PdfWriter.ALLOW_DEGRADED_PRINTING;
    }
    return permissions;
}