Example usage for org.apache.pdfbox.pdmodel PDPage setRotation

List of usage examples for org.apache.pdfbox.pdmodel PDPage setRotation

Introduction

In this page you can find the example usage for org.apache.pdfbox.pdmodel PDPage setRotation.

Prototype

public void setRotation(int rotation) 

Source Link

Document

This will set the rotation for this page.

Usage

From source file:org.sejda.impl.pdfbox.component.PdfRotator.java

License:Apache License

/**
 * apply the rotation to the given page if necessary
 * /*from  w w w.j ava2  s .co m*/
 * @param pageNmber
 */
private void apply(int pageNmber) {
    if (pages.contains(pageNmber)) {
        PDPage page = (PDPage) document.getDocumentCatalog().getAllPages().get(pageNmber - 1);
        page.setRotation(rotation.addRotation(getRotation(page.findRotation())).getDegrees());
    }
}

From source file:org.wso2.carbon.apimgt.impl.reportgen.ReportGenerator.java

License:Open Source License

/**
 * Generate PDF file for API microgateway request summary
 *
 * @param table object containing table headers and row data
 * @return InputStream pdf as a stream// ww  w. j  a va2  s.com
 * @throws IOException
 * @throws COSVisitorException
 */
public InputStream generateMGRequestSummeryPDF(TableData table) throws IOException, COSVisitorException {

    String[] columnHeaders = table.getColumnHeaders();

    PDDocument document = new PDDocument();
    PDPage page = new PDPage();
    page.setMediaBox(PDPage.PAGE_SIZE_A4);
    page.setRotation(0);
    document.addPage(page);

    PDPageContentStream contentStream = new PDPageContentStream(document, page, false, false);

    // add logo
    InputStream in = APIManagerComponent.class.getResourceAsStream("/report/wso2-logo.jpg");
    PDJpeg img = new PDJpeg(document, in);
    contentStream.drawImage(img, 375, 755);

    // Add topic
    contentStream.setFont(PDType1Font.HELVETICA_BOLD, 16);
    writeContent(contentStream, CELL_MARGIN, 770, "API Microgateway request summary");

    // Add generated time
    contentStream.setFont(PDType1Font.HELVETICA_BOLD, FONT_SIZE);
    writeContent(contentStream, CELL_MARGIN, 730, "Report generated on: " + new Date().toString());

    contentStream.setFont(TEXT_FONT, FONT_SIZE);

    // add table with data
    drowTableGrid(contentStream, table.getRows().size());
    writeRowsContent(contentStream, columnHeaders, table.getRows());

    // Add meta data
    // Whenever the summary report structure is updated this should be changed
    String requestCount = table.getRows().get(0).getEntries().get(2);
    document.getDocumentInformation().setCustomMetadataValue(MGW_META, getMetaCount(requestCount));

    contentStream.close();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    document.save(out);
    document.close();

    return new ByteArrayInputStream(out.toByteArray());

}

From source file:paper2ebook.Transformer.java

License:Apache License

/**
 * Output a PDF with as many pages as there are interesting areas in the
 * input document/*from  w ww .  j av a2 s.c o m*/
 */
@Override
public PDDocument extract() throws IOException {
    PDDocument extractedDocument = new PDDocument();
    extractedDocument.setDocumentInformation(sourceDocument.getDocumentInformation());
    extractedDocument.getDocumentCatalog()
            .setViewerPreferences(sourceDocument.getDocumentCatalog().getViewerPreferences());

    @SuppressWarnings("unchecked")
    List<PDPage> pages = sourceDocument.getDocumentCatalog().getAllPages();
    int pageCounter = 1;
    for (PDPage page : pages) {
        if (pageCounter >= startPage && pageCounter <= endPage) {

            List<PDRectangle> zoomedFragments = getFragments(page);
            for (PDRectangle fragment : zoomedFragments) {
                PDPage outputPage = extractedDocument.importPage(page);
                outputPage.setCropBox(fragment);
                outputPage.setMediaBox(page.getMediaBox());
                outputPage.setResources(page.findResources());
                outputPage.setRotation(page.findRotation());

                // TODO: rotate the page in landscape mode is width > height
            }
        }
        pageCounter++;
    }
    return extractedDocument;
}

From source file:Reports.DROTDataReader.java

