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_EDIT_H_
      8 #define PUBLIC_FPDF_EDIT_H_
      9 
     10 #include "fpdfview.h"
     11 
     12 // Define all types used in the SDK. Note they can be simply regarded as opaque pointers
     13 // or long integer numbers.
     14 
     15 #define FPDF_ARGB(a,r,g,b)      ((((FX_DWORD)(((FX_BYTE)(b)|((FX_WORD)((FX_BYTE)(g))<<8))|(((FX_DWORD)(FX_BYTE)(r))<<16)))) | (((FX_DWORD)(FX_BYTE)(a))<<24))
     16 #define FPDF_GetBValue(argb)    ((FX_BYTE)(argb))
     17 #define FPDF_GetGValue(argb)    ((FX_BYTE)(((FX_WORD)(argb)) >> 8))
     18 #define FPDF_GetRValue(argb)    ((FX_BYTE)((argb)>>16))
     19 #define FPDF_GetAValue(argb)    ((FX_BYTE)((argb)>>24))
     20 
     21 #ifdef __cplusplus
     22 extern "C" {
     23 #endif
     24 
     25 //////////////////////////////////////////////////////////////////////
     26 //
     27 // Document functions
     28 //
     29 //////////////////////////////////////////////////////////////////////
     30 
     31 // Function: FPDF_CreateNewDocument
     32 //          Create a new PDF document.
     33 // Parameters:
     34 //          None.
     35 // Return value:
     36 //          A handle to a document. If failed, NULL is returned.
     37 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument();
     38 
     39 //////////////////////////////////////////////////////////////////////
     40 //
     41 // Page functions
     42 //
     43 //////////////////////////////////////////////////////////////////////
     44 
     45 // Function: FPDFPage_New
     46 //          Construct an empty page.
     47 // Parameters:
     48 //          document    -   Handle to document. Returned by FPDF_LoadDocument and FPDF_CreateNewDocument.
     49 //          page_index  -   The index of a page.
     50 //          width       -   The page width.
     51 //          height      -   The page height.
     52 // Return value:
     53 //          The handle to the page.
     54 // Comments:
     55 //          Loaded page can be deleted by FPDFPage_Delete.
     56 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, int page_index, double width, double height);
     57 
     58 // Function: FPDFPage_Delete
     59 //          Delete a PDF page.
     60 // Parameters:
     61 //          document    -   Handle to document. Returned by FPDF_LoadDocument and FPDF_CreateNewDocument.
     62 //          page_index  -   The index of a page.
     63 // Return value:
     64 //          None.
     65 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index);
     66 
     67 // Function: FPDFPage_GetRotation
     68 //          Get the page rotation. One of following values will be returned: 0(0), 1(90), 2(180), 3(270).
     69 // Parameters:
     70 //          page        -   Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
     71 // Return value:
     72 //          The PDF page rotation.
     73 // Comment:
     74 //          The PDF page rotation is rotated clockwise.
     75 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page);
     76 
     77 // Function: FPDFPage_SetRotation
     78 //          Set page rotation. One of following values will be set: 0(0), 1(90), 2(180), 3(270).
     79 // Parameters:
     80 //          page        -   Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
     81 //          rotate      -   The value of the PDF page rotation.
     82 // Return value:
     83 //          None.
     84 // Comment:
     85 //          The PDF page rotation is rotated clockwise.
     86 //
     87 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate);
     88 
     89 // Function: FPDFPage_InsertObject
     90 //          Insert an object to the page. The page object is automatically freed.
     91 // Parameters:
     92 //          page        -   Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
     93 //          page_obj    -   Handle to a page object. Returned by FPDFPageObj_NewTextObj,FPDFPageObj_NewTextObjEx and
     94 //                          FPDFPageObj_NewPathObj.
     95 // Return value:
     96 //          None.
     97 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj);
     98 
     99 // Function: FPDFPage_CountObject
    100 //          Get number of page objects inside the page.
    101 // Parameters:
    102 //          page        -   Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
    103 // Return value:
    104 //          The number of the page object.
    105 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page);
    106 
    107 // Function: FPDFPage_GetObject
    108 //          Get page object by index.
    109 // Parameters:
    110 //          page        -   Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
    111 //          index       -   The index of a page object.
    112 // Return value:
    113 //          The handle of the page object. Null for failed.
    114 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index);
    115 
    116 // Function: FPDFPage_HasTransparency
    117 //          Check that whether the content of specified PDF page contains transparency.
    118 // Parameters:
    119 //          page        -   Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
    120 // Return value:
    121 //          TRUE means that the PDF page does contains transparency.
    122 //          Otherwise, returns FALSE.
    123 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page);
    124 
    125 // Function: FPDFPage_GenerateContent
    126 //          Generate PDF Page content.
    127 // Parameters:
    128 //          page        -   Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
    129 // Return value:
    130 //          True if successful, false otherwise.
    131 // Comment:
    132 //          Before you save the page to a file, or reload the page, you must call the FPDFPage_GenerateContent function.
    133 //          Or the changed information will be lost.
    134 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page);
    135 
    136 //////////////////////////////////////////////////////////////////////
    137 //
    138 // Page Object functions
    139 //
    140 //////////////////////////////////////////////////////////////////////
    141 
    142 // Function: FPDFPageObj_HasTransparency
    143 //          Check that whether the specified PDF page object contains transparency.
    144 // Parameters:
    145 //          pageObject  -   Handle to a page object.
    146 // Return value:
    147 //          TRUE means that the PDF page object does contains transparency.
    148 //          Otherwise, returns FALSE.
    149 DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject);
    150 
    151 // Function: FPDFPageObj_Transform
    152 //          Transform (scale, rotate, shear, move) page object.
    153 // Parameters:
    154 //          page_object -   Handle to a page object. Returned by FPDFPageObj_NewImageObj.
    155 //          a           -   The coefficient "a" of the matrix.
    156 //          b           -   The coefficient "b" of the matrix.
    157 //          c           -   The coefficient "c" of the matrix.
    158 //          d           -   The coefficient "d" of the matrix.
    159 //          e           -   The coefficient "e" of the matrix.
    160 //          f           -   The coefficient "f" of the matrix.
    161 // Return value:
    162 //          None.
    163 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
    164                             double a, double b, double c, double d, double e, double f);
    165 
    166 // Function: FPDFPage_TransformAnnots
    167 //          Transform (scale, rotate, shear, move) all annots in a page.
    168 // Parameters:
    169 //          page        -   Handle to a page.
    170 //          a           -   The coefficient "a" of the matrix.
    171 //          b           -   The coefficient "b" of the matrix.
    172 //          c           -   The coefficient "c" of the matrix.
    173 //          d           -   The coefficient "d" of the matrix.
    174 //          e           -   The coefficient "e" of the matrix.
    175 //          f           -   The coefficient "f" of the matrix.
    176 // Return value:
    177 //          None.
    178 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
    179                                              double a, double b, double c, double d, double e, double f);
    180 
    181 // The page object constants.
    182 #define FPDF_PAGEOBJ_TEXT       1
    183 #define FPDF_PAGEOBJ_PATH       2
    184 #define FPDF_PAGEOBJ_IMAGE      3
    185 #define FPDF_PAGEOBJ_SHADING    4
    186 #define FPDF_PAGEOBJ_FORM       5
    187 
    188 //////////////////////////////////////////////////////////////////////
    189 //
    190 // Image functions
    191 //
    192 //////////////////////////////////////////////////////////////////////
    193 
    194 // Function: FPDFPageObj_NewImgeObj
    195 //          Create a new Image Object.
    196 // Parameters:
    197 //          document        -   Handle to document. Returned by FPDF_LoadDocument or FPDF_CreateNewDocument function.
    198 // Return Value:
    199 //          Handle of image object.
    200 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document);
    201 
    202 
    203 // Function: FPDFImageObj_LoadJpegFile
    204 //          Load Image from a JPEG image file and then set it to an image object.
    205 // Parameters:
    206 //          pages           -   Pointers to the start of all loaded pages, could be NULL.
    207 //          nCount          -   Number of pages, could be 0.
    208 //          image_object    -   Handle of image object returned by FPDFPageObj_NewImgeObj.
    209 //          fileAccess      -   The custom file access handler, which specifies the JPEG image file.
    210 //  Return Value:
    211 //          TRUE if successful, FALSE otherwise.
    212 //  Note:
    213 //          The image object might already has an associated image, which is shared and cached by the loaded pages, In this case, we need to clear the cache of image for all the loaded pages.
    214 //          Pass pages and count to this API to clear the image cache.
    215 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCount,FPDF_PAGEOBJECT image_object, FPDF_FILEACCESS* fileAccess);
    216 
    217 
    218 // Function: FPDFImageObj_SetMatrix
    219 //          Set the matrix of an image object.
    220 // Parameters:
    221 //          image_object    -   Handle of image object returned by FPDFPageObj_NewImgeObj.
    222 //          a               -   The coefficient "a" of the matrix.
    223 //          b               -   The coefficient "b" of the matrix.
    224 //          c               -   The coefficient "c" of the matrix.
    225 //          d               -   The coefficient "d" of the matrix.
    226 //          e               -   The coefficient "e" of the matrix.
    227 //          f               -   The coefficient "f" of the matrix.
    228 // Return value:
    229 //          TRUE if successful, FALSE otherwise.
    230 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
    231                                              double a, double b, double c, double d, double e, double f);
    232 
    233 // Function: FPDFImageObj_SetBitmap
    234 //          Set the bitmap to an image object.
    235 // Parameters:
    236 //          pages           -   Pointer's to the start of all loaded pages.
    237 //          nCount          -   Number of pages.
    238 //          image_object    -   Handle of image object returned by FPDFPageObj_NewImgeObj.
    239 //          bitmap          -   The handle of the bitmap which you want to set it to the image object.
    240 // Return value:
    241 //          TRUE if successful, FALSE otherwise.
    242 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap);
    243 
    244 #ifdef __cplusplus
    245 }
    246 #endif
    247 
    248 #endif  // PUBLIC_FPDF_EDIT_H_
    249