summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fpdfsdk/fpdf_transformpage.cpp20
-rw-r--r--public/fpdf_transformpage.h22
2 files changed, 27 insertions, 15 deletions
diff --git a/fpdfsdk/fpdf_transformpage.cpp b/fpdfsdk/fpdf_transformpage.cpp
index b607dffc4e..4f29fd69d6 100644
--- a/fpdfsdk/fpdf_transformpage.cpp
+++ b/fpdfsdk/fpdf_transformpage.cpp
@@ -106,19 +106,27 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPage_TransFormWithClip(FPDF_PAGE page,
FS_MATRIX* matrix,
FS_RECTF* clipRect) {
+ if (!matrix && !clipRect)
+ return false;
+
CPDF_Page* pPage = CPDFPageFromFPDFPage(page);
if (!pPage)
return false;
std::ostringstream textBuf;
textBuf << "q ";
- CFX_FloatRect rect = CFXFloatRectFromFSRECTF(*clipRect);
- rect.Normalize();
- textBuf << ByteString::Format("%f %f %f %f re W* n ", rect.left, rect.bottom,
- rect.Width(), rect.Height());
- textBuf << ByteString::Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b,
- matrix->c, matrix->d, matrix->e, matrix->f);
+ if (clipRect) {
+ CFX_FloatRect rect = CFXFloatRectFromFSRECTF(*clipRect);
+ rect.Normalize();
+
+ textBuf << ByteString::Format("%f %f %f %f re W* n ", rect.left,
+ rect.bottom, rect.Width(), rect.Height());
+ }
+ if (matrix) {
+ textBuf << ByteString::Format("%f %f %f %f %f %f cm ", matrix->a, matrix->b,
+ matrix->c, matrix->d, matrix->e, matrix->f);
+ }
CPDF_Dictionary* pPageDict = pPage->m_pFormDict.Get();
CPDF_Object* pContentObj = GetPageContent(pPageDict);
diff --git a/public/fpdf_transformpage.h b/public/fpdf_transformpage.h
index f26c077bde..a6ed04a511 100644
--- a/public/fpdf_transformpage.h
+++ b/public/fpdf_transformpage.h
@@ -84,15 +84,19 @@ FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page,
float* top);
/**
-* Transform the whole page with a specified matrix, then clip the page content
-* region.
-*
-* @param[in] page - A page handle.
-* @param[in] matrix - The transform matrix.
-* @param[in] clipRect - A rectangle page area to be clipped.
-* @Note. This function will transform the whole page, and would take effect to
-* all the objects in the page.
-*/
+ * Apply transforms to |page|.
+ *
+ * If |matrix| is provided it will be applied to transform the page.
+ * If |clipRect| is provided it will be used to clip the resulting page.
+ * If neither |matrix| or |clipRect| are provided this method returns |false|.
+ * Returns |true| if transforms are applied.
+ *
+ * @param[in] page - Page handle.
+ * @param[in] matrix - Transform matrix.
+ * @param[in] clipRect - Clipping rectangle.
+ * @Note. This function will transform the whole page, and would take effect to
+ * all the objects in the page.
+ */
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
FPDFPage_TransFormWithClip(FPDF_PAGE page,
FS_MATRIX* matrix,