Skip to content

Commit

Permalink
Minor changes for #334 - tabs replaced with spaces, etc.
Browse files Browse the repository at this point in the history
I'm the worst offender with tabs but they are evil!
  • Loading branch information
danfickle committed Mar 17, 2019
1 parent 6eb8f44 commit c605ec1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@
*/
package com.openhtmltopdf.pdfboxout;

import java.awt.geom.Rectangle2D;

import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.common.PDRectangle;

/**
* Callback listener for PDF creation. To use this, call {@link PdfBoxRenderer#setListener(PDFCreationListener)}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public interface PageSupplier {
* @param doc
* {@link PDDocument} the page belongs to
* @param pageWidth
* Width of page
* Width of page in PDF points (1/72 inch)
* @param pageHeight
* Height of page
* Height of page in PDF points
* @param pageNumber
* Number of the page
* Number of the layout page - this may differ from the PDF document page if there are previous shadow pages.
* @param shadowPageNumber
* Number of the shadow-page
* Number of the shadow-page or -1 if on a main page.
* @return {@link PDPage}
*/
PDPage requestPage(PDDocument doc, float pageWidth, float pageHeight, int pageNumber, int shadowPageNumber);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.openhtmltopdf.bidi.SimpleBidiReorderer;
import com.openhtmltopdf.context.StyleReference;
import com.openhtmltopdf.css.constants.IdentValue;
import com.openhtmltopdf.css.parser.property.PrimitivePropertyBuilders.Page;
import com.openhtmltopdf.css.style.CalculatedStyle;
import com.openhtmltopdf.extend.*;
import com.openhtmltopdf.layout.BoxBuilder;
Expand Down Expand Up @@ -626,24 +625,34 @@ private void writePDFFast(List<PageBox> pages, RenderingContext c, Rectangle2D f

for (DisplayListPageContainer shadowPage : pageOperations.shadowPages()) {
PDPage shadowPdPage =
_pageSupplier.requestPage(doc, (float) currentPage.getWidth(c) / _dotsPerPoint, (float) currentPage.getHeight(c) / _dotsPerPoint, i, shadowPageIndex);
_pageSupplier.requestPage(
doc,
(float) currentPage.getWidth(c) / _dotsPerPoint,
(float) currentPage.getHeight(c) / _dotsPerPoint, i, shadowPageIndex);

PDPageContentStream shadowCs = new PDPageContentStream(doc, shadowPdPage, AppendMode.APPEND, !_testMode);

_outputDevice.initializePage(shadowCs, shadowPdPage, (float) currentPage.getHeight(c) / _dotsPerPoint);
c.setShadowPageNumber(shadowPageIndex);
paintPageFast(c, currentPage, shadowPage, -translateX);
_outputDevice.finishPage();
translateX += (pageContentWidth * (currentPage.getCutOffPageDirection() == IdentValue.LTR ? 1 : -1));

pdfPageIndex++;
shadowPageIndex++;
}
}

if (i != pageCount - 1) {
PageBox nextPage = pages.get(i + 1);
Rectangle2D nextPageSize = new Rectangle2D.Float(0, 0, nextPage.getWidth(c) / _dotsPerPoint,

Rectangle2D nextPageSize = new Rectangle2D.Float(0, 0,
nextPage.getWidth(c) / _dotsPerPoint,
nextPage.getHeight(c) / _dotsPerPoint);

PDPage pageNext =
_pageSupplier.requestPage(doc, (float) nextPageSize.getWidth(), (float) nextPageSize.getHeight(), pdfPageIndex, -1);
_pageSupplier.requestPage(doc, (float) nextPageSize.getWidth(), (float) nextPageSize.getHeight(), i + 1, -1);

PDPageContentStream csNext = new PDPageContentStream(doc, pageNext, AppendMode.APPEND, !_testMode);
_outputDevice.initializePage(csNext, pageNext, (float) nextPageSize.getHeight());
}
Expand All @@ -656,7 +665,7 @@ private void writePDF(List<PageBox> pages, RenderingContext c, Rectangle2D first
_outputDevice.setRoot(_root);
_outputDevice.start(_doc);

PDPage page = _pageSupplier.requestPage(doc, (float) firstPageSize.getWidth(), (float) firstPageSize.getHeight(), 1, -1);
PDPage page = _pageSupplier.requestPage(doc, (float) firstPageSize.getWidth(), (float) firstPageSize.getHeight(), 0, -1);
PDPageContentStream cs = new PDPageContentStream(doc, page, AppendMode.APPEND, !_testMode);

_outputDevice.initializePage(cs, page, (float) firstPageSize.getHeight());
Expand Down

0 comments on commit c605ec1

Please sign in to comment.