If have created a new patch with your suggestions.
PS: damn IBM Notes HTML emails....so now I send from my private email address.
=========================================================================================
Index: src/base/PdfInputStream.cpp
===================================================================
--- src/base/PdfInputStream.cpp (revision 1697)
+++ src/base/PdfInputStream.cpp (working copy)
@@ -35,6 +35,7 @@
#include "PdfInputDevice.h"
#include "PdfDefinesPrivate.h"
+#include "PdfDate.h"
#include <stdio.h>
#include <string.h>
@@ -98,6 +99,24 @@
return lLen;
}
+PdfDate PdfFileInputStream::GetModifiedDate()
+{
+
+ struct stat file_stat;
+ int fp = fileno(m_hFile);
+ fstat(fp, &file_stat);
+ return PdfDate(file_stat.st_mtime);
+}
+
+
+PdfDate PdfFileInputStream::GetCreationDate()
+{
+ struct stat file_stat;
+ int fp = fileno(m_hFile);
+ fstat(fp, &file_stat);
+ return PdfDate(file_stat.st_ctime);
+}
+
FILE*
PdfFileInputStream::GetHandle()
{
Index: src/base/PdfInputStream.h
===================================================================
--- src/base/PdfInputStream.h (revision 1697)
+++ src/base/PdfInputStream.h (working copy)
@@ -35,6 +35,7 @@
#define _PDF_INPUT_STREAM_H_
#include "PdfDefines.h"
+#include "PdfDate.h"
namespace PoDoFo {
@@ -103,6 +104,16 @@
*/
pdf_long GetFileLength();
+ /** Get the modified date of the file.
+ * \return the file modified date
+ */
+ PdfDate GetModifiedDate();
+
+ /** Get the creation date of the file.
+ * \return the file creation date
+ */
+ PdfDate GetCreationDate();
+
/** Get the internal FILE handle.
* \return the internal FILE handle
*/
Index: src/doc/PdfFileSpec.cpp
===================================================================
--- src/doc/PdfFileSpec.cpp (revision 1697)
+++ src/doc/PdfFileSpec.cpp (working copy)
@@ -39,6 +39,7 @@
#include "base/PdfInputStream.h"
#include "base/PdfObject.h"
#include "base/PdfStream.h"
+#include "base/PdfDate.h"
#include <sstream>
@@ -182,7 +183,7 @@
// Add additional information about the embedded file to the stream
PdfDictionary params;
params.AddKey( "Size", static_cast<pdf_int64>(stream.GetFileLength()) );
- // TODO: CreationDate and ModDate
+ AddDateParams(params, stream.GetCreationDate(), stream.GetModifiedDate());
pStream->GetDictionary().AddKey("Params", params );
}
@@ -291,7 +292,7 @@
// Add additional information about the embedded file to the stream
PdfDictionary params;
params.AddKey( "Size", static_cast<pdf_int64>(stream.GetFileLength()) );
- // TODO: CreationDate and ModDate
+ AddDateParams(params, stream.GetCreationDate(), stream.GetModifiedDate());
pStream->GetDictionary().AddKey("Params", params );
}
@@ -320,7 +321,7 @@
return lastFrom;
}
-void PdfFileSpec::EmbeddFileFromMem( PdfObject* pStream, const unsigned char*
data, ptrdiff_t size ) const
+void PdfFileSpec::EmbeddFileFromMem( PdfObject* pStream, const unsigned char*
data, ptrdiff_t size, const PdfDate* creation_date, const PdfDate* mod_date )
const
{
PdfMemoryInputStream memstream(reinterpret_cast<const char*>(data),size);
pStream->GetStream()->Set( &memstream );
@@ -328,6 +329,17 @@
// Add additional information about the embedded file to the stream
PdfDictionary params;
params.AddKey( "Size", static_cast<pdf_int64>(size) );
+ PdfDate creation_date_internal;
+ PdfDate mod_date_internal;
+ if (creation_date != NULL)
+ {
+ creation_date_internal = *creation_date;
+ }
+ if (mod_date != NULL)
+ {
+ mod_date_internal = *mod_date;
+ }
+ AddDateParams( params, creation_date_internal, mod_date_internal );
pStream->GetDictionary().AddKey("Params", params );
}
@@ -346,5 +358,15 @@
PODOFO_RAISE_ERROR( ePdfError_InvalidDataType );
}
+void PdfFileSpec::AddDateParams(PdfDictionary ¶ms, const PdfDate
&creation_date, const PdfDate &mod_date) const
+{
+ PdfString mod_date_string;
+ mod_date.ToString(mod_date_string);
+ params.AddKey("ModDate", mod_date_string);
+ PdfString creation_date_string;
+ creation_date.ToString(creation_date_string);
+ params.AddKey("CreationDate", creation_date_string);
+}
+
};
Index: src/doc/PdfFileSpec.h
===================================================================
--- src/doc/PdfFileSpec.h (revision 1697)
+++ src/doc/PdfFileSpec.h (working copy)
@@ -38,6 +38,8 @@
#include "podofo/base/PdfString.h"
+#include "base/PdfDate.h"
+
#include "PdfElement.h"
namespace PoDoFo {
@@ -125,8 +127,15 @@
/* Petr P. Petrov 17 September 2009*/
/** Embeds the file from memory
*/
- void EmbeddFileFromMem( PdfObject* pStream, const unsigned char* data,
ptrdiff_t size ) const;
+ void EmbeddFileFromMem( PdfObject* pStream, const unsigned char* data,
ptrdiff_t size, const PdfDate* creation_date = NULL, const PdfDate* mod_date =
NULL ) const;
+ /** Add creation date and modified date params to the given dictonary.
+ * \param params add the dates to this dictionary
+ * \param creation_date the creation date that will be added
+ * \param mod_date the modified date that will be added
+ */
+ void AddDateParams( PdfDictionary ¶ms, const PdfDate &creation_date,
const PdfDate &mod_date ) const;
+
};
};
------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741911&iu=/4140
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users