Skip to content
Snippets Groups Projects
Commit e82c98df authored by cepedac's avatar cepedac
Browse files

Compilation error fixed and README updated

parent 1f0571e7
No related branches found
No related tags found
No related merge requests found
Pipeline #2906 passed
# Split-pdf
Split PDF files: read all the pages, detect the pages with QR codes (which contain json objects) and create PDF files with the pages between them.
The QR codes should be in the top-left quarter of your pages.
The name of the split PDF files is determined by the values in the json object of the previous QR code.
The new files are grouped in sub-directories by a defined attribute.
......@@ -24,7 +25,7 @@ with:
- arg4 (optional): index of the attribute by which the program will group the split PDF files, possible values: 0 to size-1 (from arg3 list), default = 2 (for "class")
## Delete first pages
## Delete first pages (deprecated)
Deleting useless first pages in the content is possible. After splitting the PDF files, there are PDF files whose names start with "second_pages_", which contain only the first pages of all split PDF files. There are also CSV files whose names start with "second_pages_mapping", which contain two columns: the page number (of PDF file of first pages) and the name of the split PDF file that contains the corresponding first page.
If you want to delete the first pages of all the split PDF files, you can mark exceptions in the CSV file: simply add a character like 'X' on the third column within the adequate line. The files of these lines will not be modified.
......
......@@ -27,7 +27,7 @@ import java.nio.file.Files;
// ***************** FIN FT## ******************************
@Deprecated
public class SecondPagesHandler extends PDFStreamEngine
{
private static String prefixOutputSubFolder = "c";
......
......@@ -19,32 +19,15 @@ import java.util.*;
// ***************** FT## *****************
import org.apache.pdfbox.rendering.*;
import com.google.zxing.*;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import fr.limos.splitpdf.SecondPagesHandler;
import fr.limos.splitpdf.Tools;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.AffineTransformOp;
import java.awt.image.BufferedImageOp;
import java.awt.image.ConvolveOp;
import java.awt.image.Kernel;
import java.awt.image.LookupOp;
import java.awt.image.ShortLookupTable;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import javax.imageio.IIOImage;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -332,23 +315,23 @@ public class SplitQRCodePages extends PDFStreamEngine
Tools.writeFile(invalidQRfound, outputFolder + "invalid_codes_"+inputFileName+".csv");
}
private static void saveSecondPagesPdf(PDDocument secondPagesPdf, String secondPagesList, String outputFolder, String inputFileName) {
if (!outputFolder.endsWith("/") || !outputFolder.endsWith("\\"))
outputFolder += "/";
if (secondPagesPdf != null && secondPagesPdf.getNumberOfPages() > 0) {
try {
secondPagesPdf.save(outputFolder + "second_pages_"+inputFileName+".pdf");
secondPagesPdf.close();
}
catch (IOException e) {
System.out.println("Problem to save the file second_pages.pdf");
}
}
if (secondPagesList != null && !secondPagesList.isEmpty())
Tools.writeFile(secondPagesList, outputFolder + SecondPagesHandler.getCSV_FILENAME_BEGINNING()+inputFileName+".csv");
}
// private static void saveSecondPagesPdf(PDDocument secondPagesPdf, String secondPagesList, String outputFolder, String inputFileName) {
// if (!outputFolder.endsWith("/") || !outputFolder.endsWith("\\"))
// outputFolder += "/";
//
// if (secondPagesPdf != null && secondPagesPdf.getNumberOfPages() > 0) {
// try {
// secondPagesPdf.save(outputFolder + "second_pages_"+inputFileName+".pdf");
// secondPagesPdf.close();
// }
// catch (IOException e) {
// System.out.println("Problem to save the file second_pages.pdf");
// }
// }
//
// if (secondPagesList != null && !secondPagesList.isEmpty())
// Tools.writeFile(secondPagesList, outputFolder + SecondPagesHandler.getCSV_FILENAME_BEGINNING()+inputFileName+".csv");
// }
// private static void saveContentPdf(PDDocument contentPdf, String outputFolder, String inputFileName) {
// if (!outputFolder.endsWith("/") || !outputFolder.endsWith("\\"))
......
......@@ -14,7 +14,6 @@ import com.google.zxing.NotFoundException;
import com.google.zxing.Result;
import com.google.zxing.client.j2se.BufferedImageLuminanceSource;
import com.google.zxing.common.HybridBinarizer;
import com.sun.javafx.iio.ImageStorage;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileWriter;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment