Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
fpdf_attachment.h
Go to the documentation of this file.
1// Copyright 2017 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef PUBLIC_FPDF_ATTACHMENT_H_
6#define PUBLIC_FPDF_ATTACHMENT_H_
7
8// NOLINTNEXTLINE(build/include)
9#include "fpdfview.h"
10
11#ifdef __cplusplus
12extern "C" {
13#endif // __cplusplus
14
15// Experimental API.
16// Get the number of embedded files in |document|.
17//
18// document - handle to a document.
19//
20// Returns the number of embedded files in |document|.
22FPDFDoc_GetAttachmentCount(FPDF_DOCUMENT document);
23
24// Experimental API.
25// Add an embedded file with |name| in |document|. If |name| is empty, or if
26// |name| is the name of a existing embedded file in |document|, or if
27// |document|'s embedded file name tree is too deep (i.e. |document| has too
28// many embedded files already), then a new attachment will not be added.
29//
30// document - handle to a document.
31// name - name of the new attachment.
32//
33// Returns a handle to the new attachment object, or NULL on failure.
34FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV
35FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name);
36
37// Experimental API.
38// Get the embedded attachment at |index| in |document|. Note that the returned
39// attachment handle is only valid while |document| is open.
40//
41// document - handle to a document.
42// index - the index of the requested embedded file.
43//
44// Returns the handle to the attachment object, or NULL on failure.
45FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV
46FPDFDoc_GetAttachment(FPDF_DOCUMENT document, int index);
47
48// Experimental API.
49// Delete the embedded attachment at |index| in |document|. Note that this does
50// not remove the attachment data from the PDF file; it simply removes the
51// file's entry in the embedded files name tree so that it does not appear in
52// the attachment list. This behavior may change in the future.
53//
54// document - handle to a document.
55// index - the index of the embedded file to be deleted.
56//
57// Returns true if successful.
59FPDFDoc_DeleteAttachment(FPDF_DOCUMENT document, int index);
60
61// Experimental API.
62// Get the name of the |attachment| file. |buffer| is only modified if |buflen|
63// is longer than the length of the file name. On errors, |buffer| is unmodified
64// and the returned length is 0.
65//
66// attachment - handle to an attachment.
67// buffer - buffer for holding the file name, encoded in UTF-16LE.
68// buflen - length of the buffer in bytes.
69//
70// Returns the length of the file name in bytes.
71FPDF_EXPORT unsigned long FPDF_CALLCONV
72FPDFAttachment_GetName(FPDF_ATTACHMENT attachment,
73 FPDF_WCHAR* buffer,
74 unsigned long buflen);
75
76// Experimental API.
77// Check if the params dictionary of |attachment| has |key| as a key.
78//
79// attachment - handle to an attachment.
80// key - the key to look for, encoded in UTF-8.
81//
82// Returns true if |key| exists.
84FPDFAttachment_HasKey(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key);
85
86// Experimental API.
87// Get the type of the value corresponding to |key| in the params dictionary of
88// the embedded |attachment|.
89//
90// attachment - handle to an attachment.
91// key - the key to look for, encoded in UTF-8.
92//
93// Returns the type of the dictionary value.
94FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV
95FPDFAttachment_GetValueType(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key);
96
97// Experimental API.
98// Set the string value corresponding to |key| in the params dictionary of the
99// embedded file |attachment|, overwriting the existing value if any. The value
100// type should be FPDF_OBJECT_STRING after this function call succeeds.
101//
102// attachment - handle to an attachment.
103// key - the key to the dictionary entry, encoded in UTF-8.
104// value - the string value to be set, encoded in UTF-16LE.
105//
106// Returns true if successful.
108FPDFAttachment_SetStringValue(FPDF_ATTACHMENT attachment,
109 FPDF_BYTESTRING key,
110 FPDF_WIDESTRING value);
111
112// Experimental API.
113// Get the string value corresponding to |key| in the params dictionary of the
114// embedded file |attachment|. |buffer| is only modified if |buflen| is longer
115// than the length of the string value. Note that if |key| does not exist in the
116// dictionary or if |key|'s corresponding value in the dictionary is not a
117// string (i.e. the value is not of type FPDF_OBJECT_STRING or
118// FPDF_OBJECT_NAME), then an empty string would be copied to |buffer| and the
119// return value would be 2. On other errors, nothing would be added to |buffer|
120// and the return value would be 0.
121//
122// attachment - handle to an attachment.
123// key - the key to the requested string value, encoded in UTF-8.
124// buffer - buffer for holding the string value encoded in UTF-16LE.
125// buflen - length of the buffer in bytes.
126//
127// Returns the length of the dictionary value string in bytes.
128FPDF_EXPORT unsigned long FPDF_CALLCONV
129FPDFAttachment_GetStringValue(FPDF_ATTACHMENT attachment,
130 FPDF_BYTESTRING key,
131 FPDF_WCHAR* buffer,
132 unsigned long buflen);
133
134// Experimental API.
135// Set the file data of |attachment|, overwriting the existing file data if any.
136// The creation date and checksum will be updated, while all other dictionary
137// entries will be deleted. Note that only contents with |len| smaller than
138// INT_MAX is supported.
139//
140// attachment - handle to an attachment.
141// contents - buffer holding the file data to write to |attachment|.
142// len - length of file data in bytes.
143//
144// Returns true if successful.
146FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment,
147 FPDF_DOCUMENT document,
148 const void* contents,
149 unsigned long len);
150
151// Experimental API.
152// Get the file data of |attachment|.
153// When the attachment file data is readable, true is returned, and |out_buflen|
154// is updated to indicate the file data size. |buffer| is only modified if
155// |buflen| is non-null and long enough to contain the entire file data. Callers
156// must check both the return value and the input |buflen| is no less than the
157// returned |out_buflen| before using the data.
158//
159// Otherwise, when the attachment file data is unreadable or when |out_buflen|
160// is null, false is returned and |buffer| and |out_buflen| remain unmodified.
161//
162// attachment - handle to an attachment.
163// buffer - buffer for holding the file data from |attachment|.
164// buflen - length of the buffer in bytes.
165// out_buflen - pointer to the variable that will receive the minimum buffer
166// size to contain the file data of |attachment|.
167//
168// Returns true on success, false otherwise.
170FPDFAttachment_GetFile(FPDF_ATTACHMENT attachment,
171 void* buffer,
172 unsigned long buflen,
173 unsigned long* out_buflen);
174
175#ifdef __cplusplus
176} // extern "C"
177#endif // __cplusplus
178
179#endif // PUBLIC_FPDF_ATTACHMENT_H_
fxcrt::ByteString ByteString
Definition bytestring.h:180
const CPDF_Dictionary * GetAnnotDict() const
std::vector< RetainPtr< CPDF_Object > >::const_iterator const_iterator
Definition cpdf_array.h:29
bool KeyExist(const ByteString &key) const
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
#define UNSAFE_TODO(...)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetFontSize(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, float *value)
#define FPDF_ANNOT_FILEATTACHMENT
Definition fpdf_annot.h:37
#define FPDF_ANNOT_STAMP
Definition fpdf_annot.h:33
#define FPDF_ANNOT_FLAG_INVISIBLE
Definition fpdf_annot.h:52
#define FPDF_ANNOT_FLAG_NOROTATE
Definition fpdf_annot.h:56
#define FPDF_ANNOT_FLAG_NOZOOM
Definition fpdf_annot.h:55
#define FPDF_ANNOT_FLAG_HIDDEN
Definition fpdf_annot.h:53
#define FPDF_ANNOT_FLAG_PRINT
Definition fpdf_annot.h:54
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_RemoveAnnot(FPDF_PAGE page, int index)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetBorder(FPDF_ANNOTATION annot, float *horizontal_radius, float *vertical_radius, float *border_width)
#define FPDF_ANNOT_APPEARANCEMODE_COUNT
Definition fpdf_annot.h:65
#define FPDF_ANNOT_APPEARANCEMODE_ROLLOVER
Definition fpdf_annot.h:63
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFocusableSubtypesCount(FPDF_FORMHANDLE hHandle)
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetOptionCount(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetVertices(FPDF_ANNOTATION annot, FS_POINTF *buffer, unsigned long length)
#define FPDF_ANNOT_UNDERLINE
Definition fpdf_annot.h:30
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index)
#define FPDF_ANNOT_UNKNOWN
Definition fpdf_annot.h:20
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot, FPDF_BYTESTRING key)
#define FPDF_FORMFLAG_TEXT_MULTILINE
Definition fpdf_annot.h:76
FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV FPDFAnnot_AddFileAttachment(FPDF_ANNOTATION annot, FPDF_WIDESTRING name)
FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot)
#define FPDF_ANNOT_FLAG_READONLY
Definition fpdf_annot.h:58
FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotCount(FPDF_PAGE page)
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFPage_CreateAnnot(FPDF_PAGE page, FPDF_ANNOTATION_SUBTYPE subtype)
#define FPDF_FORMFLAG_NOEXPORT
Definition fpdf_annot.h:72
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_IsChecked(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot)
FPDF_EXPORT FPDF_LINK FPDF_CALLCONV FPDFAnnot_GetLink(FPDF_ANNOTATION annot)
#define FPDF_FORMFLAG_CHOICE_COMBO
Definition fpdf_annot.h:81
#define FPDF_FORMFLAG_CHOICE_EDIT
Definition fpdf_annot.h:82
FPDF_EXPORT FPDF_ANNOTATION_SUBTYPE FPDF_CALLCONV FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot)
#define FPDF_ANNOT_WIDGET
Definition fpdf_annot.h:40
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_AppendAttachmentPoints(FPDF_ANNOTATION annot, const FS_QUADPOINTSF *quad_points)
#define FPDF_ANNOT_HIGHLIGHT
Definition fpdf_annot.h:29
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetFontColor(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, unsigned int *R, unsigned int *G, unsigned int *B)
#define FPDF_FORMFLAG_READONLY
Definition fpdf_annot.h:70
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetOptionLabel(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot, int index, FPDF_WCHAR *buffer, unsigned long buflen)
#define FPDF_ANNOT_INK
Definition fpdf_annot.h:35
#define FPDF_ANNOT_APPEARANCEMODE_NORMAL
Definition fpdf_annot.h:62
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetInkListPath(FPDF_ANNOTATION annot, unsigned long path_index, FS_POINTF *buffer, unsigned long length)
#define FPDF_FORMFLAG_REQUIRED
Definition fpdf_annot.h:71
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_IsOptionSelected(FPDF_FORMHANDLE handle, FPDF_ANNOTATION annot, int index)
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFPage_GetAnnot(FPDF_PAGE page, int index)
#define FPDF_ANNOT_FLAG_LOCKED
Definition fpdf_annot.h:59
#define FPDF_ANNOT_SQUARE
Definition fpdf_annot.h:25
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, FPDF_BYTESTRING key, FPDF_WCHAR *buffer, unsigned long buflen)
FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetNumberValue(FPDF_ANNOTATION annot, FPDF_BYTESTRING key, float *value)
#define FPDF_ANNOT_AACTION_FORMAT
Definition fpdf_annot.h:91
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetURI(FPDF_ANNOTATION annot, const char *uri)
#define FPDF_ANNOT_APPEARANCEMODE_DOWN
Definition fpdf_annot.h:64
#define FPDF_ANNOT_FLAG_NONE
Definition fpdf_annot.h:51
#define FPDF_ANNOT_FLAG_NOVIEW
Definition fpdf_annot.h:57
#define FPDF_ANNOT_REDACT
Definition fpdf_annot.h:48
#define FPDF_ANNOT_POLYGON
Definition fpdf_annot.h:27
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetLine(FPDF_ANNOTATION annot, FS_POINTF *start, FS_POINTF *end)
FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotIndex(FPDF_PAGE page, FPDF_ANNOTATION annot)
#define FPDF_ANNOT_POPUP
Definition fpdf_annot.h:36
#define FPDF_FORMFLAG_TEXT_PASSWORD
Definition fpdf_annot.h:77
FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle, FPDF_PAGE page, const FS_POINTF *point)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAnnot_GetInkListCount(FPDF_ANNOTATION annot)
#define FPDF_FORMFLAG_CHOICE_MULTI_SELECT
Definition fpdf_annot.h:83
@ FPDFANNOT_COLORTYPE_Color
Definition fpdf_annot.h:96
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetBorder(FPDF_ANNOTATION annot, float horizontal_radius, float vertical_radius, float border_width)
#define FPDF_ANNOT_FLAG_TOGGLENOVIEW
Definition fpdf_annot.h:60
#define FPDF_ANNOT_AACTION_KEY_STROKE
Definition fpdf_annot.h:90
FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV FPDFAnnot_GetFileAttachment(FPDF_ANNOTATION annot)
#define FPDF_ANNOT_TEXT
Definition fpdf_annot.h:21
#define FPDF_ANNOT_LINK
Definition fpdf_annot.h:22
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_RemoveInkList(FPDF_ANNOTATION annot)
TEST_F(FPDFAnnotEmbedderTest, SetAP)
FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV FPDFAttachment_GetValueType(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAttachment_SetFile(FPDF_ATTACHMENT attachment, FPDF_DOCUMENT document, const void *contents, unsigned long len)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAttachment_GetStringValue(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key, FPDF_WCHAR *buffer, unsigned long buflen)
FPDF_EXPORT int FPDF_CALLCONV FPDFDoc_GetAttachmentCount(FPDF_DOCUMENT document)
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAttachment_GetName(FPDF_ATTACHMENT attachment, FPDF_WCHAR *buffer, unsigned long buflen)
FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV FPDFDoc_AddAttachment(FPDF_DOCUMENT document, FPDF_WIDESTRING name)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFDoc_DeleteAttachment(FPDF_DOCUMENT document, int index)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAttachment_SetStringValue(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key, FPDF_WIDESTRING value)
FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV FPDFDoc_GetAttachment(FPDF_DOCUMENT document, int index)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAttachment_GetFile(FPDF_ATTACHMENT attachment, void *buffer, unsigned long buflen, unsigned long *out_buflen)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAttachment_HasKey(FPDF_ATTACHMENT attachment, FPDF_BYTESTRING key)
FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDFLink_GetAction(FPDF_LINK link)
Definition fpdf_doc.cpp:361
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetType(FPDF_ACTION action)
Definition fpdf_doc.cpp:180
FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetURIPath(FPDF_DOCUMENT document, FPDF_ACTION action, void *buffer, unsigned long buflen)
Definition fpdf_doc.cpp:231
FPDF_EXPORT FPDF_LINK FPDF_CALLCONV FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y)
Definition fpdf_doc.cpp:307
#define PDFACTION_URI
Definition fpdf_doc.h:24
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFImageObj_SetBitmap(FPDF_PAGE *pages, int count, FPDF_PAGEOBJECT image_object, FPDF_BITMAP bitmap)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_SetStrokeColor(FPDF_PAGEOBJECT page_object, unsigned int R, unsigned int G, unsigned int B, unsigned int A)
FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x, float y)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, int fillmode, FPDF_BOOL stroke)
FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument()
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_SetFillColor(FPDF_PAGEOBJECT page_object, unsigned int R, unsigned int G, unsigned int B, unsigned int A)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_LineTo(FPDF_PAGEOBJECT path, float x, float y)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_BezierTo(FPDF_PAGEOBJECT path, float x1, float y1, float x2, float y2, float x3, float y3)
FPDF_EXPORT int FPDF_CALLCONV FPDFPageObj_GetType(FPDF_PAGEOBJECT page_object)
#define FPDF_PAGEOBJ_PATH
Definition fpdf_edit.h:40
#define FPDF_PAGEOBJ_TEXT
Definition fpdf_edit.h:39
#define FPDF_PAGEOBJ_IMAGE
Definition fpdf_edit.h:41
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_MoveTo(FPDF_PAGEOBJECT path, float x, float y)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_SetMatrix(FPDF_PAGEOBJECT page_object, const FS_MATRIX *matrix)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPageObj_SetStrokeWidth(FPDF_PAGEOBJECT page_object, float width)
FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page)
FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, double a, double b, double c, double d, double e, double f)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FORM_ForceToKillFocus(FPDF_FORMHANDLE hHandle)
#define FPDF_FORMFIELD_CHECKBOX
#define FPDF_FORMFIELD_COMBOBOX
#define FPDF_FORMFIELD_TEXTFIELD
#define FPDF_FORMFIELD_RADIOBUTTON
#define FPDF_FORMFIELD_LISTBOX
FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_LoadCustomDocument(FPDF_FILEACCESS *pFileAccess, FPDF_BYTESTRING password)
FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetHeight(FPDF_BITMAP bitmap)
FPDF_EXPORT void FPDF_CALLCONV FPDFBitmap_Destroy(FPDF_BITMAP bitmap)
FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV FPDFBitmap_Create(int width, int height, int alpha)
FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFBitmap_FillRect(FPDF_BITMAP bitmap, int left, int top, int width, int height, FPDF_DWORD color)
FPDF_EXPORT int FPDF_CALLCONV FPDFBitmap_GetWidth(FPDF_BITMAP bitmap)
#define FPDF_OBJECT_REFERENCE
Definition fpdfview.h:45
#define FPDF_OBJECT_NAME
Definition fpdfview.h:40
#define FPDF_CALLCONV
Definition fpdfview.h:229
#define FPDF_EXPORT
Definition fpdfview.h:223
#define FPDF_OBJECT_STRING
Definition fpdfview.h:39
#define FPDF_ANNOT
Definition fpdfview.h:790
std::unique_ptr< FPDF_WCHAR, pdfium::FreeDeleter > ScopedFPDFWideString
const char kBlankPage612By792Checksum[]
const char * AnnotationStampWithApChecksum()
const char * HelloWorldChecksum()