Esempio n. 1
0
        /* (non-Javadoc)
         * @see com.itextpdf.layout.renderer.DocumentRenderer#addNewPage(com.itextpdf.kernel.geom.PageSize)
         */
        protected override PageSize AddNewPage(PageSize customPageSize)
        {
            PdfPage addedPage;
            int     pageNumber = document.GetPdfDocument().GetNumberOfPages() + 1;
            PageContextProcessor nextProcessor = GetPageProcessor(pageNumber);

            if (customPageSize != null)
            {
                addedPage = document.GetPdfDocument().AddNewPage(customPageSize);
            }
            else
            {
                addedPage = document.GetPdfDocument().AddNewPage(nextProcessor.GetPageSize());
            }
            nextProcessor.ProcessNewPage(addedPage);
            float[] margins = nextProcessor.ComputeLayoutMargins();
            BodyHtmlStylesContainer[] styles = new BodyHtmlStylesContainer[] { ((IPropertyContainer)document).GetProperty
                                                                               <BodyHtmlStylesContainer>(Html2PdfProperty.HTML_STYLING), ((IPropertyContainer)document).GetProperty <BodyHtmlStylesContainer
                                                                                                                                                                                     >(Html2PdfProperty.BODY_STYLING) };
            pageStylesPropertiesMap.Put(pageNumber, new HtmlBodyStylesApplierHandler.PageStylesProperties(styles));
            UpdateDefaultMargins(styles, margins);
            SetProperty(Property.MARGIN_TOP, margins[0]);
            SetProperty(Property.MARGIN_RIGHT, margins[1]);
            SetProperty(Property.MARGIN_BOTTOM, margins[2]);
            SetProperty(Property.MARGIN_LEFT, margins[3]);
            return(new PageSize(addedPage.GetTrimBox()));
        }
 /* (non-Javadoc)
 * @see com.itextpdf.layout.renderer.DocumentRenderer#addNewPage(com.itextpdf.kernel.geom.PageSize)
 */
 protected override PageSize AddNewPage(PageSize customPageSize) {
     PdfPage addedPage;
     int numberOfPages = document.GetPdfDocument().GetNumberOfPages();
     PageContextProcessor nextProcessor = GetPageProcessor(numberOfPages + 1);
     if (customPageSize != null) {
         addedPage = document.GetPdfDocument().AddNewPage(customPageSize);
     }
     else {
         addedPage = document.GetPdfDocument().AddNewPage(nextProcessor.GetPageSize());
     }
     nextProcessor.ProcessNewPage(addedPage);
     float[] margins = nextProcessor.ComputeLayoutMargins();
     ApplyHtmlBodyStyles(addedPage, margins);
     SetProperty(Property.MARGIN_TOP, margins[0]);
     SetProperty(Property.MARGIN_RIGHT, margins[1]);
     SetProperty(Property.MARGIN_BOTTOM, margins[2]);
     SetProperty(Property.MARGIN_LEFT, margins[3]);
     return new PageSize(addedPage.GetTrimBox());
 }