Show
Ignore:
Timestamp:
06/05/06 08:41:08 (2 years ago)
Author:
jordi
Message:

Added the option to save a copy of the currently loaded document.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/PDFDocument.cxx

    r196 r200  
    181181    // Try to open the PDF document. 
    182182    GError *loadError = NULL; 
    183     PopplerDocument *newDocument =  
     183    PopplerDocument *newDocument = 
    184184        poppler_document_new_from_file (filename_uri, password, &loadError); 
    185185    g_free (filename_uri); 
     
    262262    gchar *subject = NULL; 
    263263    gchar *title = NULL; 
    264     
     264 
    265265    g_object_get (m_Document, 
    266266            "author", &author, 
     
    461461        return NULL; 
    462462    } 
    463      
     463 
    464464    // First create the document's page. 
    465465    gdouble pageWidth; 
     
    488488    } 
    489489    g_object_unref (pixbuf); 
    490      
     490 
    491491    return (renderedPage); 
     492} 
     493 
     494/// 
     495/// @brief Saves a document's copy to a file. 
     496/// 
     497/// Tries to save the document to file @a filename. 
     498/// 
     499/// @param filename The path, absolute or relative, to the file name 
     500///                 to save the copy to. 
     501/// @param error Location to store any error that could happen or 
     502///              set to NULL to ignore errors. 
     503/// 
     504/// @return TRUE if the file could be saved. FALSE otherwise. 
     505/// 
     506gboolean 
     507PDFDocument::saveFile (const gchar *filename, GError **error) 
     508{ 
     509    g_assert (NULL != m_Document && "No document loaded yet."); 
     510    g_assert (NULL != filename && "Tried to save to a NULL file name."); 
     511 
     512    gchar *absoluteFileName = getAbsoluteFileName (filename); 
     513    gchar *filename_uri = g_filename_to_uri (absoluteFileName, NULL, error); 
     514    g_free (absoluteFileName); 
     515    if ( NULL == filename_uri ) 
     516    { 
     517        return FALSE; 
     518    } 
     519    // Try to save the PDF document. 
     520    gboolean result = poppler_document_save (m_Document, filename_uri, error); 
     521    g_free (filename_uri); 
     522 
     523    return result; 
    492524} 
    493525