// Path: src/main/java/technology/tabula/tabula_web/Utils.java
// public class Utils {
// 
//     private static final String DEFAULT_PASSWORD = "";
// 
//     public static PDDocument openPDF(String documentPath) throws IOException {
//         PDDocument document = PDDocument.load(new File(documentPath));
//         if (document.isEncrypted()) {
//             document.close();
//             document = PDDocument.load(new File(documentPath), DEFAULT_PASSWORD);
//             document.setAllSecurityToBeRemoved(true);
//         }
//         return document;
//     }
// }


import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.pdfbox.pdmodel.PDDocument;
import technology.tabula.ObjectExtractor;
import technology.tabula.Page;
import technology.tabula.PageIterator;
import technology.tabula.Table;
import technology.tabula.extractors.BasicExtractionAlgorithm;
import technology.tabula.extractors.ExtractionAlgorithm;
import technology.tabula.extractors.SpreadsheetExtractionAlgorithm;
import technology.tabula.tabula_web.Utils;
package technology.tabula.tabula_web.extractor;




public class Extractor {

	@SuppressWarnings("Convert2Diamond")
    public static List<TableWithSpecIndex> extractTables(String pdfPath, List<CoordSpec> specs) throws IOException {
		
		Map<Integer, List<CoordSpec>> specsByPage = specs.stream().collect(Collectors.groupingBy(CoordSpec::getPage));
		//noinspection Convert2Diamond
		List<Integer> pages = new ArrayList<Integer>(specsByPage.keySet());
		Collections.sort(pages);
		
// Path: src/main/java/technology/tabula/tabula_web/Utils.java
// public class Utils {
// 
//     private static final String DEFAULT_PASSWORD = "";
// 
//     public static PDDocument openPDF(String documentPath) throws IOException {
//         PDDocument document = PDDocument.load(new File(documentPath));
//         if (document.isEncrypted()) {
//             document.close();
//             document = PDDocument.load(new File(documentPath), DEFAULT_PASSWORD);
//             document.setAllSecurityToBeRemoved(true);
//         }
//         return document;
//     }
// }


// Path: src/main/java/technology/tabula/tabula_web/extractor/Extractor.java
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.pdfbox.pdmodel.PDDocument;
import technology.tabula.ObjectExtractor;
import technology.tabula.Page;
import technology.tabula.PageIterator;
import technology.tabula.Table;
import technology.tabula.extractors.BasicExtractionAlgorithm;
import technology.tabula.extractors.ExtractionAlgorithm;
import technology.tabula.extractors.SpreadsheetExtractionAlgorithm;
import technology.tabula.tabula_web.Utils;

package technology.tabula.tabula_web.extractor;




public class Extractor {

	@SuppressWarnings("Convert2Diamond")
    public static List<TableWithSpecIndex> extractTables(String pdfPath, List<CoordSpec> specs) throws IOException {
		
		Map<Integer, List<CoordSpec>> specsByPage = specs.stream().collect(Collectors.groupingBy(CoordSpec::getPage));
		//noinspection Convert2Diamond
		List<Integer> pages = new ArrayList<Integer>(specsByPage.keySet());
		Collections.sort(pages);
		
		PDDocument document = Utils.openPDF(pdfPath);