Page 1 of 1

Determining Paper Size

Posted: Tue Jul 11, 2017 4:51 pm
by rsb
Hello,

How do you determine the page size for a PDF document. In the class wxPrintData, there's a wxSize variable m_paperSize that's
initialized to -1, -1. After setting the paper type and orientation using the page setup dialog, this variable is not updated
but it is updated when printing to a Printer. Also, the wxPdfPrintData object doesn't have a paper size variable, not sure why.

Here's a snippet of code we're using:

Code: Select all

    wxPrintData &printData = GetPrintData() ; // Stored in the frame class

    wxPrintDialogData initPrintDialogData(printData);
    wxPdfPrinter printer(&initPrintDialogData);

    if( !printer.PrintDialog(pFrame) )
    {
        return ;
    }

    wxPageSetupDialogData &pageSetupDialogData = GetPageSetupDialogData() ; // Stored in the frame class

    wxPdfPageSetupDialog setupDialog(pFrame, &pageSetupDialogData);

    if( setupDialog.ShowModal() != wxID_OK )
    {
        return ;
    }
    wxPrintData &printData = setupDialog.GetPageSetupData().GetPrintData();
When we use a wxPrinter object instead of a wxPdfPrinter object, the paper size is initialized.

Is this by design and if so how does the wxPdfDC know the size of the paper it's printing on.

Thanks.

Windows 7, Visual Studio 2015

Re: Determining Paper Size

Posted: Tue Jul 11, 2017 4:53 pm
by rsb
Also, We're using wxWidgets 3.1.0

Re: Determining Paper Size

Posted: Tue Jul 11, 2017 8:47 pm
by utelle
rsb wrote:How do you determine the page size for a PDF document. In the class wxPrintData, there's a wxSize variable m_paperSize that's
initialized to -1, -1. After setting the paper type and orientation using the page setup dialog, this variable is not updated
but it is updated when printing to a Printer. Also, the wxPdfPrintData object doesn't have a paper size variable, not sure why.
Well, most of the wxPdfDC code and its integration with the wxWidgets printing framework was contributed by Mark Dootson. Obviously he decided to use the paper id only to determine the page size and to initialize the page size of the underlying wxPdfDocument object. And this was certainly influenced by the fact that the default wxPageSetupDialog displays just a list of paper ids for selection by the user. That is, the user can't choose an arbitrary page size.
rsb wrote:When we use a wxPrinter object instead of a wxPdfPrinter object, the paper size is initialized.
Sorry, it's not clear what you mean with "the paper size is initialized". Of which's paper size are you talking?
rsb wrote:Is this by design and if so how does the wxPdfDC know the size of the paper it's printing on.
wxPdfDC uses the paper id from the wxPrintData object to set up the page size of the underlying wxPdfDocument. The default is DIN A4 (wxPAPER_A4).

Regards,

Ulrich