private void writePDF(List pages, RenderingContext c, com.lowagie.text.Rectangle firstPageSize, com.lowagie.text.Document doc, PdfWriter writer) throws DocumentException { _outputDevice.setRoot(_root); _outputDevice.start(_doc); _outputDevice.setWriter(writer); _outputDevice.initializePage(writer.getDirectContent(), firstPageSize.getHeight()); _root.getLayer().assignPagePaintingPositions(c, Layer.PAGED_MODE_PRINT); int pageCount = _root.getLayer().getPages().size(); c.setPageCount(pageCount); firePreWrite(pageCount); // opportunity to adjust meta data setDidValues(doc); // set PDF header fields from meta data for (int i = 0; i < pageCount; i++) { if (isTimeouted() || Thread.currentThread().isInterrupted()) throw new RuntimeException("Timeout occured"); PageBox currentPage = (PageBox) pages.get(i); c.setPage(i, currentPage); paintPage(c, writer, currentPage); _outputDevice.finishPage(); if (i != pageCount - 1) { PageBox nextPage = (PageBox) pages.get(i + 1); com.lowagie.text.Rectangle nextPageSize = new com.lowagie.text.Rectangle(0, 0, nextPage.getWidth(c) / _dotsPerPoint, nextPage.getHeight(c) / _dotsPerPoint); doc.setPageSize(nextPageSize); doc.newPage(); _outputDevice.initializePage(writer.getDirectContent(), nextPageSize.getHeight()); } } _outputDevice.finish(c, _root); }
private void writePDF(List pages, RenderingContext c, com.lowagie.text.Rectangle firstPageSize, com.lowagie.text.Document doc, PdfWriter writer) throws DocumentException { _outputDevice.setRoot(_root); _outputDevice.start(_doc); _outputDevice.setWriter(writer); _outputDevice.initializePage(writer.getDirectContent(), firstPageSize.getHeight()); _root.getLayer().assignPagePaintingPositions(c, Layer.PAGED_MODE_PRINT); int pageCount = _root.getLayer().getPages().size(); c.setPageCount(pageCount); firePreWrite(pageCount); // opportunity to adjust meta data setDidValues(doc); // set PDF header fields from meta data for (int i = 0; i < pageCount; i++) { if (isTimeouted() || Thread.currentThread().isInterrupted()) throw new RuntimeException("Timeout occured"); PageBox currentPage = (PageBox) pages.get(i); c.setPage(i, currentPage); paintPage(c, writer, currentPage); _outputDevice.finishPage(); if (i != pageCount - 1) { PageBox nextPage = (PageBox) pages.get(i + 1); com.lowagie.text.Rectangle nextPageSize = new com.lowagie.text.Rectangle(0, 0, nextPage.getWidth(c) / _dotsPerPoint, nextPage.getHeight(c) / _dotsPerPoint); doc.setPageSize(nextPageSize); doc.newPage(); _outputDevice.initializePage(writer.getDirectContent(), nextPageSize.getHeight()); } } _outputDevice.finish(c, _root); }
private void writePDF(List pages, RenderingContext c, com.lowagie.text.Rectangle firstPageSize, com.lowagie.text.Document doc, PdfWriter writer) throws DocumentException { _outputDevice.setRoot(_root); _outputDevice.start(_doc); _outputDevice.setWriter(writer); _outputDevice.initializePage(writer.getDirectContent(), firstPageSize.getHeight()); _root.getLayer().assignPagePaintingPositions(c, Layer.PAGED_MODE_PRINT); int pageCount = _root.getLayer().getPages().size(); c.setPageCount(pageCount); for (int i = 0; i < pageCount; i++) { PageBox currentPage = (PageBox)pages.get(i); c.setPage(i, currentPage); paintPage(c, writer, currentPage); _outputDevice.finishPage(); if (i != pageCount - 1) { PageBox nextPage = (PageBox)pages.get(i+1); com.lowagie.text.Rectangle nextPageSize = new com.lowagie.text.Rectangle( 0, 0, nextPage.getWidth(c) / _dotsPerPoint, nextPage.getHeight(c) / _dotsPerPoint); doc.setPageSize(nextPageSize); doc.newPage(); _outputDevice.initializePage( writer.getDirectContent(), nextPageSize.getHeight()); } } _outputDevice.finish(c, _root); }
PageBox currentPage = (PageBox)pages.get(i); c.setPage(i, currentPage); paintPage(c, writer, currentPage); _outputDevice.finishPage(); if (i != pageCount - 1) {
PageBox currentPage = (PageBox) pages.get(i); c.setPage(i, currentPage); paintPage(c, writer, currentPage); _outputDevice.finishPage(); if (i != pageCount - 1) {