public void multiPdfGenerator(String pdfFileNameBase, List<String> cycles)
        throws IOException, COSVisitorException {
    GlobalVar.dirMake(new File(pdfFileNameBase)); //create a folder with the same name                          
    int rowCount = 0;
    int pageCount = 1;
    PDPage page; //default size PAGE_SIZE_A4
    PDPageContentStream stream;/*www  . j a va  2s .co m*/
    //page.setRotation(90); //counterclock wise rotate 90 degree  ////left hand rule

    //        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
    String lastUpdate = null;
    String lastCycle = null;
    System.out.println("DTL_DATA keyset:" + DROT_DATA.keySet());
    System.out.println("Cycles empty? " + cycles.isEmpty() + cycles.size());
    System.out.println(cycles);
    for (String updateDate : DROT_DATA.keySet()) {
        Map<String, List<String>> thisDTData = DROT_DATA.get(updateDate);
        lastUpdate = updateDate;
        System.out.println("thisDT_DATA keyset:" + thisDTData.keySet());
        for (String cycle : thisDTData.keySet()) {
            if (cycles.isEmpty() || cycles.contains(cycle)) {
                PDDocument pdf = new PDDocument();
                lastCycle = cycle;
                List<String> thisCycle = thisDTData.get(cycle);
                pageCount = 1; // new cycle, restart page num
                page = new PDPage(); //page break
                stream = new PDPageContentStream(pdf, page, true, false);
                stream.beginText();
                page.setRotation(PAGE_ROT_DEGREE);
                //stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                addBigFontUpdateNumberAndCycle(updateDate, cycle, stream);
                stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                // stream.setFont(PDType1Font.
                int thisCycleRowCount = 0;
                for (String row : thisCycle) {
                    if (thisCycleRowCount > MAX_NUM_TRANS) {
                        //close the current page
                        setupFootNote(stream, pageCount, cycle, updateDate);
                        pageCount++;
                        stream.endText();
                        stream.close();
                        pdf.addPage(page);

                        // start a new page
                        page = new PDPage();
                        stream = new PDPageContentStream(pdf, page, true, false);
                        page.setRotation(PAGE_ROT_DEGREE);
                        stream.beginText();
                        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                        thisCycleRowCount = 0;
                    }
                    stream.setTextRotation(TEXT_ROT_RAD, TRANS_X + thisCycleRowCount * INVERVAL_X, TRANS_Y);
                    stream.drawString(row);
                    thisCycleRowCount++;
                    //System.out.println("Update:" + updateDate + " Cycle: " + cycle + " " + row);
                }
                setupFootNote(stream, pageCount, lastCycle, lastUpdate);
                stream.endText();
                stream.close();
                pdf.addPage(page);
                String pdfFileName = pdfFileNameBase + "\\DROT UPDT " + updateDate + " " + cycle + ".pdf";

                pdf.save(pdfFileName);
                pdf.close();
            }
        }
    }

    // pdf.save(pdfFileName);        
    // pdf.close();      
}

From source file:Reports.DROTDataReader.java

