Example usage for com.itextpdf.text PageSize LETTER

List of usage examples for com.itextpdf.text PageSize LETTER

Introduction

In this page you can find the example usage for com.itextpdf.text PageSize LETTER.

Prototype

Rectangle LETTER

To view the source code for com.itextpdf.text PageSize LETTER.

Click Source Link

Document

This is the letter format

Usage

From source file:com.propelics.pdfcreator.PdfcreatorModule.java

License:Open Source License

private void generateiTextPDFfunction(HashMap args) {
    Log.d(PROXY_NAME, "generateiTextPDFfunction()");

    String filename = "";
    TiUIView webview = null;//from w  w  w  .java 2  s .  co m
    int quality = 100;

    try {
        if (args.containsKey("filename")) {
            filename = (String) args.get("filename");
            Log.d(PROXY_NAME, "filename: " + filename);
        } else
            return;

        if (args.containsKey("webview")) {
            TiViewProxy viewProxy = (TiViewProxy) args.get("webview");
            webview = viewProxy.getOrCreateView();
            Log.d(PROXY_NAME, "webview: " + webview.toString());
        } else
            return;

        if (args.containsKey("quality")) {
            quality = TiConvert.toInt(args.get("quality"));
        }

        TiBaseFile file = TiFileFactory.createTitaniumFile(filename, true);
        Log.d(PROXY_NAME, "file full path: " + file.nativePath());

        OutputStream outputStream = file.getOutputStream();
        final int MARGIN = 0;
        final float PDF_WIDTH = PageSize.LETTER.getWidth() - MARGIN * 2; // A4: 595 //Letter: 612
        final float PDF_HEIGHT = PageSize.LETTER.getHeight() - MARGIN * 2; // A4: 842 //Letter: 792
        final int DEFAULT_VIEW_WIDTH = 980;
        final int DEFAULT_VIEW_HEIGHT = 1384;
        int viewWidth = DEFAULT_VIEW_WIDTH;
        int viewHeight = DEFAULT_VIEW_HEIGHT;

        Document pdfDocument = new Document(PageSize.LETTER, MARGIN, MARGIN, MARGIN, MARGIN);
        PdfWriter docWriter = PdfWriter.getInstance(pdfDocument, outputStream);

        Log.d(PROXY_NAME, "PDF_WIDTH: " + PDF_WIDTH);
        Log.d(PROXY_NAME, "PDF_HEIGHT: " + PDF_HEIGHT);

        WebView view = (WebView) webview.getNativeView();

        if (TiApplication.isUIThread()) {

            viewWidth = view.capturePicture().getWidth();
            viewHeight = view.capturePicture().getHeight();

            if (viewWidth <= 0) {
                viewWidth = DEFAULT_VIEW_WIDTH;
            }

            if (viewHeight <= 0) {
                viewHeight = DEFAULT_VIEW_HEIGHT;
            }

        } else {
            Log.e(PROXY_NAME, "NO UI THREAD");
            viewWidth = DEFAULT_VIEW_WIDTH;
            viewHeight = DEFAULT_VIEW_HEIGHT;
        }

        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        Log.d(PROXY_NAME, "viewWidth: " + viewWidth);
        Log.d(PROXY_NAME, "viewHeight: " + viewHeight);

        float scaleFactorWidth = 1 / (viewWidth / PDF_WIDTH);
        float scaleFactorHeight = 1 / (viewHeight / PDF_HEIGHT);

        Log.d(PROXY_NAME, "scaleFactorWidth: " + scaleFactorWidth);
        Log.d(PROXY_NAME, "scaleFactorHeight: " + scaleFactorHeight);

        Bitmap viewBitmap = Bitmap.createBitmap(viewWidth, viewHeight, Bitmap.Config.ARGB_8888);
        Canvas viewCanvas = new Canvas(viewBitmap);

        // Paint paintAntialias = new Paint();
        // paintAntialias.setAntiAlias(true);
        // paintAntialias.setFilterBitmap(true);

        Drawable bgDrawable = view.getBackground();
        if (bgDrawable != null) {
            bgDrawable.draw(viewCanvas);
        } else {
            viewCanvas.drawColor(Color.WHITE);
        }
        view.draw(viewCanvas);

        TiBaseFile pdfImg = createTempFile(filename);

        viewBitmap.compress(Bitmap.CompressFormat.PNG, quality, pdfImg.getOutputStream());

        FileInputStream pdfImgInputStream = new FileInputStream(pdfImg.getNativeFile());
        byte[] pdfImgBytes = IOUtils.toByteArray(pdfImgInputStream);
        pdfImgInputStream.close();

        pdfDocument.open();
        float yFactor = viewHeight * scaleFactorWidth;
        int pageNumber = 1;

        do {
            if (pageNumber > 1) {
                pdfDocument.newPage();
            }
            pageNumber++;
            yFactor -= PDF_HEIGHT;

            Image pageImage = Image.getInstance(pdfImgBytes, true);
            // Image pageImage = Image.getInstance(buffer.array());
            pageImage.scalePercent(scaleFactorWidth * 100);
            pageImage.setAbsolutePosition(0f, -yFactor);
            pdfDocument.add(pageImage);

            Log.d(PROXY_NAME, "yFactor: " + yFactor);
        } while (yFactor > 0);

        pdfDocument.close();

        sendCompleteEvent(filename);

    } catch (Exception exception) {
        sendErrorEvent(exception);
    }
}

