public abstract class PDFUtils
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
PDFUtils.Permission
Represents permissions that can be set on a PDF document.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
encryptPDF(java.io.InputStream pdf,
java.io.OutputStream target,
java.lang.String userPassword,
java.lang.String ownerPassword)
This utility method encrypts a PDF file with the given user and owner
passwords and preserves the same permissions from the original file.
|
static void |
encryptPDF(java.io.InputStream pdf,
java.io.OutputStream target,
java.lang.String userPassword,
java.lang.String ownerPassword,
PDFUtils.Permission... permissions)
This utility method encrypts a PDF file with the given user and owner
passwords and applies the specified permissions to the file.
|
static java.io.InputStream |
getStreamIfPDF(java.io.InputStream in)
Checks if the inputstream contains PDF data.
|
static boolean |
isPDF(java.io.File file) |
static boolean |
isPDF(java.io.PushbackInputStream in) |
public static void encryptPDF(java.io.InputStream pdf,
java.io.OutputStream target,
java.lang.String userPassword,
java.lang.String ownerPassword)
throws java.io.IOException
pdf - The input stream containing PDF datatarget - The output stream to write the encrypted PDF file into.userPassword - The user passwordownerPassword - The owner passwordjava.io.IOException - Upon IO errors.encryptPDF(InputStream, OutputStream, String, String,
Permission...)public static void encryptPDF(java.io.InputStream pdf,
java.io.OutputStream target,
java.lang.String userPassword,
java.lang.String ownerPassword,
PDFUtils.Permission... permissions)
throws java.io.IOException
Note that the given target output stream is NOT closed, that has to be done explicitly.
pdf - The input stream containing PDF datatarget - The output stream to write the encrypted PDF file into.userPassword - The user passwordownerPassword - The owner passwordpermissions - The permissions to be applied to
the encrypted file.java.io.IOException - Upon IO errors.public static boolean isPDF(java.io.File file)
public static java.io.InputStream getStreamIfPDF(java.io.InputStream in)
throws java.io.IOException
Note that if the stream doesn't contain PDF data, null is returned from this method.
in - The original input streamjava.io.IOException - Upon read errors.public static boolean isPDF(java.io.PushbackInputStream in)
throws java.io.IOException
java.io.IOExceptionCopyright ? Technia AB. All Rights Reserved.