public void singlePdfGenerator(String pdfFileNameBase, List<String> cycles)
        throws IOException, COSVisitorException {
    GlobalVar.dirMake(new File(pdfFileNameBase)); //create a folder with the same name                          
    int rowCount = 0;
    int pageCount = 1;
    PDDocument pdf = new PDDocument();
    PDPage page; //default size PAGE_SIZE_A4
    PDPageContentStream stream;//from  w w w . ja va 2 s  .  c om
    //page.setRotation(90); //counterclock wise rotate 90 degree  ////left hand rule

    //        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
    String lastUpdate = null;
    String lastInputSource = null;
    System.out.println("DROT_DATA keyset:" + DROT_DATA.keySet());
    //        System.out.println("Cycles empty? " + cycles.isEmpty() + cycles.size());
    //        System.out.println(cycles);
    String pdfFileName = pdfFileNameBase + "\\DROT UPDT";
    for (String updateDate : DROT_DATA.keySet()) {
        Map<String, List<String>> thisDTData = DROT_DATA.get(updateDate);
        lastUpdate = updateDate;
        System.out.println("thisDT_DATA keyset:" + thisDTData.keySet());
        pdfFileName = pdfFileName + " " + updateDate;
        for (String inputSource : thisDTData.keySet()) {
            if (cycles.isEmpty() || cycles.contains(inputSource)) {
                //PDDocument pdf = new PDDocument();    
                lastInputSource = inputSource;
                List<String> thisCycle = thisDTData.get(inputSource);
                pageCount = 1; // new cycle, restart page num
                page = new PDPage(); //page break
                stream = new PDPageContentStream(pdf, page, true, false);
                stream.beginText();
                page.setRotation(PAGE_ROT_DEGREE);
                //stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                addBigFontUpdateNumberAndCycle(updateDate, inputSource, stream);
                stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                // stream.setFont(PDType1Font.
                int thisCycleRowCount = 0;
                for (String row : thisCycle) {
                    if (thisCycleRowCount > MAX_NUM_TRANS) {
                        //close the current page
                        setupFootNote(stream, pageCount, inputSource, updateDate);
                        pageCount++;
                        stream.endText();
                        stream.close();
                        pdf.addPage(page);

                        // start a new page
                        page = new PDPage();
                        stream = new PDPageContentStream(pdf, page, true, false);
                        page.setRotation(PAGE_ROT_DEGREE);
                        stream.beginText();
                        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                        thisCycleRowCount = 0;
                    }
                    stream.setTextRotation(TEXT_ROT_RAD, TRANS_X + thisCycleRowCount * INVERVAL_X, TRANS_Y);
                    stream.drawString(row);
                    thisCycleRowCount++;
                    //System.out.println("Update:" + updateDate + " Cycle: " + cycle + " " + row);
                }
                setupFootNote(stream, pageCount, lastInputSource, lastUpdate);
                stream.endText();
                stream.close();
                pdf.addPage(page);
                //String pdfFileName = pdfFileNameBase + "\\DROT UPDT " + updateDate + " " + cycle + ".pdf";
            }
        }
    }
    if (pdf.getNumberOfPages() > 0) {
        pdfFileName = pdfFileName + ".pdf";
        pdf.save(pdfFileName);
    }
    pdf.close();
}

From source file:Reports.DTLDataReader.java

public void PdfGenerator(String pdfFileNameBase, List<String> cycles) throws IOException, COSVisitorException {
    GlobalVar.dirMake(new File(pdfFileNameBase)); //create a folder with the same name                          
    int rowCount = 0;
    int pageCount = 1;
    PDPage page; //default size PAGE_SIZE_A4
    PDPageContentStream stream;// ww  w . j a  v a  2  s .c  o m
    //page.setRotation(90); //counterclock wise rotate 90 degree  ////left hand rule

    //        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
    String lastUpdate = null;
    String lastCycle = null;
    System.out.println("DTL_DATA keyset:" + DTL_DATA.keySet());
    System.out.println("Cycles empty? " + cycles.isEmpty() + cycles.size());
    System.out.println(cycles);
    for (String updateDate : DTL_DATA.keySet()) {
        Map<String, List<String>> thisDTData = DTL_DATA.get(updateDate);
        lastUpdate = updateDate;
        System.out.println("thisDT_DATA keyset:" + thisDTData.keySet());
        for (String cycle : thisDTData.keySet()) {
            if (cycles.isEmpty() || cycles.contains(cycle)) {
                PDDocument pdf = new PDDocument();
                lastCycle = cycle;
                List<String> thisCycle = thisDTData.get(cycle);
                pageCount = 1; // new cycle, restart page num
                page = new PDPage(); //page break
                stream = new PDPageContentStream(pdf, page, true, false);
                stream.beginText();
                page.setRotation(PAGE_ROT_DEGREE);
                //stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                addBigFontUpdateNumberAndCycle(updateDate, cycle, stream);
                stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                // stream.setFont(PDType1Font.
                int thisCycleRowCount = 0;
                for (String row : thisCycle) {
                    if (thisCycleRowCount > MAX_NUM_TRANS) {
                        //close the current page
                        setupFootNote(stream, pageCount, cycle, updateDate);
                        pageCount++;
                        stream.endText();
                        stream.close();
                        pdf.addPage(page);

                        // start a new page
                        page = new PDPage();
                        stream = new PDPageContentStream(pdf, page, true, false);
                        page.setRotation(PAGE_ROT_DEGREE);
                        stream.beginText();
                        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                        thisCycleRowCount = 0;
                    }
                    stream.setTextRotation(TEXT_ROT_RAD, TRANS_X + thisCycleRowCount * INVERVAL_X, TRANS_Y);
                    stream.drawString(row);
                    thisCycleRowCount++;
                    //System.out.println("Update:" + updateDate + " Cycle: " + cycle + " " + row);
                }
                setupFootNote(stream, pageCount, lastCycle, lastUpdate);
                stream.endText();
                stream.close();
                pdf.addPage(page);
                String pdfFileName = pdfFileNameBase + "\\DTL UPDT " + updateDate + " " + cycle + ".pdf";

                pdf.save(pdfFileName);
                pdf.close();
            }
        }
    }

    // pdf.save(pdfFileName);        
    // pdf.close();      
}

