OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Private Attributes | List of all members
ossimGeoPdfInfo Class Reference

GeoPdf info class. More...

#include <ossimGeoPdfInfo.h>

Inheritance diagram for ossimGeoPdfInfo:
ossimInfoBase ossimReferenced

Public Member Functions

 ossimGeoPdfInfo ()
 default constructor More...
 
virtual ~ossimGeoPdfInfo ()
 virtual destructor More...
 
virtual bool open (const ossimFilename &file)
 open method. More...
 
virtual bool open (std::shared_ptr< ossim::istream > &str, const std::string &connectionString)
 open method. More...
 
virtual std::ostream & print (std::ostream &out) const
 Print method. More...
 
bool isOpen ()
 
- Public Member Functions inherited from ossimInfoBase
 ossimInfoBase ()
 default constructor More...
 
void setProcessOverviewFlag (bool flag)
 Sets the overview flag. More...
 
bool getProcessOverviewFlag () const
 Method to get the overview flag. More...
 
virtual bool getKeywordlist (ossimKeywordlist &kwl) const
 Method to dump info to a keyword list. More...
 
virtual bool getKeywordlist (ossimKeywordlist &kwl, ossim_uint32 entryIndex) const
 Method to dump info to a keyword list. More...
 
- Public Member Functions inherited from ossimReferenced
 ossimReferenced ()
 
 ossimReferenced (const ossimReferenced &)
 
ossimReferencedoperator= (const ossimReferenced &)
 
void ref () const
 increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unref () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unref_nodelete () const
 decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
int referenceCount () const
 

Private Attributes

ossimFilename theFile
 
PoDoFo::PdfMemDocument * m_PdfMemDocument
 

Additional Inherited Members

- Protected Member Functions inherited from ossimInfoBase
virtual ~ossimInfoBase ()
 virtual destructor More...
 
- Protected Member Functions inherited from ossimReferenced
virtual ~ossimReferenced ()
 
- Protected Attributes inherited from ossimInfoBase
bool theOverviewFlag
 

Detailed Description

GeoPdf info class.

Encapsulates the GeoPdf functionality.

Definition at line 34 of file ossimGeoPdfInfo.h.

Constructor & Destructor Documentation

◆ ossimGeoPdfInfo()

ossimGeoPdfInfo::ossimGeoPdfInfo ( )

default constructor

Definition at line 33 of file ossimGeoPdfInfo.cpp.

34  : ossimInfoBase(),
35  theFile(),
36  m_PdfMemDocument(NULL)
37 {
38 }
ossimFilename theFile
ossimInfoBase()
default constructor
PoDoFo::PdfMemDocument * m_PdfMemDocument

◆ ~ossimGeoPdfInfo()

ossimGeoPdfInfo::~ossimGeoPdfInfo ( )
virtual

virtual destructor

Definition at line 40 of file ossimGeoPdfInfo.cpp.

References m_PdfMemDocument.

41 {
42  if (m_PdfMemDocument != NULL)
43  {
44  delete m_PdfMemDocument;
45  m_PdfMemDocument = 0;
46  }
47 }
PoDoFo::PdfMemDocument * m_PdfMemDocument

Member Function Documentation

◆ isOpen()

bool ossimGeoPdfInfo::isOpen ( )

Definition at line 72 of file ossimGeoPdfInfo.cpp.

References ossimString::downcase(), ossimFilename::ext(), and theFile.

Referenced by open().

73 {
74  ossimString ext = theFile.ext().downcase();
75 
76  if(ext == "pdf")
77  {
78  return true;
79  }
80  else
81  {
82  return false;
83  }
84 }
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
ossimFilename theFile
ossimString ext() const

◆ open() [1/2]

bool ossimGeoPdfInfo::open ( const ossimFilename file)
virtual

open method.

Parameters
fileFile name to open.
Returns
true on success false on error.

Reimplemented from ossimInfoBase.

Definition at line 49 of file ossimGeoPdfInfo.cpp.

References ossimString::c_str(), isOpen(), m_PdfMemDocument, and theFile.

50 {
51  theFile = file;
52  if (isOpen())
53  {
54  PoDoFo::PdfError::EnableDebug(false); //do not print out debug info
55  m_PdfMemDocument = new PoDoFo::PdfMemDocument(theFile.c_str());
56 
57  if (m_PdfMemDocument == NULL)
58  {
59  return false;
60  }
61  return true;
62  }
63  return false;
64 }
ossimFilename theFile
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
PoDoFo::PdfMemDocument * m_PdfMemDocument

◆ open() [2/2]

bool ossimGeoPdfInfo::open ( std::shared_ptr< ossim::istream > &  str,
const std::string &  connectionString 
)
virtual

open method.

Parameters
strFile name to open.
Returns
true on success false on error.

Reimplemented from ossimInfoBase.

Definition at line 66 of file ossimGeoPdfInfo.cpp.

68 {
69  return false;
70 }

◆ print()

std::ostream & ossimGeoPdfInfo::print ( std::ostream &  out) const
virtual

Print method.

Parameters
outStream to print to.
Returns
std::ostream&

