wpfprintingsystem.printingdocumentpaginator

White spaces appear around the document to preview


I have WPF Application which use printing. I have class inherite from "DocumentPaginator"

class ReportPaginator : DocumentPaginator
{
    private Size pageSize;

    public override IDocumentPaginatorSource Source
    {
        get { return null; }
    }

    public override bool IsPageCountValid
    {
        get { return true; }
    }

    public override int PageCount
    {
        get { return pageCount; }
    }

    public override Size PageSize
    {
        get { return pageSize; }
        set
        {
            if (value != null)
            {
                pageSize = value;
                CalculatesPage();
            }
        }
    }

    public override DocumentPage GetPage(int pageNumber)
    {
       // some code.
    }  
}

When I get FixedDocumentSequence from this paginator to preview the document before printing. the "pageSize" property did NOT applied for this DocumentPage, and there is white spaces around the pages How can I solve this problem


Solution

  • Just for the case if some one had the same problem of this.
    My problem was in the my own code [specifically the part that generate the Page in the GetPage() method], I was generating white spaces around the page itself when implement GetPage method.

    if you are having same problem, may be double-checking GetPage method may be helpful.