• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SAVE_H_
8 #define PUBLIC_FPDF_SAVE_H_
9 
10 // clang-format off
11 // NOLINTNEXTLINE(build/include)
12 #include "fpdfview.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 // Structure for custom file write
19 typedef struct FPDF_FILEWRITE_ {
20   //
21   // Version number of the interface. Currently must be 1.
22   //
23   int version;
24 
25   // Method: WriteBlock
26   //          Output a block of data in your custom way.
27   // Interface Version:
28   //          1
29   // Implementation Required:
30   //          Yes
31   // Comments:
32   //          Called by function FPDF_SaveDocument
33   // Parameters:
34   //          pThis       -   Pointer to the structure itself
35   //          pData       -   Pointer to a buffer to output
36   //          size        -   The size of the buffer.
37   // Return value:
38   //          Should be non-zero if successful, zero for error.
39   int (*WriteBlock)(struct FPDF_FILEWRITE_* pThis,
40                     const void* pData,
41                     unsigned long size);
42 } FPDF_FILEWRITE;
43 
44  // Flags for FPDF_SaveAsCopy()
45 #define FPDF_INCREMENTAL 1
46 #define FPDF_NO_INCREMENTAL 2
47 #define FPDF_REMOVE_SECURITY 3
48 
49 // Function: FPDF_SaveAsCopy
50 //          Saves the copy of specified document in custom way.
51 // Parameters:
52 //          document        -   Handle to document, as returned by
53 //                              FPDF_LoadDocument() or FPDF_CreateNewDocument().
54 //          pFileWrite      -   A pointer to a custom file write structure.
55 //          flags           -   The creating flags.
56 // Return value:
57 //          TRUE for succeed, FALSE for failed.
58 //
59 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDF_SaveAsCopy(FPDF_DOCUMENT document,
60                                                     FPDF_FILEWRITE* pFileWrite,
61                                                     FPDF_DWORD flags);
62 
63 // Function: FPDF_SaveWithVersion
64 //          Same as FPDF_SaveAsCopy(), except the file version of the
65 //          saved document can be specified by the caller.
66 // Parameters:
67 //          document        -   Handle to document.
68 //          pFileWrite      -   A pointer to a custom file write structure.
69 //          flags           -   The creating flags.
70 //          fileVersion     -   The PDF file version. File version: 14 for 1.4,
71 //                              15 for 1.5, ...
72 // Return value:
73 //          TRUE if succeed, FALSE if failed.
74 //
75 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
76 FPDF_SaveWithVersion(FPDF_DOCUMENT document,
77                      FPDF_FILEWRITE* pFileWrite,
78                      FPDF_DWORD flags,
79                      int fileVersion);
80 
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif  // PUBLIC_FPDF_SAVE_H_
86