Implements ossimInfoBase.

Definition at line 86 of file ossimGeoPdfInfo.cpp.

References ossimString::c_str(), ossimString::empty(), m_PdfMemDocument, ossimString::substitute(), ossimString::toString(), and ossimString::trim().

87 {
88  static const char MODULE[] = "ossimGeoPdfInfo::print";
89 
90  int count = m_PdfMemDocument->GetPageCount();
91  PoDoFo::PdfString author = m_PdfMemDocument->GetInfo()->GetAuthor();
92  PoDoFo::PdfString creator = m_PdfMemDocument->GetInfo()->GetCreator();
93  PoDoFo::PdfString title = m_PdfMemDocument->GetInfo()->GetTitle();
94  PoDoFo::PdfString subject = m_PdfMemDocument->GetInfo()->GetSubject();
95  PoDoFo::PdfString keywords = m_PdfMemDocument->GetInfo()->GetKeywords();
96  PoDoFo::PdfString producer = m_PdfMemDocument->GetInfo()->GetProducer();
97 
98 
99  ossimString createDate;
100  ossimString modifyDate;
101  PoDoFo::PdfObject* obj = m_PdfMemDocument->GetInfo()->GetObject();
102  if (obj->IsDictionary())
103  {
104  PoDoFo::PdfDictionary pdfDictionary = obj->GetDictionary();
105 
106  PoDoFo::TKeyMap keyMap = pdfDictionary.GetKeys();
107  PoDoFo::TKeyMap::iterator it = keyMap.begin();
108  while (it != keyMap.end())
109  {
110  ossimString refName = ossimString(it->first.GetName());
111  PoDoFo::PdfObject* refObj = it->second;
112 
113  std::string objStr;
114  refObj->ToString(objStr);
115 
116  if (refName == "CreationDate")
117  {
118  createDate = ossimString(objStr);
119  createDate = createDate.substitute("(", "", true).trim();
120  createDate = createDate.substitute(")", "", true).trim();
121  createDate = createDate.substitute("D:", "", true).trim();
122  }
123  else if (refName == "ModDate")
124  {
125  modifyDate = ossimString(objStr);
126  modifyDate = modifyDate.substitute("(", "", true).trim();
127  modifyDate = modifyDate.substitute(")", "", true).trim();
128  modifyDate = modifyDate.substitute("D:", "", true).trim();
129  }
130  it++;
131  }
132  }
133 
134  try
135  {
136  m_PdfMemDocument->FreeObjectMemory(obj);
137  }
138  catch (...)
139  {
140  }
141 
142  ossimString authorStr = author.GetString();
143  ossimString creatorStr = creator.GetString();
144  ossimString titleStr = title.GetString();
145  ossimString producerStr = producer.GetString();
146  ossimString subjectStr = subject.GetString();
147  ossimString keywordsStr = keywords.GetString();
148 
149  ossimString prefix = "geopdf.";
150 
151  out << prefix << "pagecount: "
152  << ossimString::toString(count).c_str() << "\n";
153 
154  if (!authorStr.empty())
155  {
156  out << prefix << "author: "
157  << authorStr.c_str() << "\n";
158  }
159 
160  if (!creatorStr.empty())
161  {
162  out << prefix << "creator: "
163  << creatorStr.c_str() << "\n";
164  }
165 
166  if (!titleStr.empty())
167  {
168  out << prefix << "title: "
169  << titleStr.c_str() << "\n";
170  }
171 
172  if (!producerStr.empty())
173  {
174  out << prefix << "producer: "
175  << producerStr.c_str() << "\n";
176  }
177 
178  if (!subjectStr.empty())
179  {
180  out << prefix << "subject: "
181  << subjectStr.c_str() << "\n";
182  }
183 
184  if (!keywordsStr.empty())
185  {
186  out << prefix << "keywords: "
187  << keywordsStr.c_str() << "\n";
188  }
189 
190  if (!createDate.empty())
191  {
192  out << prefix << "creationdate: "
193  << createDate.c_str() << "\n";
194  }
195 
196  if (!modifyDate.empty())
197  {
198  out << prefix << "modificationdate: "
199  << modifyDate.c_str() << "\n";
200  }
201 
202  if (traceDebug())
203  {
205  << MODULE << " DEBUG Entered...\n";
206  }
207  return out;
208 }
ossimString substitute(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
Substitutes searchKey string with replacementValue and returns a string.
static ossimString toString(bool aValue)
Numeric to string methods.
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
bool empty() const
Definition: ossimString.h:411
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
PoDoFo::PdfMemDocument * m_PdfMemDocument

Member Data Documentation

◆ m_PdfMemDocument

PoDoFo::PdfMemDocument* ossimGeoPdfInfo::m_PdfMemDocument
private

Definition at line 69 of file ossimGeoPdfInfo.h.

Referenced by open(), print(), and ~ossimGeoPdfInfo().

◆ theFile

ossimFilename ossimGeoPdfInfo::theFile
private

Definition at line 68 of file ossimGeoPdfInfo.h.

Referenced by isOpen(), and open().


The documentation for this class was generated from the following files: