Steve,
Apologies for delay in replying. I wanted to refresh my memory of the
wxWidgets printing framework before replying, but I still have not found
the time.
For the installation of wxPdfDocument we need a method integrated with
Wx::PdfDocument I think.
My original thoughts on finding an existing wxPdfDocument installation
or building a new installation were to copy the methods of
Alien::wxWidgets. However, I now think it would be better to copy the
approach used by Ahmad Zawawi for Wx::Scintilla - always build
wxPdfDocument with Wx::PdfDocument. That way it makes it much simpler to
co-ordinate updates etc.
Regarding actual implementation, ( PdfFile, PdfBuffer, DoPdf etc ), that
seems like a neat solution for you, and given an installation of
wxPdfDocument via Wx::PdfDocument, you should have what you need
regarding having wxPdfDocument available.
As a general approach for an implementation within Wx::PdfDocument, I'm
not sure really. Amending the richtextprint.cpp/.h in the wxWidgets
build isn't really an option for us (unless it is something we could get
accepted upstream - which seems unlikely given it is wxPdfDocument
specific) - we don't always build wxWidgets - we often install
Alien::wxWidgets accepting a system provided wxWidgets. Maintaining and
updating our own entire copy of richtextprint.cpp seems unattractive.
Essentially, what we are trying to do with this bit of the
implementation is dummy up a 'PDF printer driver' - which would only be
one part of a Wx::PdfDocument implementation. The approach that appeals
to me on a first look is to create wxPdfPrinter. We can base this on the
existing wxWidgets code for the generic postscript printer in
src/generic/printps.cpp.
Submit this for inclusion in wxPdfDocument. You don't really need
wxPdfPrinter if you are working in C++ as it is simple to amend existing
C++ code to use a wxPdfDC instead of a wxPrinterDC. But for a script
wrapper like wxPerl it solves a number of problems.
Given a Wx::PdfPrinter class you can use it with any of the printing
implementations in wxWidgets without further amendment.
e.g.
my $print = Wx::PdfPrinter->new($printdata);
# $printdata would contain filename in addition to
# all the other required params
$print->Print($parent, $wxRichtextPrintout, 0);
# should work fine as should
$print->Print($parent, $wxPrintout, 0);
In fact, a working Wx::PdfPrinter should be all you need to get PDF
documents using any Wx::Printout derived implementation.
For the future it would be nice to implement wxPdfPrintDialog based on
existing wxPrintDialog, but for now we would just require passing all
valid info in $printdata;
If you have no objection, I'll write to Mark Wardell and ask if I can be
added to list of Wx::PdfDocument maintainers to get a first
implementation out.
Regards
Mark
On 13/04/2012 12:52, Steve Cookson wrote:
Hi Mark,
I have started a new approach to wxPdfDocument, which I think will be
easier and more suit my purposes.
I have installed the latest version of wxPdfDocument as per its
instructions, but then I call it from wxRichTextPrinting (ie
richtextprint.cpp/.h) with some new methods:
* PdfFile (Corresponding to PrintFile)
* PdfBuffer (Corresponding to PrintBuffer)
* DoPdf (Corresponding to DoPrint)
Then I will just need to add two wrap lines to the Wx::Perl wrap for:
* PdfFile
* PdfBuffer
DoPdf just copies the wxDC to wxPdfDC page by page along with headers
and footers, all of which are already handled by printing.
This creates a way of working which can be expanded for the other Print
methods (and I think there are only 2, normal print and HTML).
It doesn't give you the whole versatility of wxPdfDocument, but I
suspect most people don't need this.
I guess I will need some sort of compiler check to see if wxPdfDocument
is installed. Like:
#if WXPDFDOCS_VERSION_GE(x, y, z )
or something.
Do you know I could do this?
What do you think generally?
Regards
Steve