From source file:Reports.LeaveDataReader.java

public void multiPdfGenerator(String pdfFileNameBase, Set<String> inputSources)
        throws IOException, COSVisitorException {
    GlobalVar.dirMake(new File(pdfFileNameBase)); //create a folder with the same name                          
    int rowCount = 0;
    int pageCount = 1;
    System.out.println("passed in " + inputSources);
    PDPage page; //default size PAGE_SIZE_A4
    PDPageContentStream stream;/*www  . ja  v a 2s .  com*/
    //page.setRotation(90); //counterclock wise rotate 90 degree  ////left hand rule

    //        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
    String lastUpdate = null;
    String lastInputSource = null;
    System.out.println("LEAVE_DATA keyset:" + LEAVE_DATA.keySet());
    //        System.out.println("Cycles empty? " + cycles.isEmpty() + cycles.size());
    //        System.out.println(cycles);
    for (String updateDate : LEAVE_DATA.keySet()) {
        Map<String, List<String>> thisDTData = LEAVE_DATA.get(updateDate);
        lastUpdate = updateDate;
        System.out.println("thisDT_DATA keyset:" + thisDTData.keySet());
        for (String inputSource : thisDTData.keySet()) {
            if (inputSources.isEmpty() || inputSources.contains(inputSource)) {
                PDDocument pdf = new PDDocument();
                lastInputSource = inputSource;
                List<String> thisCycle = thisDTData.get(inputSource);
                pageCount = 1; // new cycle, restart page num
                page = new PDPage(); //page break
                stream = new PDPageContentStream(pdf, page, true, false);
                stream.beginText();
                page.setRotation(PAGE_ROT_DEGREE);
                //stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                addBigFontUpdateNumberAndCycle(updateDate, lastInputSource, stream);
                stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                // stream.setFont(PDType1Font.
                int thisCycleRowCount = 0;
                for (String row : thisCycle) {
                    if (thisCycleRowCount > MAX_NUM_TRANS) {
                        //close the current page
                        setupFootNote(stream, pageCount, lastInputSource, updateDate);
                        pageCount++;
                        stream.endText();
                        stream.close();
                        pdf.addPage(page);

                        // start a new page
                        page = new PDPage();
                        stream = new PDPageContentStream(pdf, page, true, false);
                        page.setRotation(PAGE_ROT_DEGREE);
                        stream.beginText();
                        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                        thisCycleRowCount = 0;
                    }
                    stream.setTextRotation(TEXT_ROT_RAD, TRANS_X + thisCycleRowCount * INVERVAL_X, TRANS_Y);
                    stream.drawString(row);
                    thisCycleRowCount++;
                    //System.out.println("Update:" + updateDate + " Cycle: " + cycle + " " + row);
                }
                setupFootNote(stream, pageCount, lastInputSource, lastUpdate);
                stream.endText();
                stream.close();
                pdf.addPage(page);
                String pdfFileName = pdfFileNameBase + "\\LEAVE UPDT " + updateDate + " " + lastInputSource
                        + ".pdf";

                pdf.save(pdfFileName);
                pdf.close();
            }
        }
    }

    // pdf.save(pdfFileName);        
    // pdf.close();      
}

From source file:Reports.LeaveDataReader.java

public void singlePdfGenerator(String pdfFileNameBase, Set<String> inputSources)
        throws IOException, COSVisitorException {
    GlobalVar.dirMake(new File(pdfFileNameBase)); //create a folder with the same name                          
    int rowCount = 0;
    int pageCount = 1;
    System.out.println("passed in " + inputSources);
    PDDocument pdf = new PDDocument();
    PDPage page; //default size PAGE_SIZE_A4
    PDPageContentStream stream;//from  ww  w . j  a va2 s  . co m
    //page.setRotation(90); //counterclock wise rotate 90 degree  ////left hand rule

    //        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
    String lastUpdate = null;
    String lastInputSource = null;
    System.out.println("LEAVE_DATA keyset:" + LEAVE_DATA.keySet());
    //        System.out.println("Cycles empty? " + cycles.isEmpty() + cycles.size());
    //        System.out.println(cycles);

    String pdfFileName = pdfFileNameBase + "\\LEAVE UPDT";
    for (String updateDate : LEAVE_DATA.keySet()) {
        Map<String, List<String>> thisDTData = LEAVE_DATA.get(updateDate);
        lastUpdate = updateDate;
        System.out.println("thisDT_DATA keyset:" + thisDTData.keySet());
        pdfFileName = pdfFileName + " " + updateDate;
        for (String inputSource : thisDTData.keySet()) {
            if (inputSources.isEmpty() || inputSources.contains(inputSource)) {

                lastInputSource = inputSource;
                List<String> thisCycle = thisDTData.get(inputSource);
                pageCount = 1; // new cycle, restart page num
                page = new PDPage(); //page break
                stream = new PDPageContentStream(pdf, page, true, false);
                stream.beginText();
                page.setRotation(PAGE_ROT_DEGREE);
                //stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                addBigFontUpdateNumberAndCycle(updateDate, lastInputSource, stream);
                stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                // stream.setFont(PDType1Font.
                int thisCycleRowCount = 0;
                for (String row : thisCycle) {
                    if (thisCycleRowCount > MAX_NUM_TRANS) {
                        //close the current page
                        setupFootNote(stream, pageCount, lastInputSource, updateDate);
                        pageCount++;
                        stream.endText();
                        stream.close();
                        pdf.addPage(page);

                        // start a new page
                        page = new PDPage();
                        stream = new PDPageContentStream(pdf, page, true, false);
                        page.setRotation(PAGE_ROT_DEGREE);
                        stream.beginText();
                        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                        thisCycleRowCount = 0;
                    }
                    stream.setTextRotation(TEXT_ROT_RAD, TRANS_X + thisCycleRowCount * INVERVAL_X, TRANS_Y);
                    stream.drawString(row);
                    thisCycleRowCount++;
                    //System.out.println("Update:" + updateDate + " Cycle: " + cycle + " " + row);
                }
                setupFootNote(stream, pageCount, lastInputSource, lastUpdate);
                stream.endText();
                stream.close();
                pdf.addPage(page);
            }
        }
    }
    if (pdf.getNumberOfPages() > 0) {
        pdfFileName = pdfFileName + ".pdf";
        pdf.save(pdfFileName);
    }
    pdf.close();
}

From source file:Reports.MgmtNoticesDataReader.java

public void multiPdfGenerator(String pdfFileNameBase, List<String> cycles)
        throws IOException, COSVisitorException {
    GlobalVar.dirMake(new File(pdfFileNameBase)); //create a folder with the same name                          
    int rowCount = 0;
    int pageCount = 1;
    PDPage page; //default size PAGE_SIZE_A4
    PDPageContentStream stream;//from  w w w.  j  a  v  a2  s.c o m
    //page.setRotation(90); //counterclock wise rotate 90 degree  ////left hand rule

    //        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
    String lastUpdate = null;
    String lastCycle = null;
    //        System.out.println("DROT_DATA keyset:" + MGNT_DATA.keySet());
    //        System.out.println("Cycles empty? " + cycles.isEmpty() + cycles.size());
    //        System.out.println(cycles);
    for (String updateDate : MGNT_DATA.keySet()) {
        Map<String, List<String>> thisDTData = MGNT_DATA.get(updateDate);
        lastUpdate = updateDate;
        System.out.println("thisDT_DATA keyset:" + thisDTData.keySet());
        for (String cycle : thisDTData.keySet()) {
            if (cycles.isEmpty() || cycles.contains(cycle)) {
                PDDocument pdf = new PDDocument();
                lastCycle = cycle;
                List<String> thisCycle = thisDTData.get(cycle);
                pageCount = 1; // new cycle, restart page num
                page = new PDPage(); //page break
                stream = new PDPageContentStream(pdf, page, true, false);
                stream.beginText();
                page.setRotation(PAGE_ROT_DEGREE);
                //stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                addBigFontUpdateNumberAndCycle(updateDate, cycle, stream);
                stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                // stream.setFont(PDType1Font.
                int thisCycleRowCount = 0;
                for (String row : thisCycle) {
                    if (thisCycleRowCount > MAX_NUM_TRANS) {
                        //close the current page
                        setupFootNote(stream, pageCount, cycle, updateDate);
                        pageCount++;
                        stream.endText();
                        stream.close();
                        pdf.addPage(page);

                        // start a new page
                        page = new PDPage();
                        stream = new PDPageContentStream(pdf, page, true, false);
                        page.setRotation(PAGE_ROT_DEGREE);
                        stream.beginText();
                        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                        thisCycleRowCount = 0;
                    }
                    stream.setTextRotation(TEXT_ROT_RAD, TRANS_X + thisCycleRowCount * INVERVAL_X, TRANS_Y);
                    stream.drawString(row);
                    thisCycleRowCount++;
                    //System.out.println("Update:" + updateDate + " Cycle: " + cycle + " " + row);
                }
                setupFootNote(stream, pageCount, lastCycle, lastUpdate);
                stream.endText();
                stream.close();
                pdf.addPage(page);
                String pdfFileName = pdfFileNameBase + "\\MGMT NTC UPDT " + updateDate + " " + cycle + ".pdf";

                pdf.save(pdfFileName);
                pdf.close();
            }
        }
    }

    // pdf.save(pdfFileName);        
    // pdf.close();      
}

