Extra blank page when converting HTML to PDF using abcPDF

前端 未结 8 1260
花落未央
花落未央 2020-12-30 08:40

I have an HTML report, with each print page contained by a

. The page class is defined as

width: 180mm;
height: 250mm         


        
8条回答
  •  [愿得一人]
    2020-12-30 09:37

    protected void RemoveBlankPages(Doc pdf)
    {
        for (int i = pdf.PageCount; i > 0; i--)
        {
            pdf.PageNumber = i;
    
            //get the pdf content
            string textContent = pdf.GetText("Text");
    
            //delete the page if it is blank
            if (string.IsNullOrEmpty(textContent))
                pdf.Delete(pdf.Page);
        }
    }
    

提交回复
热议问题