| 155 | | /// @brief Gets the document's title. |
|---|
| 156 | | /// |
|---|
| 157 | | /// @return The title of the document or an empty string if the document don't |
|---|
| 158 | | /// have a title. |
|---|
| 159 | | /// |
|---|
| 160 | | const gchar * |
|---|
| 161 | | PDFDocument::getTitle () |
|---|
| 162 | | { |
|---|
| 163 | | if ( NULL == m_Title ) |
|---|
| 164 | | { |
|---|
| 165 | | return ""; |
|---|
| 166 | | } |
|---|
| 167 | | return m_Title; |
|---|
| 168 | | } |
|---|
| 169 | | |
|---|
| 170 | | /// |
|---|
| 171 | | /// @brief Gets the document's author. |
|---|
| 172 | | /// |
|---|
| 173 | | /// @return The author of the document or an empty string if the document don't |
|---|
| 174 | | /// have the author name. |
|---|
| 175 | | /// |
|---|
| 176 | | const gchar * |
|---|
| 177 | | PDFDocument::getAuthor () |
|---|
| 178 | | { |
|---|
| 179 | | if ( NULL == m_Author ) |
|---|
| 180 | | { |
|---|
| 181 | | return ""; |
|---|
| 182 | | } |
|---|
| 183 | | return m_Author; |
|---|
| 184 | | } |
|---|
| 185 | | |
|---|
| 186 | | /// |
|---|
| 187 | | /// @brief Gets the document's subject. |
|---|
| 188 | | /// |
|---|
| 189 | | /// @return The subject of the document or an empty string ig the document don't |
|---|
| 190 | | /// have subject. |
|---|
| 191 | | /// |
|---|
| 192 | | const gchar * |
|---|
| 193 | | PDFDocument::getSubject () |
|---|
| 194 | | { |
|---|
| 195 | | if ( NULL == m_Subject ) |
|---|
| 196 | | { |
|---|
| 197 | | return ""; |
|---|
| 198 | | } |
|---|
| 199 | | return m_Subject; |
|---|
| 200 | | } |
|---|
| 201 | | |
|---|
| 202 | | /// |
|---|
| 203 | | /// @brief Gets the document's keywords. |
|---|
| 204 | | /// |
|---|
| 205 | | /// @return An string with all keywords separated by whitespace, or an empty |
|---|
| 206 | | /// string if the document have no keywords. |
|---|
| 207 | | /// |
|---|
| 208 | | const gchar * |
|---|
| 209 | | PDFDocument::getKeywords () |
|---|
| 210 | | { |
|---|
| 211 | | if ( NULL == m_Keywords ) |
|---|
| 212 | | { |
|---|
| 213 | | return ""; |
|---|
| 214 | | } |
|---|
| 215 | | return m_Keywords; |
|---|
| 216 | | } |
|---|
| 217 | | |
|---|
| 218 | | /// |
|---|
| 219 | | /// @brief Gets the document's creator. |
|---|
| 220 | | /// |
|---|
| 221 | | /// @return The name of the software that created the document or an empty |
|---|
| 222 | | /// string if the creator's name is not available. |
|---|
| 223 | | /// |
|---|
| 224 | | const gchar * |
|---|
| 225 | | PDFDocument::getCreator () |
|---|
| 226 | | { |
|---|
| 227 | | if ( NULL == m_Creator ) |
|---|
| 228 | | { |
|---|
| 229 | | return ""; |
|---|
| 230 | | } |
|---|
| 231 | | return m_Creator; |
|---|
| 232 | | } |
|---|
| 233 | | |
|---|
| 234 | | /// |
|---|
| 235 | | /// @brief Gets the document's producer. |
|---|
| 236 | | /// |
|---|
| 237 | | /// @return The name of the software that converted the document or an empty |
|---|
| 238 | | /// string if the producer's name is not available. |
|---|
| 239 | | /// |
|---|
| 240 | | const gchar * |
|---|
| 241 | | PDFDocument::getProducer () |
|---|
| 242 | | { |
|---|
| 243 | | if ( NULL == m_Producer ) |
|---|
| 244 | | { |
|---|
| 245 | | return ""; |
|---|
| 246 | | } |
|---|
| 247 | | return m_Producer; |
|---|
| 248 | | } |
|---|
| 249 | | |
|---|
| 250 | | /// |
|---|
| 251 | | /// @brief Get the document's format. |
|---|
| 252 | | /// |
|---|
| 253 | | /// @returns The PDF version of the document or an empty string if the version |
|---|
| 254 | | /// is not available (usually only when the document has not been |
|---|
| 255 | | /// loaded yet). |
|---|
| 256 | | /// |
|---|
| 257 | | const gchar * |
|---|
| 258 | | PDFDocument::getFormat () |
|---|
| 259 | | { |
|---|
| 260 | | if ( NULL == m_Format ) |
|---|
| 261 | | { |
|---|
| 262 | | return ""; |
|---|
| 263 | | } |
|---|
| 264 | | return m_Format; |
|---|
| 265 | | } |
|---|
| 266 | | |
|---|
| 267 | | /// |
|---|
| 268 | | /// @brief Get if the document is linearized. |
|---|
| 269 | | /// |
|---|
| 270 | | /// @return The string "Yes" if the document is optimized for web viewing, "No" |
|---|
| 271 | | /// if it's not optimized or an empty string if this information is |
|---|
| 272 | | /// not available. |
|---|
| 273 | | /// |
|---|
| 274 | | const gchar * |
|---|
| 275 | | PDFDocument::getLinearized () |
|---|
| 276 | | { |
|---|
| 277 | | if ( NULL == m_Linearized ) |
|---|
| 278 | | { |
|---|
| 279 | | return ""; |
|---|
| 280 | | } |
|---|
| 281 | | return m_Linearized; |
|---|
| 282 | | } |
|---|
| 283 | | |
|---|
| 284 | | /// |
|---|
| 285 | | /// @brief Get the document's creation date. |
|---|
| 286 | | /// |
|---|
| 287 | | /// @return The date and time the document was created or an empty string if |
|---|
| 288 | | /// this information is not available. |
|---|
| 289 | | /// |
|---|
| 290 | | const gchar * |
|---|
| 291 | | PDFDocument::getCreationDate () |
|---|
| 292 | | { |
|---|
| 293 | | if ( NULL == m_CreationDate ) |
|---|
| 294 | | { |
|---|
| 295 | | return ""; |
|---|
| 296 | | } |
|---|
| 297 | | return m_CreationDate; |
|---|
| 298 | | } |
|---|
| 299 | | |
|---|
| 300 | | /// |
|---|
| 301 | | /// @brief Get the document's modification date. |
|---|
| 302 | | /// |
|---|
| 303 | | /// @return The date and time the document was modified or an empty string if |
|---|
| 304 | | /// this information is not available. |
|---|
| 305 | | /// |
|---|
| 306 | | const gchar * |
|---|
| 307 | | PDFDocument::getModifiedDate () |
|---|
| 308 | | { |
|---|
| 309 | | if ( NULL == m_ModifiedDate ) |
|---|
| 310 | | { |
|---|
| 311 | | return ""; |
|---|
| 312 | | } |
|---|
| 313 | | return m_ModifiedDate; |
|---|
| 314 | | } |
|---|
| 315 | | |
|---|
| 316 | | /// |
|---|
| 317 | | /// @brief Get the documents page mode. |
|---|
| 318 | | /// |
|---|
| 319 | | /// @return The page mode of the document or PageModeUnset if this |
|---|
| 320 | | /// information is not available. |
|---|
| 321 | | /// |
|---|
| 322 | | PageMode |
|---|
| 323 | | PDFDocument::getPageMode () |
|---|
| 324 | | { |
|---|
| 325 | | return m_PageMode; |
|---|
| 326 | | } |
|---|
| 327 | | |
|---|
| 328 | | /// |
|---|
| 329 | | /// @brief Get the document's page layout. |
|---|
| 330 | | /// |
|---|
| 331 | | /// @return The initial page layout of the document or PageLayoutUnset if this |
|---|
| 332 | | /// information is not available. |
|---|
| 333 | | /// |
|---|
| 334 | | PageLayout |
|---|
| 335 | | PDFDocument::getPageLayout () |
|---|
| 336 | | { |
|---|
| 337 | | return m_PageLayout; |
|---|
| 338 | | } |
|---|
| 339 | | |
|---|
| 340 | | /// |
|---|
| 341 | | /// @brief Get the document's number of pages. |
|---|
| 342 | | /// |
|---|
| 343 | | /// @return The total number of pages the document has or 0 if the document has |
|---|
| 344 | | /// not been loaded yet. |
|---|
| 345 | | /// |
|---|
| 346 | | gint |
|---|
| 347 | | PDFDocument::getNumPages () |
|---|
| 348 | | { |
|---|
| 349 | | return m_PageNumber; |
|---|
| 350 | | } |
|---|
| 351 | | |
|---|
| 352 | | /// |
|---|
| 368 | | g_free (m_Author); |
|---|
| 369 | | m_Author = getDictionaryString (dictionary, "Author"); |
|---|
| 370 | | g_free (m_CreationDate); |
|---|
| 371 | | m_CreationDate = getDictionaryDate (dictionary, "CreationDate"); |
|---|
| 372 | | g_free (m_Creator); |
|---|
| 373 | | m_Creator = getDictionaryString (dictionary, "Creator"); |
|---|
| 374 | | g_free(m_Format); |
|---|
| 375 | | m_Format = g_strdup_printf ("PDF-%.2g", m_Document->getPDFVersion ()); |
|---|
| 376 | | g_free (m_Keywords); |
|---|
| 377 | | m_Keywords = getDictionaryString (dictionary, "Keywords"); |
|---|
| 378 | | g_free (m_Linearized); |
|---|
| 379 | | if ( m_Document->isLinearized () ) |
|---|
| 380 | | { |
|---|
| 381 | | m_Linearized = g_strdup ("Yes"); |
|---|
| 382 | | } |
|---|
| 383 | | else |
|---|
| 384 | | { |
|---|
| 385 | | m_Linearized = g_strdup ("No"); |
|---|
| 386 | | } |
|---|
| 387 | | g_free (m_ModifiedDate); |
|---|
| 388 | | m_ModifiedDate = getDictionaryDate (dictionary, "ModDate"); |
|---|
| 389 | | g_free (m_Producer); |
|---|
| 390 | | m_Producer = getDictionaryString (dictionary, "Producer"); |
|---|
| 391 | | g_free (m_Subject); |
|---|
| 392 | | m_Subject = getDictionaryString (dictionary, "Subject"); |
|---|
| 393 | | g_free (m_Title); |
|---|
| 394 | | m_Title = getDictionaryString (dictionary, "Title"); |
|---|
| | 147 | gchar *value = NULL; |
|---|
| | 148 | // Author |
|---|
| | 149 | value = getDictionaryString (dictionary, "Author"); |
|---|
| | 150 | setAuthor (value); |
|---|
| | 151 | g_free (value); |
|---|
| | 152 | // Creation date. |
|---|
| | 153 | value = getDictionaryDate (dictionary, "CreationDate"); |
|---|
| | 154 | setCreationDate (value); |
|---|
| | 155 | g_free (value); |
|---|
| | 156 | // Creator |
|---|
| | 157 | value = getDictionaryString (dictionary, "Creator"); |
|---|
| | 158 | setCreator (value); |
|---|
| | 159 | g_free (value); |
|---|
| | 160 | // PDF Format |
|---|
| | 161 | value = g_strdup_printf ("PDF-%.2g", m_Document->getPDFVersion ()); |
|---|
| | 162 | setFormat (value); |
|---|
| | 163 | g_free (value); |
|---|
| | 164 | // Keywords |
|---|
| | 165 | value = getDictionaryString (dictionary, "Keywords"); |
|---|
| | 166 | setKeywords (value); |
|---|
| | 167 | g_free (value); |
|---|
| | 168 | // Is linearized |
|---|
| | 169 | setLinearized (m_Document->isLinearized ()); |
|---|
| | 170 | // Modified date |
|---|
| | 171 | value = getDictionaryDate (dictionary, "ModDate"); |
|---|
| | 172 | setModifiedDate (value); |
|---|
| | 173 | g_free (value); |
|---|
| | 174 | // Producer |
|---|
| | 175 | value = getDictionaryString (dictionary, "Producer"); |
|---|
| | 176 | setProducer (value); |
|---|
| | 177 | g_free (value); |
|---|
| | 178 | // Subject |
|---|
| | 179 | value = getDictionaryString (dictionary, "Subject"); |
|---|
| | 180 | setSubject (value); |
|---|
| | 181 | g_free (value); |
|---|
| | 182 | // Title |
|---|
| | 183 | value = getDictionaryString (dictionary, "Title"); |
|---|
| | 184 | setTitle (value); |
|---|
| | 185 | g_free (value); |
|---|