@Override
   public final void onEndPage(PdfWriter writer, Document document) {
      super.onEndPage(writer, document);
      sanitize(writer);
      try {
         if (failuresHereAfter || debugHereAfter) {
            PdfContentByte bg = writer.getDirectContentUnder();
            Rectangle rect = writer.getPageSize();
            rect.setBackgroundColor(itextHelper.fromColor(getSettings().getColorProperty(new Color(240, 240, 240), "legendbackground")));
            bg.rectangle(rect);
            bg.closePathFillStroke();
         } else {
            for (Advanced a : doForAllPages) {
               try {
                  if (a.shouldDraw(null)) {
                     a.draw(document.getPageSize(), null);
                  }
               } catch (VectorPrintException ex) {
                  throw new VectorPrintRuntimeException(ex);
               }
            }
         }
         if (!debugHereAfter && getSettings().getBooleanProperty(false, DEBUG)) {
            
            PdfContentByte canvas = writer.getDirectContent();
            
            Rectangle rect = new Rectangle(document.leftMargin(),
                document.bottomMargin(),
                document.right() - document.rightMargin(),
                document.top() - document.topMargin());
            
            DebugHelper.debugRect(canvas, rect, new float[]{10, 2}, 0.3f, getSettings(), stylerFactory.getLayerManager());
            
         }
         
         renderHeader(writer, document);
         maxTagForGenericTagOnPage = ((DefaultElementProducer) elementProducer).getAdvancedTag();
         if (getSettings().getBooleanProperty(Boolean.FALSE, ReportConstants.PRINTFOOTER)) {
            renderFooter(writer, document);
         } else {
            log.warning("not printing footer, if you want page footers set " + ReportConstants.PRINTFOOTER + " to true");
         }
         maxTagForGenericTagOnPage = Integer.MAX_VALUE;
      } catch (VectorPrintException | DocumentException | InstantiationException | IllegalAccessException e) {
         throw new VectorPrintRuntimeException("failed to create the report header or footer: ", e);
      }
   }
@ Override public final void onEndPage ( PdfWriter writer , Document document ) { super . onEndPage ( writer , document ) ; sanitize ( writer ) ; try { if ( failuresHereAfter || debugHereAfter ) { PdfContentByte bg = writer . getDirectContentUnder ( ) ; Rectangle rect = writer . getPageSize ( ) ; rect . setBackgroundColor ( itextHelper . fromColor ( getSettings ( ) . getColorProperty ( new Color ( 240 , 240 , 240 ) , "legendbackground" ) ) ) ; bg . rectangle ( rect ) ; bg . closePathFillStroke ( ) ; } else { for ( Advanced a : doForAllPages ) { try { if ( a . shouldDraw ( null ) ) { a . draw ( document . getPageSize ( ) , null ) ; } } catch ( VectorPrintException ex ) { throw new VectorPrintRuntimeException ( ex ) ; } } } if ( ! debugHereAfter && getSettings ( ) . getBooleanProperty ( false , DEBUG ) ) { PdfContentByte canvas = writer . getDirectContent ( ) ; Rectangle rect = new Rectangle ( document . leftMargin ( ) , document . bottomMargin ( ) , document . right ( ) - document . rightMargin ( ) , document . top ( ) - document . topMargin ( ) ) ; DebugHelper . debugRect ( canvas , rect , new float [ ] { 10 , 2 } , 0.3f , getSettings ( ) , stylerFactory . getLayerManager ( ) ) ; } renderHeader ( writer , document ) ; maxTagForGenericTagOnPage = ( ( DefaultElementProducer ) elementProducer ) . getAdvancedTag ( ) ; if ( getSettings ( ) . getBooleanProperty ( Boolean . FALSE , ReportConstants . PRINTFOOTER ) ) { renderFooter ( writer , document ) ; } else { log . warning ( "not printing footer, if you want page footers set " + ReportConstants . PRINTFOOTER + " to true" ) ; } maxTagForGenericTagOnPage = Integer . MAX_VALUE ; } catch ( VectorPrintException | DocumentException | InstantiationException | IllegalAccessException e ) { throw new VectorPrintRuntimeException ( "failed to create the report header or footer: " , e ) ; } }
prints debug info when property debug is true, calls renderHeader and renderFooter and
{@link Advanced#draw(com.itextpdf.text.Rectangle, java.lang.String) } with {@link Document#getPageSize() }
and null for {@link DefaultStylerFactory#PAGESTYLERS}.

@param writer
@param document