Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:

Hi People,

I am using the Wx::RichText framework, which is more or less doing what I want from it, however, I'd like to create a PDF file from my RichTextBuffer.

There is a wxPdfDocument structure in wxWidgets, but it is unwrapped, so I thought it would be easier to use the Wx print framework instead.

The issue is that if I call the print dialogue everything works fine, and I can create a PDF with no problem, however (as I want it to be transparent to the user), when I do it bypassing the print dialogue, it doesn't work.

Code follows at end.

My question is:

  1. does anyone have background (or at least dialogue-less) printing working for any printer type?
  2. does anyone have an alternative method for creating PDFs from wxXML objects? Or anything else?
  3. am I using the print framework commands properly?

As always, many thanks for your ideas.

Regards

Steve

my $loc_pdf_printdata = $self->{Ctl_RTC_Printing_Obj}->GetPrintData; $loc_pdf_printdata->SetOrientation( wxPORTRAIT ); $loc_pdf_printdata->SetNoCopies(1); $loc_pdf_printdata->SetPaperId( wxPAPER_A4 ); $loc_pdf_printdata->SetPrinterName("Virtual_PDF_Printer"); # This i +s the name of the Printer as it appears in cups on localhost:631. my $loc_printdialogdata = Wx::PrintDialogData->new(); $loc_printdialogdata->SetPrintData($loc_pdf_printdata); my $loc_pdf_printout = Wx::Printout->new("PDF Report"); my $loc_wxPrinter = Wx::Printer->new($loc_printdialogdata); my $loc_success = $loc_wxPrinter->Print( undef, $loc_pdf_printout, 0 + ); print $loc_success.";

# Print $loc_success returns "1".

  • Comment on Wx::Perl, background printing, PDF document creation and PDF file names.
  • Download Code

Replies are listed 'Best First'.
Re: Wx::Perl, background printing, PDF document creation and PDF file names.
by Anonymous Monk on Mar 14, 2012 at 13:46 UTC

    when I do it bypassing the print dialogue, it doesn't work.

    And the error message is?

      Good question,

      no segfault, no crash, no error message, printed flag returns 1, but no entry on the printer queue and if I do a search of the whole root directory for *.pdf, no pdf file printed within the previous few minutes.

      Regards

      Steve

        no segfault, no crash, no error message

        Not possible :) Wx::LogWindow->new(undef,-1,1);