From source file:Reports.MgmtNoticesDataReader.java

public void singlePdfGenerator(String pdfFileNameBase, List<String> cycles)
        throws IOException, COSVisitorException {
    GlobalVar.dirMake(new File(pdfFileNameBase)); //create a folder with the same name                          
    int rowCount = 0;
    int pageCount = 1;
    PDDocument pdf = new PDDocument();
    PDPage page; //default size PAGE_SIZE_A4
    PDPageContentStream stream;/*w w  w  .  j  a va 2 s .  c  o m*/
    //page.setRotation(90); //counterclock wise rotate 90 degree  ////left hand rule

    //        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
    String lastUpdate = null;
    String lastTrans = null;
    System.out.println("MGNT_DATA keyset:" + MGNT_DATA.keySet());
    //        System.out.println("Cycles empty? " + cycles.isEmpty() + cycles.size());
    //        System.out.println(cycles);
    String pdfFileName = pdfFileNameBase + "\\MGMT NTC UPDT";
    for (String updateDate : MGNT_DATA.keySet()) {
        Map<String, List<String>> thisDTData = MGNT_DATA.get(updateDate);
        lastUpdate = updateDate;
        System.out.println("thisDT_DATA keyset:" + thisDTData.keySet());
        pdfFileName = pdfFileName + " " + updateDate;
        for (String trans : thisDTData.keySet()) {
            if (cycles.isEmpty() || cycles.contains(trans)) {
                //PDDocument pdf = new PDDocument();    
                lastTrans = trans;
                List<String> thisCycle = thisDTData.get(trans);
                pageCount = 1; // new cycle, restart page num
                page = new PDPage(); //page break
                stream = new PDPageContentStream(pdf, page, true, false);
                stream.beginText();
                page.setRotation(PAGE_ROT_DEGREE);
                //stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                addBigFontUpdateNumberAndCycle(updateDate, trans, stream);
                stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                // stream.setFont(PDType1Font.
                int thisCycleRowCount = 0;
                for (String row : thisCycle) {
                    if (thisCycleRowCount > MAX_NUM_TRANS) {
                        //close the current page
                        setupFootNote(stream, pageCount, trans, updateDate);
                        pageCount++;
                        stream.endText();
                        stream.close();
                        pdf.addPage(page);

                        // start a new page
                        page = new PDPage();
                        stream = new PDPageContentStream(pdf, page, true, false);
                        page.setRotation(PAGE_ROT_DEGREE);
                        stream.beginText();
                        stream.setFont(PDType1Font.COURIER, FONT_SIZE);
                        thisCycleRowCount = 0;
                    }
                    stream.setTextRotation(TEXT_ROT_RAD, TRANS_X + thisCycleRowCount * INVERVAL_X, TRANS_Y);
                    stream.drawString(row);
                    thisCycleRowCount++;
                }
                setupFootNote(stream, pageCount, lastTrans, lastUpdate);
                stream.endText();
                stream.close();
                pdf.addPage(page);

            }
        }
    }
    if (pdf.getNumberOfPages() > 0) {
        pdfFileName = pdfFileName + ".pdf";
        pdf.save(pdfFileName);
    }
    pdf.close();
}