diff options
-rw-r--r-- | core/include/fpdfdoc/fpdf_doc.h | 5 | ||||
-rw-r--r-- | core/src/fpdfdoc/doc_viewerPreferences.cpp | 29 | ||||
-rw-r--r-- | fpdfsdk/include/fpdfview.h | 36 | ||||
-rw-r--r-- | fpdfsdk/src/fpdfview.cpp | 31 |
4 files changed, 101 insertions, 0 deletions
diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h index cbb0fd4a11..e4cf777c1f 100644 --- a/core/include/fpdfdoc/fpdf_doc.h +++ b/core/include/fpdfdoc/fpdf_doc.h @@ -1657,6 +1657,11 @@ public: FX_BOOL PrintScaling() const; + FX_INT32 NumCopies() const; + + CPDF_Array* PrintPageRange() const; + + CFX_ByteString Duplex() const; protected: CPDF_Document* m_pDoc; diff --git a/core/src/fpdfdoc/doc_viewerPreferences.cpp b/core/src/fpdfdoc/doc_viewerPreferences.cpp index 617485cfc2..f68d3fbdc7 100644 --- a/core/src/fpdfdoc/doc_viewerPreferences.cpp +++ b/core/src/fpdfdoc/doc_viewerPreferences.cpp @@ -29,3 +29,32 @@ FX_BOOL CPDF_ViewerPreferences::PrintScaling() const } return FX_BSTRC("None") != pDict->GetString(FX_BSTRC("PrintScaling")); } +FX_INT32 CPDF_ViewerPreferences::NumCopies() const +{ + CPDF_Dictionary *pDict = m_pDoc->GetRoot(); + pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); + if (!pDict) { + return 1; + } + return pDict->GetInteger(FX_BSTRC("NumCopies")); +} +CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const +{ + CPDF_Dictionary *pDict = m_pDoc->GetRoot(); + CPDF_Array *pRange = NULL; + pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); + if (!pDict) { + return pRange; + } + pRange = pDict->GetArray(FX_BSTRC("PrintPageRange")); + return pRange; +} +CFX_ByteString CPDF_ViewerPreferences::Duplex() const +{ + CPDF_Dictionary *pDict = m_pDoc->GetRoot(); + pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); + if (!pDict) { + return FX_BSTRC("None"); + } + return pDict->GetString(FX_BSTRC("Duplex")); +} diff --git a/fpdfsdk/include/fpdfview.h b/fpdfsdk/include/fpdfview.h index f4f13750bc..1b7ae2e251 100644 --- a/fpdfsdk/include/fpdfview.h +++ b/fpdfsdk/include/fpdfview.h @@ -34,6 +34,7 @@ typedef void* FPDF_BOOKMARK; typedef void* FPDF_DEST; typedef void* FPDF_ACTION; typedef void* FPDF_LINK; +typedef void* FPDF_PAGERANGE; // Basic data types typedef int FPDF_BOOL; @@ -42,6 +43,14 @@ typedef unsigned long FPDF_DWORD; typedef float FS_FLOAT; +// Duplex types +typedef enum _FPDF_DUPLEXTYPE_ { + DuplexUndefined = 0, + Simplex, + DuplexFlipShortEdge, + DuplexFlipLongEdge +} FPDF_DUPLEXTYPE; + // String types typedef unsigned short FPDF_WCHAR; typedef unsigned char const* FPDF_LPCBYTE; @@ -556,6 +565,33 @@ DLLEXPORT void STDCALL FPDFBitmap_Destroy(FPDF_BITMAP bitmap); // DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT document); +// Function: FPDF_VIEWERREF_GetNumCopies +// Returns the number of copies to be printed. +// Parameters: +// document - Handle to the loaded document. +// Return value: +// The number of copies to be printed. +// +DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document); + +// Function: FPDF_VIEWERREF_GetPrintPageRange +// Page numbers to initialize print dialog box when file is printed. +// Parameters: +// document - Handle to the loaded document. +// Return value: +// The print page range to be used for printing. +// +DLLEXPORT FPDF_PAGERANGE STDCALL FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document); + +// Function: FPDF_VIEWERREF_GetDuplex +// Returns the paper handling option to be used when printing from print dialog. +// Parameters: +// document - Handle to the loaded document. +// Return value: +// The paper handling option to be used when printing. +// +DLLEXPORT FPDF_DUPLEXTYPE STDCALL FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document); + // Function: FPDF_GetNamedDestByName // get a special dest handle by the index. // Parameters: diff --git a/fpdfsdk/src/fpdfview.cpp b/fpdfsdk/src/fpdfview.cpp index a9aa9a8ff2..8a97c286aa 100644 --- a/fpdfsdk/src/fpdfview.cpp +++ b/fpdfsdk/src/fpdfview.cpp @@ -859,6 +859,37 @@ DLLEXPORT FPDF_BOOL STDCALL FPDF_VIEWERREF_GetPrintScaling(FPDF_DOCUMENT documen return viewRef.PrintScaling(); } +DLLEXPORT int STDCALL FPDF_VIEWERREF_GetNumCopies(FPDF_DOCUMENT document) +{ + CPDF_Document* pDoc = (CPDF_Document*)document; + if (!pDoc) return 1; + CPDF_ViewerPreferences viewRef(pDoc); + return viewRef.NumCopies(); +} + +DLLEXPORT FPDF_PAGERANGE STDCALL FPDF_VIEWERREF_GetPrintPageRange(FPDF_DOCUMENT document) +{ + CPDF_Document* pDoc = (CPDF_Document*)document; + if (!pDoc) return NULL; + CPDF_ViewerPreferences viewRef(pDoc); + return viewRef.PrintPageRange(); +} + +DLLEXPORT FPDF_DUPLEXTYPE STDCALL FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document) +{ + CPDF_Document* pDoc = (CPDF_Document*)document; + if (!pDoc) return DuplexUndefined; + CPDF_ViewerPreferences viewRef(pDoc); + CFX_ByteString duplex = viewRef.Duplex(); + if (FX_BSTRC("Simplex") == duplex) + return Simplex; + if (FX_BSTRC("DuplexFlipShortEdge") == duplex) + return DuplexFlipShortEdge; + if (FX_BSTRC("DuplexFlipLongEdge") == duplex) + return DuplexFlipLongEdge; + return DuplexUndefined; +} + DLLEXPORT FPDF_DEST STDCALL FPDF_GetNamedDestByName(FPDF_DOCUMENT document,FPDF_BYTESTRING name) { if (document == NULL) |