You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2022/07/31 15:32:22 UTC
svn commit: r1903145 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/Loader.java
Author: lehmi
Date: Sun Jul 31 15:32:21 2022
New Revision: 1903145
URL: http://svn.apache.org/viewvc?rev=1903145&view=rev
Log:
PDFBOX-4892: fix javadoc, add some more methods using RandomAccessRead as source for the pdf to be read
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/Loader.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/Loader.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/Loader.java?rev=1903145&r1=1903144&r2=1903145&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/Loader.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/Loader.java Sun Jul 31 15:32:21 2022
@@ -324,9 +324,96 @@ public class Loader
}
/**
+ * Parses a PDF. Unrestricted main memory will be used for buffering PDF streams.
+ *
+ * @param randomAccessRead random access read representing the pdf to be loaded
+ *
+ * @return loaded document
+ *
+ * @throws InvalidPasswordException If the PDF required a non-empty password.
+ * @throws IOException In case of a reading or parsing error.
+ */
+ public static PDDocument loadPDF(RandomAccessRead randomAccessRead) throws IOException
+ {
+ return Loader.loadPDF(randomAccessRead, "", null, null,
+ MemoryUsageSetting.setupMainMemoryOnly());
+ }
+
+ /**
* Parses a PDF.
*
- * @param raFile random access read representing the pdf to be loaded
+ * @param randomAccessRead random access read representing the pdf to be loaded
+ * @param memUsageSetting defines how memory is used for buffering PDF streams
+ *
+ * @return loaded document
+ *
+ * @throws InvalidPasswordException If the PDF required a non-empty password.
+ * @throws IOException In case of a reading or parsing error.
+ */
+ public static PDDocument loadPDF(RandomAccessRead randomAccessRead, MemoryUsageSetting memUsageSetting)
+ throws IOException
+ {
+ return Loader.loadPDF(randomAccessRead, "", null, null, memUsageSetting);
+ }
+
+ /**
+ * Parses a PDF.
+ *
+ * @param randomAccessRead stream that contains the document. Don't forget to close it after loading.
+ * @param password password to be used for decryption
+ *
+ * @return loaded document
+ *
+ * @throws InvalidPasswordException If the password is incorrect.
+ * @throws IOException In case of a reading or parsing error.
+ */
+ public static PDDocument loadPDF(RandomAccessRead randomAccessRead, String password) throws IOException
+ {
+ return Loader.loadPDF(randomAccessRead, password, null, null,
+ MemoryUsageSetting.setupMainMemoryOnly());
+ }
+
+ /**
+ * Parses a PDF.
+ *
+ * @param randomAccessRead stream that contains the document. Don't forget to close it after loading.
+ * @param password password to be used for decryption
+ * @param keyStore key store to be used for decryption when using public key security
+ * @param alias alias to be used for decryption when using public key security
+ *
+ * @return loaded document
+ *
+ * @throws IOException In case of a reading or parsing error.
+ */
+ public static PDDocument loadPDF(RandomAccessRead randomAccessRead, String password, InputStream keyStore,
+ String alias) throws IOException
+ {
+ return Loader.loadPDF(randomAccessRead, password, keyStore, alias,
+ MemoryUsageSetting.setupMainMemoryOnly());
+ }
+
+ /**
+ * Parses a PDF.
+ *
+ * @param randomAccessRead stream that contains the document. Don't forget to close it after loading.
+ * @param password password to be used for decryption
+ * @param memUsageSetting defines how memory is used for buffering PDF streams
+ *
+ * @return loaded document
+ *
+ * @throws InvalidPasswordException If the password is incorrect.
+ * @throws IOException In case of a reading or parsing error.
+ */
+ public static PDDocument loadPDF(RandomAccessRead randomAccessRead, String password,
+ MemoryUsageSetting memUsageSetting) throws IOException
+ {
+ return Loader.loadPDF(randomAccessRead, password, null, null, memUsageSetting);
+ }
+
+ /**
+ * Parses a PDF.
+ *
+ * @param randomAccessRead random access read representing the pdf to be loaded
* @param password password to be used for decryption
* @param keyStore key store to be used for decryption when using public key security
* @param alias alias to be used for decryption when using public key security
@@ -336,13 +423,15 @@ public class Loader
*
* @throws IOException in case of a file reading or parsing error
*/
- public static PDDocument loadPDF(RandomAccessRead raFile, String password,
+ public static PDDocument loadPDF(RandomAccessRead randomAccessRead, String password,
InputStream keyStore, String alias, MemoryUsageSetting memUsageSetting)
throws IOException
{
- PDFParser parser = new PDFParser(raFile, password, keyStore, alias, memUsageSetting);
+ PDFParser parser = new PDFParser(randomAccessRead, password, keyStore, alias,
+ memUsageSetting);
return parser.parse();
}
+
/**
* Parses a PDF. The given input stream is copied to the memory to enable random access to the pdf. Unrestricted
* main memory will be used for buffering PDF streams.
@@ -360,8 +449,7 @@ public class Loader
}
/**
- * Parses a PDF. Depending on the memory settings parameter the given input stream is either copied to main memory
- * or to a temporary file to enable random access to the pdf.
+ * Parses a PDF. The given input stream is copied to main memory to enable random access to the pdf.
*
* @param input stream that contains the document. Don't forget to close it after loading.
* @param memUsageSetting defines how memory is used for buffering PDF streams
@@ -376,6 +464,7 @@ public class Loader
{
return Loader.loadPDF(input, "", null, null, memUsageSetting);
}
+
/**
* Parses a PDF. The given input stream is copied to the memory to enable random access to the pdf. Unrestricted
* main memory will be used for buffering PDF streams.
@@ -412,8 +501,7 @@ public class Loader
}
/**
- * Parses a PDF. Depending on the memory settings parameter the given input stream is either copied to main memory
- * or to a temporary file to enable random access to the pdf.
+ * Parses a PDF. The given input stream is copied to main memory to enable random access to the pdf.
*
* @param input stream that contains the document. Don't forget to close it after loading.
* @param password password to be used for decryption