gml_PDFDocument.h

00001 // gml_PDFDocument.h --
00002 //
00003 //   Define the gml_TPDFDocument class.
00004 //
00005 //  Copyright (c) 2004 CLIPS-IMAG
00006 //
00007 //  See the file "gml_LicenseTerms.txt" for information on usage and redistribution
00008 //  of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00009 //
00010 //  Created in February 2004 (JL).
00011 
00012 #ifndef __GML_PDFDOCUMENT__
00013 #define __GML_PDFDOCUMENT__
00014 
00015 #include <sys/types.h>
00016 
00017 #include "gml/base/gml_Types.h"
00018 #include "gml/base/gml_Errors.h"
00019 #include "gml/image/gml_Geometry.h"
00020 #include "gml/image/gml_Bitmap.h"
00021 
00022 ///
00023 /// gml_TPDFBox --
00024 ///
00025 /// Names of the boxes defined in a PDF document page.
00026 ///
00027 enum gml_TPDFBox {
00028   gml_cPDFMediaBox = 0,
00029   gml_cPDFCropBox  = 1,
00030   gml_cPDFBleedBox = 2,
00031   gml_cPDFTrimBox  = 3,
00032   gml_cPDFArtBox   = 4
00033   
00034 };
00035 
00036 
00037 ///
00038 /// gml_TPDFDocumentPlatformData --
00039 ///
00040 /// Type for platform-specific data in gml_TPDFDocument objects.
00041 ///
00042 typedef struct _gml_TPDFDocumentPlatformData gml_TPDFDocumentPlatformData;
00043 
00044 
00045 
00046 ////////////////////////////////////////////////////////////////////////////////
00047 //                                                                            //
00048 //                      gml_TPDFDocument class declaration                    //
00049 //                                                                            //
00050 ////////////////////////////////////////////////////////////////////////////////
00051 
00052 ///
00053 /// gml_TPDFDocument --
00054 ///
00055 /// Represent a PDF document that can be loaded in memory and rendered 
00056 /// to gml_Bitmap objects.
00057 ///
00058 class gml_TPDFDocument
00059 {
00060 public:
00061 
00062   ///
00063   /// Init --
00064   ///   Open the PDF document at <path> and get ready for rendering.
00065   ///
00066   gml_TError Init (char *path);
00067   
00068   ///
00069   /// Dispose --
00070   ///   Free all resources claimed by Init().
00071   ///
00072   void Dispose ();
00073   
00074   ///
00075   /// Pages --
00076   ///   Return the number of pages in this document.
00077   ///
00078   UInt16 Pages ();
00079   
00080   ///
00081   /// Box --
00082   ///   Return in <result> the requested page box of the document.
00083   ///
00084   gml_TError Box (UInt16 page, gml_TPDFBox box, gml_TRectFloat &result);
00085   
00086   ///
00087   /// Render --
00088   ///     Render page <page> of this document in the given <bitmap> object.
00089   /// The page is scaled to fill the bitmap, while keeping proportions.
00090   ///
00091   gml_TError Render (gml_TBitmap *bitmap, UInt16 page);
00092 
00093 
00094 private:
00095   char                            *fPath;         ///< path to the loaded document
00096   FILE                            *fStream;       ///< corresponding file stream
00097   off_t                            fSize;         ///< file size in bytes
00098   void                            *fAddress;      ///< memory address of the file mapping
00099   gml_TPDFDocumentPlatformData    *fPlatformData; ///< anchor for platform-specific fields
00100   size_t                           fPages;        ///< number of pages in document
00101 };
00102 
00103 #endif /* __GML_PDFDOCUMENT__ */
Generated on Tue Jun 12 14:03:27 2007 for gml by Doxygen 1.5.2.