Home | History | Annotate | Download | only in public
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #ifndef PUBLIC_FPDF_TRANSFORMPAGE_H_
      8 #define PUBLIC_FPDF_TRANSFORMPAGE_H_
      9 
     10 #include "fpdfview.h"
     11 
     12 #ifdef __cplusplus
     13 extern "C" {
     14 #endif
     15 
     16 typedef void* FPDF_PAGEARCSAVER;
     17 typedef void* FPDF_PAGEARCLOADER;
     18 
     19 /**
     20 *  Set "MediaBox" entry to the page dictionary.
     21 * @param[in] page   - Handle to a page.
     22 * @param[in] left   - The left of the rectangle.
     23 * @param[in] bottom - The bottom of the rectangle.
     24 * @param[in] right  - The right of the rectangle.
     25 * @param[in] top    - The top of the rectangle.
     26 * @retval None.
     27 */
     28 DLLEXPORT void STDCALL FPDFPage_SetMediaBox(FPDF_PAGE page,
     29                                             float left,
     30                                             float bottom,
     31                                             float right,
     32                                             float top);
     33 
     34 /**
     35 *  Set "CropBox" entry to the page dictionary.
     36 * @param[in] page   - Handle to a page.
     37 * @param[in] left   - The left of the rectangle.
     38 * @param[in] bottom - The bottom of the rectangle.
     39 * @param[in] right  - The right of the rectangle.
     40 * @param[in] top    - The top of the rectangle.
     41 * @retval None.
     42 */
     43 DLLEXPORT void STDCALL FPDFPage_SetCropBox(FPDF_PAGE page,
     44                                            float left,
     45                                            float bottom,
     46                                            float right,
     47                                            float top);
     48 
     49 /**  Get "MediaBox" entry from the page dictionary.
     50 * @param[in] page   - Handle to a page.
     51 * @param[in] left   - Pointer to a double value receiving the left of the
     52 * rectangle.
     53 * @param[in] bottom - Pointer to a double value receiving the bottom of the
     54 * rectangle.
     55 * @param[in] right  - Pointer to a double value receiving the right of the
     56 * rectangle.
     57 * @param[in] top    - Pointer to a double value receiving the top of the
     58 * rectangle.
     59 * @retval True if success,else fail.
     60 */
     61 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetMediaBox(FPDF_PAGE page,
     62                                                  float* left,
     63                                                  float* bottom,
     64                                                  float* right,
     65                                                  float* top);
     66 
     67 /**  Get "CropBox" entry from the page dictionary.
     68 * @param[in] page   - Handle to a page.
     69 * @param[in] left   - Pointer to a double value receiving the left of the
     70 * rectangle.
     71 * @param[in] bottom - Pointer to a double value receiving the bottom of the
     72 * rectangle.
     73 * @param[in] right  - Pointer to a double value receiving the right of the
     74 * rectangle.
     75 * @param[in] top    - Pointer to a double value receiving the top of the
     76 * rectangle.
     77 * @retval True if success,else fail.
     78 */
     79 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetCropBox(FPDF_PAGE page,
     80                                                 float* left,
     81                                                 float* bottom,
     82                                                 float* right,
     83                                                 float* top);
     84 
     85 /**
     86 * Transform the whole page with a specified matrix, then clip the page content
     87 * region.
     88 *
     89 * @param[in] page        - A page handle.
     90 * @param[in] matrix      - The transform matrix.
     91 * @param[in] clipRect    - A rectangle page area to be clipped.
     92 * @Note. This function will transform the whole page, and would take effect to
     93 * all the objects in the page.
     94 */
     95 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_TransFormWithClip(FPDF_PAGE page,
     96                                                        FS_MATRIX* matrix,
     97                                                        FS_RECTF* clipRect);
     98 
     99 /**
    100 * Transform (scale, rotate, shear, move) the clip path of page object.
    101 * @param[in] page_object - Handle to a page object. Returned by
    102 * FPDFPageObj_NewImageObj.
    103 * @param[in] a  - The coefficient "a" of the matrix.
    104 * @param[in] b  - The coefficient "b" of the matrix.
    105 * @param[in] c  - The coefficient "c" of the matrix.
    106 * @param[in] d  - The coefficient "d" of the matrix.
    107 * @param[in] e  - The coefficient "e" of the matrix.
    108 * @param[in] f  - The coefficient "f" of the matrix.
    109 * @retval None.
    110 */
    111 DLLEXPORT void STDCALL
    112 FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object,
    113                               double a,
    114                               double b,
    115                               double c,
    116                               double d,
    117                               double e,
    118                               double f);
    119 
    120 /**
    121 * Create a new clip path, with a rectangle inserted.
    122 *
    123 * @param[in] left   - The left of the clip box.
    124 * @param[in] bottom - The bottom of the clip box.
    125 * @param[in] right  - The right of the clip box.
    126 * @param[in] top    - The top of the clip box.
    127 * @retval a handle to the clip path.
    128 */
    129 DLLEXPORT FPDF_CLIPPATH STDCALL FPDF_CreateClipPath(float left,
    130                                                     float bottom,
    131                                                     float right,
    132                                                     float top);
    133 
    134 /**
    135 * Destroy the clip path.
    136 *
    137 * @param[in] clipPath - A handle to the clip path.
    138 * Destroy the clip path.
    139 * @retval None.
    140 */
    141 DLLEXPORT void STDCALL FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath);
    142 
    143 /**
    144 * Clip the page content, the page content that outside the clipping region
    145 * become invisible.
    146 *
    147 * @param[in] page        - A page handle.
    148 * @param[in] clipPath    - A handle to the clip path.
    149 * @Note. A clip path will be inserted before the page content stream or content
    150 * array. In this way, the page content will be clipped
    151 * by this clip path.
    152 */
    153 DLLEXPORT void STDCALL FPDFPage_InsertClipPath(FPDF_PAGE page,
    154                                                FPDF_CLIPPATH clipPath);
    155 
    156 #ifdef __cplusplus
    157 }
    158 #endif
    159 
    160 #endif  // PUBLIC_FPDF_TRANSFORMPAGE_H_
    161