Home | History | Annotate | Download | only in include
      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	_FPDFEDIT_H_
      8 #define	_FPDFEDIT_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.
     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_InsertObject
     78 //			Insert an object to the page. The page object is automatically freed.
     79 // Parameters:
     80 //			page		-	Handle to a page. Returned by FPDFPage_New.
     81 //			page_obj	-	Handle to a page object. Returned by FPDFPageObj_NewTextObj,FPDFPageObj_NewTextObjEx and
     82 //							FPDFPageObj_NewPathObj.
     83 // Return value:
     84 //			None.
     85 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj);
     86 
     87 // Function: FPDFPage_CountObject
     88 //			Get number of page objects inside the page.
     89 // Parameters:
     90 //			page		-	Handle to a page. Returned by FPDFPage_New.
     91 // Return value:
     92 //			The number of the page object.
     93 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page);
     94 
     95 // Function: FPDFPage_GetObject
     96 //			Get page object by index.
     97 // Parameters:
     98 //			page		-	Handle to a page. Returned by FPDFPage_New.
     99 //			index		-	The index of a page object.
    100 // Return value:
    101 //			The handle of the page object. Null for failed.
    102 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index);
    103 
    104 // Function: FPDFPage_HasTransparency
    105 //			Check that whether the content of specified PDF page contains transparency.
    106 // Parameters:
    107 //			page		-	Handle to a page. Returned by FPDFPage_New or FPDF_LoadPage.
    108 // Return value:
    109 //			TRUE means that the PDF page does contains transparency.
    110 //			Otherwise, returns FALSE.
    111 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page);
    112 
    113 // Function: FPDFPage_GenerateContent
    114 //			Generate PDF Page content.
    115 // Parameters:
    116 //			page		-	Handle to a page. Returned by FPDFPage_New.
    117 // Return value:
    118 //			True if successful, false otherwise.
    119 // Comment:
    120 //			Before you save the page to a file, or reload the page, you must call the FPDFPage_GenerateContent function.
    121 //			Or the changed information will be lost.
    122 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page);
    123 
    124 //////////////////////////////////////////////////////////////////////
    125 //
    126 // Page Object functions
    127 //
    128 //////////////////////////////////////////////////////////////////////
    129 
    130 // Function: FPDFPageObj_HasTransparency
    131 //			Check that whether the specified PDF page object contains transparency.
    132 // Parameters:
    133 //			pageObject	-	Handle to a page object.
    134 // Return value:
    135 //			TRUE means that the PDF page object does contains transparency.
    136 //			Otherwise, returns FALSE.
    137 DLLEXPORT FPDF_BOOL STDCALL FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject);
    138 
    139 // Function: FPDFPageObj_Transform
    140 //			Transform (scale, rotate, shear, move) page object.
    141 // Parameters:
    142 //			page_object	-	Handle to a page object. Returned by FPDFPageObj_NewImageObj.
    143 //			a			-	The coefficient "a" of the matrix.
    144 //			b			-	The	coefficient "b" of the matrix.
    145 //			c			-	The coefficient "c" of the matrix.
    146 //			d			-	The coefficient "d" of the matrix.
    147 //			e			-	The coefficient "e" of the matrix.
    148 //			f			-	The coefficient "f" of the matrix.
    149 // Return value:
    150 //			None.
    151 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object,
    152 							double a, double b, double c, double d, double e, double f);
    153 
    154 // Function: FPDFPage_TransformAnnots
    155 //			Transform (scale, rotate, shear, move) all annots in a page.
    156 // Parameters:
    157 //			page		-	Handle to a page.
    158 //			a			-	The coefficient "a" of the matrix.
    159 //			b			-	The	coefficient "b" of the matrix.
    160 //			c			-	The coefficient "c" of the matrix.
    161 //			d			-	The coefficient "d" of the matrix.
    162 //			e			-	The coefficient "e" of the matrix.
    163 //			f			-	The coefficient "f" of the matrix.
    164 // Return value:
    165 //			None.
    166 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page,
    167 											 double a, double b, double c, double d, double e, double f);
    168 
    169 // The page object constants.
    170 #define FPDF_PAGEOBJ_TEXT		1
    171 #define FPDF_PAGEOBJ_PATH		2
    172 #define FPDF_PAGEOBJ_IMAGE		3
    173 #define FPDF_PAGEOBJ_SHADING	4
    174 #define FPDF_PAGEOBJ_FORM		5
    175 
    176 //////////////////////////////////////////////////////////////////////
    177 //
    178 // Image functions
    179 //
    180 //////////////////////////////////////////////////////////////////////
    181 
    182 // Function: FPDFPageObj_NewImgeObj
    183 //			Create a new Image Object.
    184 // Parameters:
    185 //			document		-	Handle to document. Returned by FPDF_LoadDocument or FPDF_CreateNewDocument function.
    186 // Return Value:
    187 //			Handle of image object.
    188 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document);
    189 
    190 
    191 // Function: FPDFImageObj_LoadJpegFile
    192 //			Load Image from a JPEG image file and then set it to an image object.
    193 // Parameters:
    194 //			pages			-	Pointers to the start of all loaded pages, could be NULL.
    195 //			nCount			-	Number of pages, could be 0.
    196 //			image_object	-	Handle of image object returned by FPDFPageObj_NewImgeObj.
    197 //			fileAccess		-	The custom file access handler, which specifies the JPEG image file.
    198 //	Return Value:
    199 //			TRUE if successful, FALSE otherwise.
    200 //  Note:
    201 //			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.
    202 //			Pass pages and count to this API to clear the image cache.
    203 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, int nCount,FPDF_PAGEOBJECT image_object, FPDF_FILEACCESS* fileAccess);
    204 
    205 
    206 // Function: FPDFImageObj_SetMatrix
    207 //			Set the matrix of an image object.
    208 // Parameters:
    209 //			image_object	-	Handle of image object returned by FPDFPageObj_NewImgeObj.
    210 //			a				-	The coefficient "a" of the matrix.
    211 //			b				-	The coefficient "b" of the matrix.
    212 //			c				-	The coefficient "c" of the matrix.
    213 //			d				-	The coefficient "d" of the matrix.
    214 //			e				-	The coefficient "e" of the matrix.
    215 //			f				-	The coefficient "f" of the matrix.
    216 // Return value:
    217 //			TRUE if successful, FALSE otherwise.
    218 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object,
    219 											 double a, double b, double c, double d, double e, double f);
    220 
    221 // Function: FPDFImageObj_SetBitmap
    222 //			Set the bitmap to an image object.
    223 // Parameters:
    224 //			pages			-	Pointer's to the start of all loaded pages.
    225 //			nCount			-	Number of pages.
    226 //			image_object	-	Handle of image object returned by FPDFPageObj_NewImgeObj.
    227 //			bitmap			-	The handle of the bitmap which you want to set it to the image object.
    228 // Return value:
    229 //			TRUE if successful, FALSE otherwise.
    230 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages,int nCount,FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap);
    231 
    232 #ifdef __cplusplus
    233 }
    234 #endif
    235 #endif // _FPDFEDIT_H_
    236