From source file:com.sapito.direccion.PdfView.java

@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    ByteArrayOutputStream baos = createTemporaryOutputStream();
    Document document = new Document(PageSize.LETTER);
    PdfWriter pdfWriter = PdfWriter.getInstance(document, baos);
    pdfWriter.setViewerPreferences(PdfWriter.ALLOW_PRINTING | PdfWriter.PageLayoutSinglePage);

    document.open();/*from ww  w  . j av a  2  s.c  o  m*/
    buildPdfDocument(model, document, pdfWriter, request, response);
    document.close();

    response.setHeader("Content-Disposition",
            "attachment; filename=" + model.get("filename").toString() + ".pdf");
    //response.setContentLength(baos.size());
    System.out.println("size:" + baos.size());
    writeToResponse(response, baos);

}

From source file:com.tommontom.pdfsplitter.PdfMerge.java

public static void doMerge(java.util.List<InputStream> list, String[] imageList, String[] listWordExcels,
        OutputStream outputStream) throws DocumentException, IOException {
    Document document = new Document(PageSize.LETTER, 0, 0, 0, 0);
    PdfWriter writer = PdfWriter.getInstance(document, outputStream);
    writer.setFullCompression();// w ww .j  a  va2 s . com
    document.open();
    PdfContentByte cb = writer.getDirectContent();
    Image img;
    for (InputStream in : list) {
        PdfReader reader = new PdfReader(in);
        for (int i = 1; i <= reader.getNumberOfPages(); i++) {

            document.newPage();
            //import the page from source pdf
            PdfImportedPage page = writer.getImportedPage(reader, i);
            //add the page to the destination pdf
            cb.addTemplate(page, 0, 0);
        }

    }
    for (int i = 0; i < imageList.length; i++) {
        document.newPage();
        if (imageList[i] != null) {
            img = Image.getInstance(String.format("%s", imageList[i]));
            Rectangle one = new Rectangle(img.getPlainWidth(), img.getPlainHeight());
            document.setPageSize(one);
            if (img.getScaledWidth() > img.getScaledHeight()) {
                img.rotate();
            }
            if (img.getScaledWidth() > 792 || img.getScaledHeight() > 792) {
                img.scaleToFit(792, 792);

            }
            img.setDpi(150, 150);
            document.add(img);
        }
    }
    for (int i = 0; i < listWordExcels.length; i++) {
        if (imageList[i] != null) {
            File input = new File(listWordExcels[i]);
            File output = new File(listWordExcels[i] + ".pdf");
            String outputS = listWordExcels[i] + ".pdf";
            OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
            connection.connect();
            DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
            converter.convert(input, output);
            PdfReader readerWord = new PdfReader(outputS);
            PdfImportedPage page = writer.getImportedPage(readerWord, readerWord.getNumberOfPages());
            cb.addTemplate(page, 0, 0);
        }
    }

    outputStream.flush();
    document.close();
    outputStream.close();
}

From source file:com.tommontom.pdfsplitter.PdfSplit.java

