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