Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.pdftron.pdf.PDFDoc;
- import com.pdftron.pdf.PDFNet;
- import javax.annotation.PostConstruct;
- import javax.annotation.PreDestroy;
- import java.io.FileNotFoundException;
- import java.util.ArrayList;
- import java.util.Enumeration;
- import java.util.List;
- import java.util.zip.ZipEntry;
- import java.util.zip.ZipFile;
- import java.util.stream.Collectors;
- import java.util.Scanner;
- public class PDFTron {
- public static void main(String[] args) throws Exception {
- PDFNet.initialize();
- Scanner scanner = new Scanner(System.in);
- scanner.nextInt();
- int count = 100;
- do {
- while (count > 0) {
- run();
- count--;
- }
- System.out.println("Iteration done!");
- count = scanner.nextInt();
- }
- while (count != 0);
- PDFNet.terminate();
- System.out.println("Done");
- scanner.nextInt();
- }
- private static void run() throws Exception {
- String pathToZipFile = "files.zip";
- ZipFile zipFile = new ZipFile(pathToZipFile);
- List<PDFDoc> pdfDocs = zipFile.stream().parallel()
- .map(zipEntry -> {
- try {
- return new PDFDoc(zipFile.getInputStream(zipEntry));
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- })
- .collect(Collectors.toList());
- zipFile.close();
- for (PDFDoc pdfDoc : pdfDocs) {
- pdfDoc.close();
- }
- }
- }
Add Comment
Please, Sign In to add comment