public void pdfSplit(String path) throws IOException, DocumentException, InterruptedException {
    // TODO Instead of hard code path, pass in as argument
    File folder = new File(path);
    FileNameFilter FileFilter = new FileNameFilter();
    File[] listOfFiles = folder.listFiles(FileFilter); /* Stores the listing of the files */

    for (int i = 0; i < listOfFiles.length; i++) {
        File file = listOfFiles[i];
        if (!file.isFile()) {
            continue;
        }/*from   www.  ja v a  2  s .  co  m*/
        // Split the source filename into its 2 parts
        String fileName = file.getName();
        String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf("."));
        PdfReader pdfFileReader = new PdfReader(file.getPath());
        Document document = new Document(PageSize.LETTER, 0, 0, 0,
                0); /* instantiates a new document to be made */

        int k = 0;
        int numPages = pdfFileReader.getNumberOfPages();
        // Split on a space '\s'
        // Determine number of pages by difference of lot numbers
        // Read in the source document
        // Example file name: 16034-212234 16034-212236.pdf > 16034-212234.pdf, 16034-212235.pdf, 16034-212236.pdf
        // Create a copy of the orignal source file. We will pick specific pages out below
        for (int j = 1; j < numPages + 1; j++) {
            String FileName = (fileNameWithoutExt); /* Dynamic file name */

            PdfCopy copy = new PdfCopy(document,
                    new FileOutputStream(path + "\\" + FileName + "(" + j + ")" + ".pdf"));
            document.open();
            copy.addPage(copy.getImportedPage(pdfFileReader, j)); /* Import pages from original document */

            deleteFile[k] = path + "\\" + FileName + "(" + j + 1 + ")" + ".pdf";
            k++;
            if (j == 1) {
                newFileListing = ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            } else if (j > 1) {
                newFileListing += ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            }
            document.close();

        }

        System.out.println("Number of Documents Created:" + numPages);
        pdfFileReader.close();
    }
}

From source file:com.tommontom.pdfsplitter.PdfSplit.java

public void pdfSplitCopy(String path) throws IOException, DocumentException {
    // TODO Instead of hard code path, pass in as argument
    File folder = new File(path);
    FileNameFilter FileFilter = new FileNameFilter();
    File[] listOfFiles = folder.listFiles(FileFilter); /* Stores the listing of the files */

    for (int i = 0; i < listOfFiles.length; i++) {
        File file = listOfFiles[i];
        if (!file.isFile()) {
            continue;
        }//  w  w w . j ava  2 s .c  o m
        // Split the source filename into its 2 parts
        String fileName = file.getName();
        String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf("."));
        PdfReader pdfFileReader = new PdfReader(file.getPath());
        Document document = new Document(PageSize.LETTER, 0, 0, 0,
                0); /* instantiates a new document to be made */

        String[] fileNameNum = fileNameWithoutExt.split("-");
        int fileNameNumOne = Integer.getInteger(fileNameNum[0]);
        int fileNameNumTwo = Integer.getInteger(fileNameNum[1]);
        int constant = 1;
        int k = 0;
        int numPages = fileNameNumTwo - fileNameNumOne;
        // Split on a space '\s'
        // Determine number of pages by difference of lot numbers
        // Read in the source document
        // Example file name: 16034-212234 16034-212236.pdf > 16034-212234.pdf, 16034-212235.pdf, 16034-212236.pdf
        // Create a copy of the orignal source file. We will pick specific pages out below
        document.open();
        for (int j = 0; j < numPages + 1; j++) {
            String FileName = (fileNameWithoutExt); /* Dynamic file name */
            PdfCopy copy = new PdfCopy(document,
                    new FileOutputStream(path + "\\" + FileName + "(" + j + 1 + ")" + ".pdf"));
            deleteFile[k] = (path + "\\" + FileName + "(" + j + 1 + ")" + ".pdf");
            k++;
            document.open();
            copy.addPage(
                    copy.getImportedPage(pdfFileReader, constant)); /* Import pages from original document */

            if (j == 1) {
                newFileListing = ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            } else if (j > 1) {
                newFileListing += ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            }
            document.close();
            copy.close();
        }

        System.out.println("Number of Documents Created:" + numPages);
        pdfFileReader.close();
    }

}

From source file:com.tommontom.pdfsplitter.PdfSplit.java

