| | 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 | /// |
| | 506 | gboolean |
| | 507 | PDFDocument::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; |