Determining Paper Size

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
rsb
Experienced Solver
Experienced Solver
Posts: 91
Joined: Fri May 29, 2015 7:26 pm

Determining Paper Size

Postby rsb » Tue Jul 11, 2017 4:51 pm

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
Last edited by doublemax on Tue Jul 11, 2017 5:26 pm, edited 1 time in total.
Reason: Added code tags

rsb
Experienced Solver
Experienced Solver
Posts: 91
Joined: Fri May 29, 2015 7:26 pm

Re: Determining Paper Size

Postby rsb » Tue Jul 11, 2017 4:53 pm

Also, We're using wxWidgets 3.1.0

utelle
Moderator
Moderator
Posts: 756
Joined: Tue Jul 05, 2005 10:00 pm
Location: Cologne, Germany
Contact:

Re: Determining Paper Size

Postby utelle » Tue Jul 11, 2017 8:47 pm

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


Return to “wxCode”

Who is online

Users browsing this forum: No registered users and 1 guest