public void pdfSplitSupplierDoc(String path) throws IOException, DocumentException {
    // TODO Instead of hard code path, pass in as argument
    File folder = new File(path);
    FileNameFilter FileFilter = new FileNameFilter();
    File[] listOfFiles = folder.listFiles(FileFilter); /* Stores the listing of the files */

    for (int i = 0; i < listOfFiles.length; i++) {
        File file = listOfFiles[i];
        if (!file.isFile()) {
            continue;
        }/* w w w.ja va  2  s .co m*/
        // Split the source filename into its 2 parts
        String fileName = file.getName();
        String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf("."));
        PdfReader pdfFileReader = new PdfReader(file.getPath());
        Document document = new Document(PageSize.LETTER, 0, 0, 0,
                0); /* instantiates a new document to be made */

        String[] fileNames = fileNameWithoutExt.split("-");
        /*
         * if (fileNames.length != 2) { throw new RuntimeException("File name format is not in right format"); }
         */

        String fileNameFirst = fileNames[1];
        String fileNameSecond = fileNames[2];
        System.out.println("First lot number: " + fileNameFirst + " Second lot number: " + fileNameSecond);
        // Project num is always the 1st part
        String projectNum = fileNames[0];
        if (!projectNum.equals(fileNames[0])) {
            throw new RuntimeException("Filename needs to have a project number");
        }

        // Strip off the first and second lot number, parse into integers
        int firstLotNum;
        int secondLotNum;
        firstLotNum = Integer.parseInt(fileNames[1]);
        secondLotNum = Integer.parseInt(fileNames[2].substring(0, fileNames[2].lastIndexOf(".")));
        // Create a copy of the orignal source file. We will pick specific pages out below
        document.open();
        int numPages = secondLotNum - firstLotNum;
        for (int j = 1; j < numPages + 1; j++) {
            String FileName = projectNum + "-" + (firstLotNum) + ".pdf"; /* Dynamic file name */

            firstLotNum++;
            document = new Document(PageSize.LETTER, 0, 0, 0, 0);
            PdfCopy copy = new PdfCopy(document, new FileOutputStream(path + "\\" + FileName));
            document.open();
            copy.addPage(copy.getImportedPage(pdfFileReader, j)); /* Import pages from original document */

            document.close();
            copy.close();
        }
        pdfFileReader.close();
    }
}

From source file:com.tommontom.pdfsplitter.PdfSplit.java

public void pdfSplitDrop(File[] files) throws IOException, DocumentException, InterruptedException {
    // TODO Instead of hard code path, pass in as argument
    String path;/* w w  w . j a v  a 2  s  . co m*/
    if (directoryField.getText().isEmpty() || directoryField.getText().equals(example)) {
        path = files[0].getParent();
    } else {
        path = directoryField.getText();
    }
    File[] listOfFiles = files; /* Stores the listing of the files */

    for (int i = 0; i < listOfFiles.length; i++) {
        File file = listOfFiles[i];
        if (!file.isFile()) {
            continue;
        }
        // Split the source filename into its 2 parts
        String fileName = file.getName();
        String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf("."));
        PdfReader pdfFileReader = new PdfReader(file.getPath());
        Document document = new Document(PageSize.LETTER, 0, 0, 0,
                0); /* instantiates a new document to be made */

        int numPages = pdfFileReader.getNumberOfPages();
        // Determine number of pages by difference of lot numbers
        // Read in the source document
        // Example file name: 16034-212234 16034-212236.pdf > 16034-212234.pdf, 16034-212235.pdf, 16034-212236.pdf
        // Create a copy of the orignal source file. We will pick specific pages out below
        int k = 0;
        for (int j = 1; j < numPages + 1; j++) {
            String FileName = fileNameWithoutExt; /* Dynamic file name */

            PdfCopy copy = new PdfCopy(document,
                    new FileOutputStream(path + "\\" + FileName + "(" + j + ")" + ".pdf"));
            document.open();
            copy.addPage(copy.getImportedPage(pdfFileReader, j)); /* Import pages from original document */
            deleteFile[k] += path + "\\" + FileName + "(" + j + ")" + ".pdf";
            k++;
            if (j == 1) {
                newFileListing = ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            } else if (j > 1) {
                newFileListing += ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            }
            document.close();
            copy.close();
        }

        pdfFileReader.close();
    }
}

