wxIScan
wxIScanSmartHocr2Pdf Class Reference

Traverse recursively through the DOM tree beginning with the given node. More...

#include <wxiscanhocr2pdf.h>

Inheritance diagram for wxIScanSmartHocr2Pdf:
wxIScanHocr2Pdf

List of all members.

Public Member Functions

 wxIScanSmartHocr2Pdf (wxXmlDocument *poXmlDoc, wxPdfDocument *poPdfDoc, int nResolution, const wxString &strHocrClassFilter=wxT("ocr_line"))
 DOM tree traverser class for wxIScanFrame::AddPdfPage() based on wxIScanFrameHocr2Pdf class to achieve a "smarter" word based PDF output hidden behind the image.

Protected Member Functions

virtual void Print2Pdf (double x, double y, const wxString &strText)
 Print the given text at the given coordinates.
virtual void Flush2Pdf ()
 Flush outstanding print-to-PDF-commands.

Protected Attributes

double m_x
double m_y
 Save printing coordinates.
wxString m_strText
 Save outstanding text.

Detailed Description

Traverse recursively through the DOM tree beginning with the given node.

This class extends wxIScanHocr2Pdf by "smart" glueing the letters of one word together. This makes it easer to search a PDF document for words (instead of single) letters).

NOTE:

1) This is some sort of a "private" class to wxIScanFrame and should not be used outside wxIScanFrame::AddPdfPage().

2) There is no validity check done on poXmlDoc, poPdfDoc and nResolution. That is it is assumed that all parameters of the constructor are valid.

Definition at line 121 of file wxiscanhocr2pdf.h.


Constructor & Destructor Documentation

wxIScanSmartHocr2Pdf::wxIScanSmartHocr2Pdf ( wxXmlDocument *  poXmlDoc,
wxPdfDocument *  poPdfDoc,
int  nResolution,
const wxString &  strHocrClassFilter = wxT( "ocr_line" ) 
)

DOM tree traverser class for wxIScanFrame::AddPdfPage() based on wxIScanFrameHocr2Pdf class to achieve a "smarter" word based PDF output hidden behind the image.

Parameters:
poXmlDocthe (valid!) pointer to the XML DOM tree
poPdfDocthe (valid!) pointer to the PDF document
nResolutionthe (virtual) resolution of the image
strHocrClassFilterthe class to use for hOCR information (e. g. whole lines or words)

Definition at line 122 of file wxiscanhocr2pdf.cpp.

References m_strText, and m_y.

  : wxIScanHocr2Pdf( poXmlDoc, poPdfDoc, nResolution, strHocrClassFilter )
{
    // Clear the collection buffer.
    m_strText.Empty();

    // Reset ...
    m_y= -1.0;
}

Member Function Documentation

void wxIScanSmartHocr2Pdf::Flush2Pdf ( ) [protected, virtual]

Flush outstanding print-to-PDF-commands.

NOTE: This function does the real printing initialized by (maybe multiple) calls to Print2Pdf().

Reimplemented from wxIScanHocr2Pdf.

Definition at line 156 of file wxiscanhocr2pdf.cpp.

References wxIScanHocr2Pdf::m_poPdfDoc, m_strText, m_x, and m_y.

{
    if( m_y >= 0.0 )
    {
        // "Print" the collected text.
        m_poPdfDoc->Text( m_x, m_y, m_strText );

        // Empty the collection buffer.
        m_strText.Empty();

        // Reset...
        m_y= -1.0;
    }
}
void wxIScanSmartHocr2Pdf::Print2Pdf ( double  x,
double  y,
const wxString &  strText 
) [protected, virtual]

Print the given text at the given coordinates.

Parameters:
xabscissa of the origin
yordinate of the origin
strTexttext to print

NOTE: This function only collects text until Flush2Pdf() is called.

Reimplemented from wxIScanHocr2Pdf.

Definition at line 138 of file wxiscanhocr2pdf.cpp.

References m_strText, m_x, and m_y.

{
    // ...
    if( m_y < 0.0 )
    {
        m_x= x;
        m_y= y;
    }

    // Add the new text to the already collected text.
    m_strText += strText;
}

Member Data Documentation

wxString wxIScanSmartHocr2Pdf::m_strText [protected]

Save outstanding text.

Definition at line 158 of file wxiscanhocr2pdf.h.

Referenced by Flush2Pdf(), Print2Pdf(), and wxIScanSmartHocr2Pdf().

double wxIScanSmartHocr2Pdf::m_x [protected]

Definition at line 157 of file wxiscanhocr2pdf.h.

Referenced by Flush2Pdf(), and Print2Pdf().

double wxIScanSmartHocr2Pdf::m_y [protected]

Save printing coordinates.

Definition at line 157 of file wxiscanhocr2pdf.h.

Referenced by Flush2Pdf(), Print2Pdf(), and wxIScanSmartHocr2Pdf().


The documentation for this class was generated from the following files: