Show
Ignore:
Timestamp:
06/11/06 14:46:38 (2 years ago)
Author:
jordi
Message:

Added a new class named JobPrint? whose duty is to render the current document to PostScript? and print the resultant file. It already renders the requested pages (Note: the setUpPageRange is horrible) to PostScript?.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/PDFDocument.cxx

    r209 r222  
    3939{ 
    4040    m_Document = NULL; 
     41    m_PostScript = NULL; 
    4142} 
    4243 
     
    4748{ 
    4849    clearCache (); 
     50    outputPostscriptEnd (); 
    4951    if ( NULL != m_Document ) 
    5052    { 
     
    5254        m_Document = NULL; 
    5355    } 
     56} 
     57 
     58IDocument * 
     59PDFDocument::copy () const 
     60{ 
     61    // Making a deep copy is just making a new document and loading the same 
     62    // file. 
     63    PDFDocument *newDocument = new PDFDocument (); 
     64    newDocument->loadFile (getFileName (), getPassword (), NULL); 
     65 
     66    return newDocument; 
    5467} 
    5568 
     
    474487} 
    475488 
     489void 
     490PDFDocument::outputPostscriptBegin (const gchar *fileName, guint numOfPages, 
     491                                    gfloat pageWidth, gfloat pageHeight) 
     492{ 
     493    if ( NULL != m_Document ) 
     494    { 
     495        if ( NULL != m_PostScript ) 
     496        { 
     497            outputPostscriptEnd (); 
     498        } 
     499        m_PostScript = 
     500            poppler_ps_file_new (m_Document, fileName, 0, numOfPages); 
     501        if ( NULL != m_PostScript ) 
     502        { 
     503            poppler_ps_file_set_paper_size (m_PostScript, 
     504                                            pageWidth, pageHeight); 
     505        } 
     506    } 
     507} 
     508 
     509void 
     510PDFDocument::outputPostscriptEnd () 
     511{ 
     512    if ( NULL != m_PostScript ) 
     513    { 
     514        poppler_ps_file_free (m_PostScript); 
     515        m_PostScript = NULL; 
     516    } 
     517} 
     518 
     519void 
     520PDFDocument::outputPostscriptPage (guint pageNum) 
     521{ 
     522    if ( NULL != m_Document && NULL != m_PostScript ) 
     523    { 
     524        PopplerPage *page = poppler_document_get_page (m_Document, pageNum - 1); 
     525        if ( NULL != page ) 
     526        { 
     527            poppler_page_render_to_ps (page, m_PostScript); 
     528        } 
     529    } 
     530} 
     531 
     532 
    476533/// 
    477534/// @brief Renders a document's page.