From source file:com.tommontom.pdfsplitter.PdfSplit.java

public void pdfSplitDropCopy(File[] files) throws IOException, DocumentException {
    // TODO Instead of hard code path, pass in as argument
    String path;/*from   w w  w  .  j a v  a 2s .  com*/
    path = files[0].getParent();
    File[] listOfFiles = files; /* Stores the listing of the files */
    System.out.println(directoryField);
    for (int i = 0; i < listOfFiles.length; i++) {
        File file = listOfFiles[i];
        if (!file.isFile()) {
            continue;
        }
        // Split the source filename into its 2 parts
        String fileName = file.getName();
        String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf("."));
        String[] fileNameNum = fileNameWithoutExt.split("-");
        int fileNameNumOne = Integer.parseInt(fileNameNum[0]);
        int fileNameNumTwo = Integer.parseInt(fileNameNum[1]);
        int constant = 1;
        int numPages = fileNameNumTwo - fileNameNumOne;
        PdfReader pdfFileReader = new PdfReader(file.getPath());
        Document document = new Document(PageSize.LETTER, 0, 0, 0, 0);
        ; /* instantiates a new document to be made */

        // Determine number of pages by difference of lot numbers
        // Read in the source document
        // Example file name: 16034-212234 16034-212236.pdf > 16034-212234.pdf, 16034-212235.pdf, 16034-212236.pdf
        // Create a copy of the orignal source file. We will pick specific pages out below
        for (int j = 0; j < numPages + 1; j++) {
            String FileName = fileNameWithoutExt; /* Dynamic file name */
            PdfCopy copy = new PdfCopy(document,
                    new FileOutputStream(path + "\\" + FileName + "(" + j + 1 + ")" + ".pdf"));
            document.open();
            copy.addPage(
                    copy.getImportedPage(pdfFileReader, constant)); /* Import pages from original document */
            if (j == 1) {
                newFileListing = ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            } else if (j > 1) {
                newFileListing += ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            }
            document.close();
        }
        pdfFileReader.close();
    }
}

From source file:com.tommontom.pdfsplitter.PdfSplit.java

public void pdfSplitDropSupplierDoc(File[] files) throws IOException, DocumentException {
    // TODO Instead of hard code path, pass in as argument

    String path;/*from   w  w w . ja va 2 s . c o m*/
    if (directoryField.getText().isEmpty() || directoryField.getText().equals(example)) {
        path = files[0].getParent();
    } else {
        path = directoryField.getText();
    }
    File[] listOfFiles = files; /* Stores the listing of the files */

    for (int i = 0; i < listOfFiles.length; i++) {
        File file = listOfFiles[i];
        if (!file.isFile()) {
            continue;
        }
        // Split the source filename into its 2 parts
        String fileName = file.getName();
        String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf("."));
        System.out.println(fileNameWithoutExt);
        PdfReader pdfFileReader = new PdfReader(file.getPath());
        Document document = new Document(PageSize.LETTER, 0, 0, 0,
                0); /* instantiates a new document to be made */
        // Determine number of pages by difference of lot numbers
        // Read in the source document
        // Example file name: 16034-212234 16034-212236.pdf > 16034-212234.pdf, 16034-212235.pdf, 16034-212236.pdf
        // Create a copy of the orignal source file. We will pick specific pages out below
        // Split on a space '\s'
        String[] fileNames = fileNameWithoutExt.split("-");

        String fileNameFirst = fileNames[1];
        String fileNameSecond = fileNames[2];
        System.out.println("First lot number: " + fileNameFirst + " Second lot number: " + fileNameSecond);
        // Project num is always the 1st part
        String projectNum = fileNames[0];
        if (!projectNum.equals(fileNames[0])) {
            throw new RuntimeException("Filename needs to be renamed to the correct format");
        }

        // Strip off the first and second lot number, parse into integers
        int firstLotNum;
        int secondLotNum;
        firstLotNum = Integer.parseInt(fileNameFirst);
        secondLotNum = Integer.parseInt(fileNameSecond);
        int numPages = secondLotNum - firstLotNum;
        // Create a copy of the orignal source file. We will pick specific pages out below
        document.open();
        for (int j = 1; j < numPages + 1; j++) {
            String FileName = projectNum + "-" + (firstLotNum) + ".pdf"; /* Dynamic file name */
            firstLotNum++;
            document = new Document(PageSize.LETTER, 0, 0, 0, 0);
            PdfCopy copy = new PdfCopy(document, new FileOutputStream(path + "\\" + FileName));
            document.open();
            copy.addPage(copy.getImportedPage(pdfFileReader, j)); /* Import pages from original document */

            if (j == 1) {
                newFileListing = ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            } else if (j > 1) {
                newFileListing += ("Created File:" + path + FileName + "(" + j + ")" + ".pdf" + "\n");
            }
            document.close();
        }
    }
}

From source file:com.tommontom.pdfsplitter.PdfSplit.java

public void pdfEven(String path) throws IOException, DocumentException {

    String DEFAULT_PATH = path; // TODO Instead of hard code path, pass in as argument
    File folder = new File(DEFAULT_PATH);
    FileNameFilter FileFilter = new FileNameFilter();
    File[] listOfFiles = folder.listFiles(FileFilter); /* Stores the listing of the files */

    for (int i = 0; i < listOfFiles.length; i++) {
        File file = listOfFiles[i];
        if (!file.isFile()) {
            continue;
        }/*from  w  w w . j  a v  a  2 s.com*/

        // Split the source filename into its 2 parts
        String fileName = file.getName();
        String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf("."));

        // Split on a space '\s'
        String[] fileNames = fileNameWithoutExt.split("\\s");
        if (fileNames.length != 2) {
            throw new RuntimeException("File name format is not in right format");
        }

        String fileNameFirst = fileNames[0];
        String fileNameSecond = fileNames[1];
        System.out.println("First lot number: " + fileNameFirst + " Second lot number: " + fileNameSecond);
        String[] fileNameFirstParts = fileNameFirst.split("-");
        String[] fileNameSecondParts = fileNameSecond.split("-");

        // Project num is always the 1st part
        String projectNum = fileNameFirstParts[0];
        if (!projectNum.equals(fileNameSecondParts[0])) {
            throw new RuntimeException("Filename needs to be renamed to the correct format");
        }
        // Strip off the first and second lot number, parse into integers
        int firstLotNum;
        int secondLotNum;
        firstLotNum = Integer.parseInt(fileNameFirstParts[1]);
        secondLotNum = Integer.parseInt(fileNameSecondParts[1]);

        // Determine number of pages by difference of lot numbers
        // Read in the source document
        // Example file name: 16034-212234 16034-212236.pdf > 16034-212234.pdf, 16034-212235.pdf, 16034-212236.pdf
        PdfReader pdfFileReader = new PdfReader(file.getPath());
        int mod = pdfFileReader.getNumberOfPages() % 2;
        if (pdfFileReader.equals(mod)) {
            throw new RuntimeException("File is not an even number of pages");
        }
        Document document = new Document(PageSize.LETTER, 0, 0, 0,
                0); /* instantiates a new document to be made */

        int numPages = secondLotNum - firstLotNum + 1;
        int p = 0;
        int j = 1;
        // Create a copy of the orignal source file. We will pick specific pages out below
        document.open();
        while (j < numPages) {
            j++;
            if (j % 2 == 1) {
                j += 1;
            }
            firstLotNum++;
            String FileName = projectNum + "-" + (firstLotNum - 1) + ".pdf"; /* Dynamic file name */

            document = new Document(PageSize.LETTER, 0, 0, 0, 0);
            PdfCopy copy = new PdfCopy(document, new FileOutputStream(DEFAULT_PATH + "//" + FileName));
            if (j == 1) {
                newFileListing = ("Created File:" + DEFAULT_PATH + "//" + FileName + "\n");
            } else if (j > 1) {
                newFileListing += ("Created File:" + DEFAULT_PATH + "//" + FileName + "\n");
            }
            document.open();
            p += 2;
            copy.addPage(copy.getImportedPage(pdfFileReader, j)); /* Import pages from original document */

            copy.addPage(copy.getImportedPage(pdfFileReader, p));
            document.close();

        }
        System.out.println("Number of Documents Created:" + numPages);
        System.out.println("Number of Documents Created:" + listOfFiles[i]);
    }
}