feat: initial project setup with psagentia agent implementation
Add core Python agent with configuration management, environment setup, and deployment documentation. Includes user/agent profiles, startup scripts, and dependency management for the psagentia system.
This commit is contained in:
+1044
File diff suppressed because it is too large
Load Diff
+84
@@ -0,0 +1,84 @@
|
||||
// Copyright (C) 2004-2025 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_CLEAN_H
|
||||
#define MUPDF_PDF_CLEAN_H
|
||||
|
||||
#include "mupdf/pdf/document.h"
|
||||
#include "mupdf/pdf/image-rewriter.h"
|
||||
|
||||
/**
|
||||
Specifies whether the PDF's structure tree should be dropped or
|
||||
kept when rearranging or subsetting its pages.
|
||||
|
||||
PDF_CLEAN_STRUCTURE_DROP: Remove the structure tree entirely.
|
||||
|
||||
PDF_CLEAN_STRUCTURE_KEEP: Preserve the structure tree. When
|
||||
redacting a document, preserving the structure tree might leak
|
||||
information.
|
||||
*/
|
||||
typedef enum {
|
||||
PDF_CLEAN_STRUCTURE_DROP = 0,
|
||||
PDF_CLEAN_STRUCTURE_KEEP = 1
|
||||
} pdf_clean_options_structure;
|
||||
|
||||
typedef enum {
|
||||
PDF_CLEAN_VECTORIZE_NO = 0,
|
||||
PDF_CLEAN_VECTORIZE_YES = 1
|
||||
} pdf_clean_options_vectorize;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
pdf_write_options write;
|
||||
pdf_image_rewriter_options image;
|
||||
|
||||
int subset_fonts;
|
||||
|
||||
/* PDF_CLEAN_STRUCTURE_DROP to drop the structure tree (default).
|
||||
* PDF_CLEAN_STRUCTURE_KEEP to keep it unchanged.
|
||||
* Future values reserved.
|
||||
*/
|
||||
pdf_clean_options_structure structure;
|
||||
|
||||
/* PDF_CLEAN_VECTORIZE_NO to leave the pages unchanged.
|
||||
* PDF_CLEAN_VECTORIZE_YES to vectorize each page (and flatten any Type 3 fonts).
|
||||
* Future values reserved.
|
||||
*/
|
||||
pdf_clean_options_vectorize vectorize;
|
||||
} pdf_clean_options;
|
||||
|
||||
/*
|
||||
Read infile, and write selected pages to outfile with the given options.
|
||||
*/
|
||||
void pdf_clean_file(fz_context *ctx, char *infile, char *outfile, char *password, pdf_clean_options *opts, int retainlen, char *retainlist[]);
|
||||
|
||||
/*
|
||||
Recreate page tree to include only the pages listed in the array, in the order listed.
|
||||
*/
|
||||
void pdf_rearrange_pages(fz_context *ctx, pdf_document *doc, int count, const int *pages, pdf_clean_options_structure structure);
|
||||
|
||||
/*
|
||||
Recreate given page list (or all pages if count == 0), with text being vectorized.
|
||||
*/
|
||||
void pdf_vectorize_pages(fz_context *ctx, pdf_document *doc, int count, const int *new_page_list, pdf_clean_options_vectorize vectorize);
|
||||
|
||||
#endif
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
// Copyright (C) 2004-2025 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_CMAP_H
|
||||
#define MUPDF_PDF_CMAP_H
|
||||
|
||||
#include "mupdf/fitz/store.h"
|
||||
#include "mupdf/pdf/document.h"
|
||||
|
||||
// The maximum 1-to-many mapping length.
|
||||
// In the PDF reference, the max is 512 bytes for ToUnicode CMaps.
|
||||
// This results in us needing to support up to 256 characters.
|
||||
#define PDF_MRANGE_CAP 256
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short low, high, out;
|
||||
} pdf_range;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int low, high, out;
|
||||
} pdf_xrange;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int low, out;
|
||||
} pdf_mrange;
|
||||
|
||||
typedef struct cmap_splay cmap_splay;
|
||||
|
||||
typedef struct pdf_cmap
|
||||
{
|
||||
fz_storable storable;
|
||||
char cmap_name[32];
|
||||
|
||||
char usecmap_name[32];
|
||||
struct pdf_cmap *usecmap;
|
||||
|
||||
int wmode;
|
||||
|
||||
int codespace_len;
|
||||
struct
|
||||
{
|
||||
int n;
|
||||
unsigned int low;
|
||||
unsigned int high;
|
||||
} codespace[40];
|
||||
|
||||
int rlen, rcap;
|
||||
pdf_range *ranges;
|
||||
|
||||
int xlen, xcap;
|
||||
pdf_xrange *xranges;
|
||||
|
||||
int mlen, mcap;
|
||||
pdf_mrange *mranges;
|
||||
|
||||
int dlen, dcap;
|
||||
int *dict;
|
||||
|
||||
int tlen, tcap, ttop;
|
||||
cmap_splay *tree;
|
||||
} pdf_cmap;
|
||||
|
||||
pdf_cmap *pdf_new_cmap(fz_context *ctx);
|
||||
pdf_cmap *pdf_keep_cmap(fz_context *ctx, pdf_cmap *cmap);
|
||||
void pdf_drop_cmap(fz_context *ctx, pdf_cmap *cmap);
|
||||
void pdf_drop_cmap_imp(fz_context *ctx, fz_storable *cmap);
|
||||
size_t pdf_cmap_size(fz_context *ctx, pdf_cmap *cmap);
|
||||
|
||||
int pdf_cmap_wmode(fz_context *ctx, pdf_cmap *cmap);
|
||||
void pdf_set_cmap_wmode(fz_context *ctx, pdf_cmap *cmap, int wmode);
|
||||
void pdf_set_usecmap(fz_context *ctx, pdf_cmap *cmap, pdf_cmap *usecmap);
|
||||
|
||||
/*
|
||||
Add a codespacerange section.
|
||||
These ranges are used by pdf_decode_cmap to decode
|
||||
multi-byte encoded strings.
|
||||
*/
|
||||
void pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, unsigned int low, unsigned int high, size_t n);
|
||||
|
||||
/*
|
||||
Add a range of contiguous one-to-one mappings (i.e. 1..5 maps to 21..25)
|
||||
*/
|
||||
void pdf_map_range_to_range(fz_context *ctx, pdf_cmap *cmap, unsigned int srclo, unsigned int srchi, int dstlo);
|
||||
|
||||
/*
|
||||
Add a single one-to-many mapping.
|
||||
|
||||
len <= 256.
|
||||
*/
|
||||
void pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, unsigned int one, int *many, size_t len);
|
||||
void pdf_sort_cmap(fz_context *ctx, pdf_cmap *cmap);
|
||||
|
||||
/*
|
||||
Lookup the mapping of a codepoint.
|
||||
*/
|
||||
int pdf_lookup_cmap(pdf_cmap *cmap, unsigned int cpt);
|
||||
int pdf_lookup_cmap_full(pdf_cmap *cmap, unsigned int cpt, int *out);
|
||||
|
||||
/*
|
||||
Use the codespace ranges to extract a codepoint from a
|
||||
multi-byte encoded string.
|
||||
*/
|
||||
int pdf_decode_cmap(pdf_cmap *cmap, unsigned char *s, unsigned char *e, unsigned int *cpt);
|
||||
|
||||
/*
|
||||
Create an Identity-* CMap (for both 1 and 2-byte encodings)
|
||||
*/
|
||||
pdf_cmap *pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes);
|
||||
pdf_cmap *pdf_load_cmap(fz_context *ctx, fz_stream *file);
|
||||
|
||||
/*
|
||||
Load predefined CMap from system.
|
||||
*/
|
||||
pdf_cmap *pdf_load_system_cmap(fz_context *ctx, const char *name);
|
||||
|
||||
/*
|
||||
Load built-in CMap resource.
|
||||
*/
|
||||
pdf_cmap *pdf_load_builtin_cmap(fz_context *ctx, const char *name);
|
||||
|
||||
/*
|
||||
Load CMap stream in PDF file
|
||||
*/
|
||||
pdf_cmap *pdf_load_embedded_cmap(fz_context *ctx, pdf_document *doc, pdf_obj *ref);
|
||||
|
||||
#endif
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
// Copyright (C) 2004-2023 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_CRYPT_H
|
||||
#define MUPDF_PDF_CRYPT_H
|
||||
|
||||
#include "mupdf/pdf/document.h"
|
||||
#include "mupdf/pdf/object.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PDF_ENCRYPT_KEEP,
|
||||
PDF_ENCRYPT_NONE,
|
||||
PDF_ENCRYPT_RC4_40,
|
||||
PDF_ENCRYPT_RC4_128,
|
||||
PDF_ENCRYPT_AES_128,
|
||||
PDF_ENCRYPT_AES_256,
|
||||
PDF_ENCRYPT_UNKNOWN
|
||||
};
|
||||
|
||||
/*
|
||||
Create crypt object for decrypting strings and streams
|
||||
given the Encryption and ID objects.
|
||||
*/
|
||||
pdf_crypt *pdf_new_crypt(fz_context *ctx, pdf_obj *enc, pdf_obj *id);
|
||||
pdf_crypt *pdf_new_encrypt(fz_context *ctx, const char *opwd_utf8, const char *upwd_utf8, pdf_obj *id, int permissions, int algorithm);
|
||||
void pdf_drop_crypt(fz_context *ctx, pdf_crypt *crypt);
|
||||
|
||||
void pdf_crypt_obj(fz_context *ctx, pdf_crypt *crypt, pdf_obj *obj, int num, int gen);
|
||||
fz_stream *pdf_open_crypt(fz_context *ctx, fz_stream *chain, pdf_crypt *crypt, int num, int gen);
|
||||
fz_stream *pdf_open_crypt_with_filter(fz_context *ctx, fz_stream *chain, pdf_crypt *crypt, pdf_obj *name, int num, int gen);
|
||||
|
||||
int pdf_crypt_version(fz_context *ctx, pdf_crypt *crypt);
|
||||
int pdf_crypt_revision(fz_context *ctx, pdf_crypt *crypt);
|
||||
const char *pdf_crypt_method(fz_context *ctx, pdf_crypt *crypt);
|
||||
const char *pdf_crypt_string_method(fz_context *ctx, pdf_crypt *crypt);
|
||||
const char *pdf_crypt_stream_method(fz_context *ctx, pdf_crypt *crypt);
|
||||
int pdf_crypt_length(fz_context *ctx, pdf_crypt *crypt);
|
||||
int pdf_crypt_permissions(fz_context *ctx, pdf_crypt *crypt);
|
||||
int pdf_crypt_encrypt_metadata(fz_context *ctx, pdf_crypt *crypt);
|
||||
unsigned char *pdf_crypt_owner_password(fz_context *ctx, pdf_crypt *crypt);
|
||||
unsigned char *pdf_crypt_user_password(fz_context *ctx, pdf_crypt *crypt);
|
||||
unsigned char *pdf_crypt_owner_encryption(fz_context *ctx, pdf_crypt *crypt);
|
||||
unsigned char *pdf_crypt_user_encryption(fz_context *ctx, pdf_crypt *crypt);
|
||||
unsigned char *pdf_crypt_permissions_encryption(fz_context *ctx, pdf_crypt *crypt);
|
||||
unsigned char *pdf_crypt_key(fz_context *ctx, pdf_crypt *crypt);
|
||||
|
||||
void pdf_print_crypt(fz_context *ctx, fz_output *out, pdf_crypt *crypt);
|
||||
|
||||
void pdf_write_digest(fz_context *ctx, fz_output *out, pdf_obj *byte_range, pdf_obj *field, size_t digest_offset, size_t digest_length, pdf_pkcs7_signer *signer);
|
||||
|
||||
/*
|
||||
User access permissions from PDF reference.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
PDF_PERM_PRINT = 1 << 2,
|
||||
PDF_PERM_MODIFY = 1 << 3,
|
||||
PDF_PERM_COPY = 1 << 4,
|
||||
PDF_PERM_ANNOTATE = 1 << 5,
|
||||
PDF_PERM_FORM = 1 << 8,
|
||||
PDF_PERM_ACCESSIBILITY = 1 << 9, /* deprecated in pdf 2.0 (this permission is always granted) */
|
||||
PDF_PERM_ASSEMBLE = 1 << 10,
|
||||
PDF_PERM_PRINT_HQ = 1 << 11,
|
||||
};
|
||||
|
||||
int pdf_document_permissions(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
int pdf_signature_byte_range(fz_context *ctx, pdf_document *doc, pdf_obj *signature, fz_range *byte_range);
|
||||
|
||||
/*
|
||||
retrieve an fz_stream to read the bytes hashed for the signature
|
||||
*/
|
||||
fz_stream *pdf_signature_hash_bytes(fz_context *ctx, pdf_document *doc, pdf_obj *signature);
|
||||
|
||||
int pdf_signature_incremental_change_since_signing(fz_context *ctx, pdf_document *doc, pdf_obj *signature);
|
||||
int pdf_incremental_change_since_signing_widget(fz_context *ctx, pdf_annot *widget);
|
||||
|
||||
/*
|
||||
Retrieve the contents of a signature as a counted allocated
|
||||
block that must be freed by the caller.
|
||||
*/
|
||||
size_t pdf_signature_contents(fz_context *ctx, pdf_document *doc, pdf_obj *signature, char **contents);
|
||||
|
||||
void pdf_encrypt_data(fz_context *ctx, pdf_crypt *crypt, int num, int gen, void (*fmt_str_out)(fz_context *, void *, const unsigned char *, size_t), void *arg, const unsigned char *s, size_t n);
|
||||
|
||||
size_t pdf_encrypted_len(fz_context *ctx, pdf_crypt *crypt, int num, int gen, size_t len);
|
||||
|
||||
#endif
|
||||
+1063
File diff suppressed because it is too large
Load Diff
+167
@@ -0,0 +1,167 @@
|
||||
// Copyright (C) 2004-2022 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_EVENT_H
|
||||
#define MUPDF_PDF_EVENT_H
|
||||
|
||||
#include "mupdf/pdf/document.h"
|
||||
|
||||
/*
|
||||
Document events: the objects via which MuPDF informs the calling app
|
||||
of occurrences emanating from the document, possibly from user interaction
|
||||
or javascript execution. MuPDF informs the app of document events via a
|
||||
callback.
|
||||
*/
|
||||
|
||||
struct pdf_doc_event
|
||||
{
|
||||
int type;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PDF_DOCUMENT_EVENT_ALERT,
|
||||
PDF_DOCUMENT_EVENT_PRINT,
|
||||
PDF_DOCUMENT_EVENT_LAUNCH_URL,
|
||||
PDF_DOCUMENT_EVENT_MAIL_DOC,
|
||||
PDF_DOCUMENT_EVENT_SUBMIT,
|
||||
PDF_DOCUMENT_EVENT_EXEC_MENU_ITEM,
|
||||
};
|
||||
|
||||
/*
|
||||
set the function via which to receive
|
||||
document events.
|
||||
*/
|
||||
void pdf_set_doc_event_callback(fz_context *ctx, pdf_document *doc, pdf_doc_event_cb *event_cb, pdf_free_doc_event_data_cb *free_event_data_cb, void *data);
|
||||
void *pdf_get_doc_event_callback_data(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/*
|
||||
The various types of document events
|
||||
*/
|
||||
|
||||
/*
|
||||
details of an alert event. In response the app should
|
||||
display an alert dialog with the buttons specified by "button_type_group".
|
||||
If "check_box_message" is non-NULL, a checkbox should be displayed in
|
||||
the lower-left corned along with the message.
|
||||
|
||||
"finally_checked" and "button_pressed" should be set by the app
|
||||
before returning from the callback. "finally_checked" need be set
|
||||
only if "check_box_message" is non-NULL.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
pdf_document *doc;
|
||||
const char *message;
|
||||
int icon_type;
|
||||
int button_group_type;
|
||||
const char *title;
|
||||
int has_check_box;
|
||||
const char *check_box_message;
|
||||
int initially_checked;
|
||||
int finally_checked;
|
||||
int button_pressed;
|
||||
} pdf_alert_event;
|
||||
|
||||
/* Possible values of icon_type */
|
||||
enum
|
||||
{
|
||||
PDF_ALERT_ICON_ERROR,
|
||||
PDF_ALERT_ICON_WARNING,
|
||||
PDF_ALERT_ICON_QUESTION,
|
||||
PDF_ALERT_ICON_STATUS
|
||||
};
|
||||
|
||||
/* Possible values of button_group_type */
|
||||
enum
|
||||
{
|
||||
PDF_ALERT_BUTTON_GROUP_OK,
|
||||
PDF_ALERT_BUTTON_GROUP_OK_CANCEL,
|
||||
PDF_ALERT_BUTTON_GROUP_YES_NO,
|
||||
PDF_ALERT_BUTTON_GROUP_YES_NO_CANCEL
|
||||
};
|
||||
|
||||
/* Possible values of button_pressed */
|
||||
enum
|
||||
{
|
||||
PDF_ALERT_BUTTON_NONE,
|
||||
PDF_ALERT_BUTTON_OK,
|
||||
PDF_ALERT_BUTTON_CANCEL,
|
||||
PDF_ALERT_BUTTON_NO,
|
||||
PDF_ALERT_BUTTON_YES
|
||||
};
|
||||
|
||||
/*
|
||||
access the details of an alert event
|
||||
The returned pointer and all the data referred to by the
|
||||
structure are owned by mupdf and need not be freed by the
|
||||
caller.
|
||||
*/
|
||||
pdf_alert_event *pdf_access_alert_event(fz_context *ctx, pdf_doc_event *evt);
|
||||
|
||||
/*
|
||||
access the details of am execMenuItem
|
||||
event, which consists of just the name of the menu item
|
||||
*/
|
||||
const char *pdf_access_exec_menu_item_event(fz_context *ctx, pdf_doc_event *evt);
|
||||
|
||||
/*
|
||||
details of a launch-url event. The app should
|
||||
open the url, either in a new frame or in the current window.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const char *url;
|
||||
int new_frame;
|
||||
} pdf_launch_url_event;
|
||||
|
||||
/*
|
||||
access the details of a launch-url
|
||||
event. The returned pointer and all data referred to by the structure
|
||||
are owned by mupdf and need not be freed by the caller.
|
||||
*/
|
||||
pdf_launch_url_event *pdf_access_launch_url_event(fz_context *ctx, pdf_doc_event *evt);
|
||||
|
||||
/*
|
||||
details of a mail_doc event. The app should save
|
||||
the current state of the document and email it using the specified
|
||||
parameters.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
int ask_user;
|
||||
const char *to;
|
||||
const char *cc;
|
||||
const char *bcc;
|
||||
const char *subject;
|
||||
const char *message;
|
||||
} pdf_mail_doc_event;
|
||||
|
||||
pdf_mail_doc_event *pdf_access_mail_doc_event(fz_context *ctx, pdf_doc_event *evt);
|
||||
|
||||
void pdf_event_issue_alert(fz_context *ctx, pdf_document *doc, pdf_alert_event *evt);
|
||||
void pdf_event_issue_print(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_event_issue_exec_menu_item(fz_context *ctx, pdf_document *doc, const char *item);
|
||||
void pdf_event_issue_launch_url(fz_context *ctx, pdf_document *doc, const char *url, int new_frame);
|
||||
void pdf_event_issue_mail_doc(fz_context *ctx, pdf_document *doc, pdf_mail_doc_event *evt);
|
||||
|
||||
#endif
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
// Copyright (C) 2004-2025 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_FONT_H
|
||||
#define MUPDF_PDF_FONT_H
|
||||
|
||||
#include "mupdf/pdf/cmap.h"
|
||||
#include "mupdf/fitz/device.h"
|
||||
#include "mupdf/fitz/font.h"
|
||||
|
||||
enum
|
||||
{
|
||||
PDF_FD_FIXED_PITCH = 1 << 0,
|
||||
PDF_FD_SERIF = 1 << 1,
|
||||
PDF_FD_SYMBOLIC = 1 << 2,
|
||||
PDF_FD_SCRIPT = 1 << 3,
|
||||
PDF_FD_NONSYMBOLIC = 1 << 5,
|
||||
PDF_FD_ITALIC = 1 << 6,
|
||||
PDF_FD_ALL_CAP = 1 << 16,
|
||||
PDF_FD_SMALL_CAP = 1 << 17,
|
||||
PDF_FD_FORCE_BOLD = 1 << 18
|
||||
};
|
||||
|
||||
void pdf_load_encoding(const char **estrings, const char *encoding);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short lo;
|
||||
unsigned short hi;
|
||||
int w; /* type3 fonts can be big! */
|
||||
} pdf_hmtx;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned short lo;
|
||||
unsigned short hi;
|
||||
short x;
|
||||
short y;
|
||||
short w;
|
||||
} pdf_vmtx;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
fz_storable storable;
|
||||
size_t size;
|
||||
|
||||
fz_font *font;
|
||||
|
||||
/* FontDescriptor */
|
||||
int flags;
|
||||
float italic_angle;
|
||||
float ascent;
|
||||
float descent;
|
||||
float cap_height;
|
||||
float x_height;
|
||||
float missing_width;
|
||||
|
||||
/* Encoding (CMap) */
|
||||
pdf_cmap *encoding;
|
||||
pdf_cmap *to_ttf_cmap;
|
||||
size_t cid_to_gid_len;
|
||||
unsigned short *cid_to_gid;
|
||||
|
||||
/* ToUnicode */
|
||||
pdf_cmap *to_unicode;
|
||||
size_t cid_to_ucs_len;
|
||||
unsigned short *cid_to_ucs;
|
||||
|
||||
/* Metrics (given in the PDF file) */
|
||||
int wmode;
|
||||
|
||||
int hmtx_len, hmtx_cap;
|
||||
pdf_hmtx dhmtx;
|
||||
pdf_hmtx *hmtx;
|
||||
|
||||
int vmtx_len, vmtx_cap;
|
||||
pdf_vmtx dvmtx;
|
||||
pdf_vmtx *vmtx;
|
||||
|
||||
int is_embedded;
|
||||
} pdf_font_desc;
|
||||
|
||||
void pdf_set_font_wmode(fz_context *ctx, pdf_font_desc *font, int wmode);
|
||||
void pdf_set_default_hmtx(fz_context *ctx, pdf_font_desc *font, int w);
|
||||
void pdf_set_default_vmtx(fz_context *ctx, pdf_font_desc *font, int y, int w);
|
||||
void pdf_add_hmtx(fz_context *ctx, pdf_font_desc *font, int lo, int hi, int w);
|
||||
void pdf_add_vmtx(fz_context *ctx, pdf_font_desc *font, int lo, int hi, int x, int y, int w);
|
||||
void pdf_end_hmtx(fz_context *ctx, pdf_font_desc *font);
|
||||
void pdf_end_vmtx(fz_context *ctx, pdf_font_desc *font);
|
||||
pdf_hmtx pdf_lookup_hmtx(fz_context *ctx, pdf_font_desc *font, int cid);
|
||||
pdf_vmtx pdf_lookup_vmtx(fz_context *ctx, pdf_font_desc *font, int cid);
|
||||
|
||||
void pdf_load_to_unicode(fz_context *ctx, pdf_document *doc, pdf_font_desc *font, const char **strings, char *collection, pdf_obj *cmapstm);
|
||||
|
||||
int pdf_font_cid_to_gid(fz_context *ctx, pdf_font_desc *fontdesc, int cid);
|
||||
const char *pdf_clean_font_name(const char *fontname);
|
||||
|
||||
const unsigned char *pdf_lookup_substitute_font(fz_context *ctx, int mono, int serif, int bold, int italic, int *len);
|
||||
|
||||
pdf_font_desc *pdf_load_type3_font(fz_context *ctx, pdf_document *doc, pdf_resource_stack *rdb, pdf_obj *obj);
|
||||
void pdf_load_type3_glyphs(fz_context *ctx, pdf_document *doc, pdf_font_desc *fontdesc);
|
||||
pdf_font_desc *pdf_load_font(fz_context *ctx, pdf_document *doc, pdf_resource_stack *rdb, pdf_obj *obj);
|
||||
pdf_font_desc *pdf_load_hail_mary_font(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
pdf_font_desc *pdf_new_font_desc(fz_context *ctx);
|
||||
pdf_font_desc *pdf_keep_font(fz_context *ctx, pdf_font_desc *fontdesc);
|
||||
void pdf_drop_font(fz_context *ctx, pdf_font_desc *font);
|
||||
|
||||
void pdf_print_font(fz_context *ctx, fz_output *out, pdf_font_desc *fontdesc);
|
||||
|
||||
void pdf_run_glyph(fz_context *ctx, pdf_document *doc, pdf_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm, void *gstate, fz_default_colorspaces *default_cs, void *fill_gstate, void *stroke_gstate);
|
||||
|
||||
pdf_obj *pdf_add_simple_font(fz_context *ctx, pdf_document *doc, fz_font *font, int encoding);
|
||||
|
||||
/*
|
||||
Creates CID font with Identity-H CMap and a ToUnicode CMap that
|
||||
is created by using the TTF cmap table "backwards" to go from
|
||||
the GID to a Unicode value.
|
||||
|
||||
We can possibly get width information that may have been embedded
|
||||
in the PDF /W array (or W2 if vertical text)
|
||||
*/
|
||||
pdf_obj *pdf_add_cid_font(fz_context *ctx, pdf_document *doc, fz_font *font);
|
||||
|
||||
/*
|
||||
Add a non-embedded UTF16-encoded CID-font for the CJK scripts:
|
||||
CNS1, GB1, Japan1, or Korea1
|
||||
*/
|
||||
pdf_obj *pdf_add_cjk_font(fz_context *ctx, pdf_document *doc, fz_font *font, int script, int wmode, int serif);
|
||||
|
||||
/*
|
||||
Add a substitute font for any script.
|
||||
*/
|
||||
pdf_obj *pdf_add_substitute_font(fz_context *ctx, pdf_document *doc, fz_font *font);
|
||||
|
||||
int pdf_font_writing_supported(fz_context *ctx, fz_font *font);
|
||||
|
||||
/*
|
||||
Subset fonts by scanning the document to establish usage, and then
|
||||
rewriting the font files.
|
||||
|
||||
Calling with pages_len == 0 means do the whole document.
|
||||
|
||||
EXPERIMENTAL AND SUBJECT TO CHANGE.
|
||||
*/
|
||||
void pdf_subset_fonts(fz_context *ctx, pdf_document *doc, int pages_len, const int *pages);
|
||||
|
||||
#endif
|
||||
+381
@@ -0,0 +1,381 @@
|
||||
// Copyright (C) 2004-2025 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_FORM_H
|
||||
#define MUPDF_PDF_FORM_H
|
||||
|
||||
#include "mupdf/fitz/display-list.h"
|
||||
#include "mupdf/pdf/document.h"
|
||||
|
||||
/* Types of widget */
|
||||
enum pdf_widget_type
|
||||
{
|
||||
PDF_WIDGET_TYPE_UNKNOWN,
|
||||
PDF_WIDGET_TYPE_BUTTON,
|
||||
PDF_WIDGET_TYPE_CHECKBOX,
|
||||
PDF_WIDGET_TYPE_COMBOBOX,
|
||||
PDF_WIDGET_TYPE_LISTBOX,
|
||||
PDF_WIDGET_TYPE_RADIOBUTTON,
|
||||
PDF_WIDGET_TYPE_SIGNATURE,
|
||||
PDF_WIDGET_TYPE_TEXT,
|
||||
};
|
||||
|
||||
/* Types of text widget content */
|
||||
enum pdf_widget_tx_format
|
||||
{
|
||||
PDF_WIDGET_TX_FORMAT_NONE,
|
||||
PDF_WIDGET_TX_FORMAT_NUMBER,
|
||||
PDF_WIDGET_TX_FORMAT_SPECIAL,
|
||||
PDF_WIDGET_TX_FORMAT_DATE,
|
||||
PDF_WIDGET_TX_FORMAT_TIME
|
||||
};
|
||||
|
||||
pdf_annot *pdf_keep_widget(fz_context *ctx, pdf_annot *widget);
|
||||
void pdf_drop_widget(fz_context *ctx, pdf_annot *widget);
|
||||
pdf_annot *pdf_first_widget(fz_context *ctx, pdf_page *page);
|
||||
pdf_annot *pdf_next_widget(fz_context *ctx, pdf_annot *previous);
|
||||
int pdf_update_widget(fz_context *ctx, pdf_annot *widget);
|
||||
|
||||
/*
|
||||
create a new signature widget on the specified page, with the
|
||||
specified name.
|
||||
|
||||
The returns pdf_annot reference must be dropped by the caller.
|
||||
This is a change from releases up to an including 1.18, where
|
||||
the returned reference was owned by the page and did not need
|
||||
to be freed by the caller.
|
||||
*/
|
||||
pdf_annot *pdf_create_signature_widget(fz_context *ctx, pdf_page *page, char *name);
|
||||
|
||||
enum pdf_widget_type pdf_widget_type(fz_context *ctx, pdf_annot *widget);
|
||||
|
||||
fz_rect pdf_bound_widget(fz_context *ctx, pdf_annot *widget);
|
||||
|
||||
/*
|
||||
get the maximum number of
|
||||
characters permitted in a text widget
|
||||
*/
|
||||
int pdf_text_widget_max_len(fz_context *ctx, pdf_annot *tw);
|
||||
|
||||
/*
|
||||
get the type of content
|
||||
required by a text widget
|
||||
*/
|
||||
int pdf_text_widget_format(fz_context *ctx, pdf_annot *tw);
|
||||
|
||||
/*
|
||||
get the list of options for a list box or combo box.
|
||||
|
||||
Returns the number of options and fills in their
|
||||
names within the supplied array. Should first be called with a
|
||||
NULL array to find out how big the array should be. If exportval
|
||||
is true, then the export values will be returned and not the list
|
||||
values if there are export values present.
|
||||
*/
|
||||
int pdf_choice_widget_options(fz_context *ctx, pdf_annot *tw, int exportval, const char *opts[]);
|
||||
int pdf_choice_widget_is_multiselect(fz_context *ctx, pdf_annot *tw);
|
||||
|
||||
/*
|
||||
get the value of a choice widget.
|
||||
|
||||
Returns the number of options currently selected and fills in
|
||||
the supplied array with their strings. Should first be called
|
||||
with NULL as the array to find out how big the array need to
|
||||
be. The filled in elements should not be freed by the caller.
|
||||
*/
|
||||
int pdf_choice_widget_value(fz_context *ctx, pdf_annot *tw, const char *opts[]);
|
||||
|
||||
/*
|
||||
set the value of a choice widget.
|
||||
|
||||
The caller should pass the number of options selected and an
|
||||
array of their names
|
||||
*/
|
||||
void pdf_choice_widget_set_value(fz_context *ctx, pdf_annot *tw, int n, const char *opts[]);
|
||||
|
||||
int pdf_choice_field_option_count(fz_context *ctx, pdf_obj *field);
|
||||
const char *pdf_choice_field_option(fz_context *ctx, pdf_obj *field, int exportval, int i);
|
||||
|
||||
int pdf_widget_is_signed(fz_context *ctx, pdf_annot *widget);
|
||||
int pdf_widget_is_readonly(fz_context *ctx, pdf_annot *widget);
|
||||
|
||||
/* Field flags */
|
||||
enum
|
||||
{
|
||||
/* All fields */
|
||||
PDF_FIELD_IS_READ_ONLY = 1,
|
||||
PDF_FIELD_IS_REQUIRED = 1 << 1,
|
||||
PDF_FIELD_IS_NO_EXPORT = 1 << 2,
|
||||
|
||||
/* Text fields */
|
||||
PDF_TX_FIELD_IS_MULTILINE = 1 << 12,
|
||||
PDF_TX_FIELD_IS_PASSWORD = 1 << 13,
|
||||
PDF_TX_FIELD_IS_FILE_SELECT = 1 << 20,
|
||||
PDF_TX_FIELD_IS_DO_NOT_SPELL_CHECK = 1 << 22,
|
||||
PDF_TX_FIELD_IS_DO_NOT_SCROLL = 1 << 23,
|
||||
PDF_TX_FIELD_IS_COMB = 1 << 24,
|
||||
PDF_TX_FIELD_IS_RICH_TEXT = 1 << 25,
|
||||
|
||||
/* Button fields */
|
||||
PDF_BTN_FIELD_IS_NO_TOGGLE_TO_OFF = 1 << 14,
|
||||
PDF_BTN_FIELD_IS_RADIO = 1 << 15,
|
||||
PDF_BTN_FIELD_IS_PUSHBUTTON = 1 << 16,
|
||||
PDF_BTN_FIELD_IS_RADIOS_IN_UNISON = 1 << 25,
|
||||
|
||||
/* Choice fields */
|
||||
PDF_CH_FIELD_IS_COMBO = 1 << 17,
|
||||
PDF_CH_FIELD_IS_EDIT = 1 << 18,
|
||||
PDF_CH_FIELD_IS_SORT = 1 << 19,
|
||||
PDF_CH_FIELD_IS_MULTI_SELECT = 1 << 21,
|
||||
PDF_CH_FIELD_IS_DO_NOT_SPELL_CHECK = 1 << 22,
|
||||
PDF_CH_FIELD_IS_COMMIT_ON_SEL_CHANGE = 1 << 25,
|
||||
};
|
||||
|
||||
void pdf_calculate_form(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_reset_form(fz_context *ctx, pdf_document *doc, pdf_obj *fields, int exclude);
|
||||
|
||||
int pdf_field_type(fz_context *ctx, pdf_obj *field);
|
||||
const char *pdf_field_type_string(fz_context *ctx, pdf_obj *field);
|
||||
int pdf_field_flags(fz_context *ctx, pdf_obj *field);
|
||||
|
||||
/*
|
||||
Retrieve the name for a field as a C string that
|
||||
must be freed by the caller.
|
||||
*/
|
||||
char *pdf_load_field_name(fz_context *ctx, pdf_obj *field);
|
||||
const char *pdf_field_value(fz_context *ctx, pdf_obj *field);
|
||||
void pdf_create_field_name(fz_context *ctx, pdf_document *doc, const char *prefix, char *buf, size_t len);
|
||||
|
||||
char *pdf_field_border_style(fz_context *ctx, pdf_obj *field);
|
||||
void pdf_field_set_border_style(fz_context *ctx, pdf_obj *field, const char *text);
|
||||
void pdf_field_set_button_caption(fz_context *ctx, pdf_obj *field, const char *text);
|
||||
void pdf_field_set_fill_color(fz_context *ctx, pdf_obj *field, pdf_obj *col);
|
||||
void pdf_field_set_text_color(fz_context *ctx, pdf_obj *field, pdf_obj *col);
|
||||
int pdf_field_display(fz_context *ctx, pdf_obj *field);
|
||||
void pdf_field_set_display(fz_context *ctx, pdf_obj *field, int d);
|
||||
const char *pdf_field_label(fz_context *ctx, pdf_obj *field);
|
||||
pdf_obj *pdf_button_field_on_state(fz_context *ctx, pdf_obj *field);
|
||||
|
||||
int pdf_set_field_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, const char *text, int ignore_trigger_events);
|
||||
|
||||
/*
|
||||
Update the text of a text widget.
|
||||
|
||||
The text is first validated by the Field/Keystroke event processing and accepted only if it passes.
|
||||
|
||||
The function returns whether validation passed.
|
||||
*/
|
||||
int pdf_set_text_field_value(fz_context *ctx, pdf_annot *widget, const char *value);
|
||||
int pdf_set_choice_field_value(fz_context *ctx, pdf_annot *widget, const char *value);
|
||||
int pdf_edit_text_field_value(fz_context *ctx, pdf_annot *widget, const char *value, const char *change, int *selStart, int *selEnd, char **newvalue);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *cn;
|
||||
char *o;
|
||||
char *ou;
|
||||
char *email;
|
||||
char *c;
|
||||
}
|
||||
pdf_pkcs7_distinguished_name;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PDF_SIGNATURE_ERROR_OKAY,
|
||||
PDF_SIGNATURE_ERROR_NO_SIGNATURES,
|
||||
PDF_SIGNATURE_ERROR_NO_CERTIFICATE,
|
||||
PDF_SIGNATURE_ERROR_DIGEST_FAILURE,
|
||||
PDF_SIGNATURE_ERROR_SELF_SIGNED,
|
||||
PDF_SIGNATURE_ERROR_SELF_SIGNED_IN_CHAIN,
|
||||
PDF_SIGNATURE_ERROR_NOT_TRUSTED,
|
||||
PDF_SIGNATURE_ERROR_NOT_SIGNED,
|
||||
PDF_SIGNATURE_ERROR_UNKNOWN,
|
||||
} pdf_signature_error;
|
||||
|
||||
/* Increment the reference count for a signer object */
|
||||
typedef pdf_pkcs7_signer *(pdf_pkcs7_keep_signer_fn)(fz_context *ctx, pdf_pkcs7_signer *signer);
|
||||
|
||||
/* Drop a reference for a signer object */
|
||||
typedef void (pdf_pkcs7_drop_signer_fn)(fz_context *ctx, pdf_pkcs7_signer *signer);
|
||||
|
||||
/* Obtain the distinguished name information from a signer object */
|
||||
typedef pdf_pkcs7_distinguished_name *(pdf_pkcs7_get_signing_name_fn)(fz_context *ctx, pdf_pkcs7_signer *signer);
|
||||
|
||||
/* Predict the size of the digest. The actual digest returned by create_digest will be no greater in size */
|
||||
typedef size_t (pdf_pkcs7_max_digest_size_fn)(fz_context *ctx, pdf_pkcs7_signer *signer);
|
||||
|
||||
/* Create a signature based on ranges of bytes drawn from a stream */
|
||||
typedef int (pdf_pkcs7_create_digest_fn)(fz_context *ctx, pdf_pkcs7_signer *signer, fz_stream *in, unsigned char *digest, size_t digest_len);
|
||||
|
||||
struct pdf_pkcs7_signer
|
||||
{
|
||||
pdf_pkcs7_keep_signer_fn *keep;
|
||||
pdf_pkcs7_drop_signer_fn *drop;
|
||||
pdf_pkcs7_get_signing_name_fn *get_signing_name;
|
||||
pdf_pkcs7_max_digest_size_fn *max_digest_size;
|
||||
pdf_pkcs7_create_digest_fn *create_digest;
|
||||
};
|
||||
|
||||
typedef struct pdf_pkcs7_verifier pdf_pkcs7_verifier;
|
||||
|
||||
typedef void (pdf_pkcs7_drop_verifier_fn)(fz_context *ctx, pdf_pkcs7_verifier *verifier);
|
||||
typedef pdf_signature_error (pdf_pkcs7_check_certificate_fn)(fz_context *ctx, pdf_pkcs7_verifier *verifier, unsigned char *signature, size_t len);
|
||||
typedef pdf_signature_error (pdf_pkcs7_check_digest_fn)(fz_context *ctx, pdf_pkcs7_verifier *verifier, fz_stream *in, unsigned char *signature, size_t len);
|
||||
typedef pdf_pkcs7_distinguished_name *(pdf_pkcs7_get_signatory_fn)(fz_context *ctx, pdf_pkcs7_verifier *verifier, unsigned char *signature, size_t len);
|
||||
|
||||
struct pdf_pkcs7_verifier
|
||||
{
|
||||
pdf_pkcs7_drop_verifier_fn *drop;
|
||||
pdf_pkcs7_check_certificate_fn *check_certificate;
|
||||
pdf_pkcs7_check_digest_fn *check_digest;
|
||||
pdf_pkcs7_get_signatory_fn *get_signatory;
|
||||
};
|
||||
|
||||
int pdf_signature_is_signed(fz_context *ctx, pdf_document *doc, pdf_obj *field);
|
||||
void pdf_signature_set_value(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer, int64_t stime);
|
||||
|
||||
int pdf_count_signatures(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
char *pdf_signature_error_description(pdf_signature_error err);
|
||||
|
||||
pdf_pkcs7_distinguished_name *pdf_signature_get_signatory(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_document *doc, pdf_obj *signature);
|
||||
pdf_pkcs7_distinguished_name *pdf_signature_get_widget_signatory(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_annot *widget);
|
||||
void pdf_signature_drop_distinguished_name(fz_context *ctx, pdf_pkcs7_distinguished_name *name);
|
||||
char *pdf_signature_format_distinguished_name(fz_context *ctx, pdf_pkcs7_distinguished_name *name);
|
||||
char *pdf_signature_info(fz_context *ctx, const char *name, pdf_pkcs7_distinguished_name *dn, const char *reason, const char *location, int64_t date, int include_labels);
|
||||
fz_display_list *pdf_signature_appearance_signed(fz_context *ctx, fz_rect rect, fz_text_language lang, fz_image *img, const char *left_text, const char *right_text, int include_logo);
|
||||
fz_display_list *pdf_signature_appearance_unsigned(fz_context *ctx, fz_rect rect, fz_text_language lang);
|
||||
|
||||
pdf_signature_error pdf_check_digest(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_document *doc, pdf_obj *signature);
|
||||
pdf_signature_error pdf_check_certificate(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_document *doc, pdf_obj *signature);
|
||||
pdf_signature_error pdf_check_widget_digest(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_annot *widget);
|
||||
pdf_signature_error pdf_check_widget_certificate(fz_context *ctx, pdf_pkcs7_verifier *verifier, pdf_annot *widget);
|
||||
|
||||
void pdf_clear_signature(fz_context *ctx, pdf_annot *widget);
|
||||
|
||||
/*
|
||||
Sign a signature field, while assigning it an arbitrary appearance determined by a display list.
|
||||
The function pdf_signature_appearance can generate a variety of common signature appearances.
|
||||
*/
|
||||
void pdf_sign_signature_with_appearance(fz_context *ctx, pdf_annot *widget, pdf_pkcs7_signer *signer, int64_t date, fz_display_list *disp_list);
|
||||
|
||||
enum {
|
||||
PDF_SIGNATURE_SHOW_LABELS = 1,
|
||||
PDF_SIGNATURE_SHOW_DN = 2,
|
||||
PDF_SIGNATURE_SHOW_DATE = 4,
|
||||
PDF_SIGNATURE_SHOW_TEXT_NAME = 8,
|
||||
PDF_SIGNATURE_SHOW_GRAPHIC_NAME = 16,
|
||||
PDF_SIGNATURE_SHOW_LOGO = 32,
|
||||
};
|
||||
|
||||
#define PDF_SIGNATURE_DEFAULT_APPEARANCE ( \
|
||||
PDF_SIGNATURE_SHOW_LABELS | \
|
||||
PDF_SIGNATURE_SHOW_DN | \
|
||||
PDF_SIGNATURE_SHOW_DATE | \
|
||||
PDF_SIGNATURE_SHOW_TEXT_NAME | \
|
||||
PDF_SIGNATURE_SHOW_GRAPHIC_NAME | \
|
||||
PDF_SIGNATURE_SHOW_LOGO )
|
||||
|
||||
/*
|
||||
Sign a signature field, while assigning it a default appearance.
|
||||
*/
|
||||
void pdf_sign_signature(fz_context *ctx, pdf_annot *widget,
|
||||
pdf_pkcs7_signer *signer,
|
||||
int appearance_flags,
|
||||
fz_image *graphic,
|
||||
const char *reason,
|
||||
const char *location);
|
||||
|
||||
/*
|
||||
Create a preview of the default signature appearance.
|
||||
*/
|
||||
fz_display_list *pdf_preview_signature_as_display_list(fz_context *ctx,
|
||||
float w, float h, fz_text_language lang,
|
||||
pdf_pkcs7_signer *signer,
|
||||
int appearance_flags,
|
||||
fz_image *graphic,
|
||||
const char *reason,
|
||||
const char *location);
|
||||
|
||||
fz_pixmap *pdf_preview_signature_as_pixmap(fz_context *ctx,
|
||||
int w, int h, fz_text_language lang,
|
||||
pdf_pkcs7_signer *signer,
|
||||
int appearance_flags,
|
||||
fz_image *graphic,
|
||||
const char *reason,
|
||||
const char *location);
|
||||
|
||||
void pdf_drop_signer(fz_context *ctx, pdf_pkcs7_signer *signer);
|
||||
void pdf_drop_verifier(fz_context *ctx, pdf_pkcs7_verifier *verifier);
|
||||
|
||||
void pdf_field_reset(fz_context *ctx, pdf_document *doc, pdf_obj *field);
|
||||
|
||||
pdf_obj *pdf_lookup_field(fz_context *ctx, pdf_obj *form, const char *name);
|
||||
|
||||
/* Form text field editing events: */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *value;
|
||||
const char *change;
|
||||
int selStart, selEnd;
|
||||
int willCommit;
|
||||
char *newChange;
|
||||
char *newValue;
|
||||
} pdf_keystroke_event;
|
||||
|
||||
int pdf_field_event_keystroke(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_keystroke_event *evt);
|
||||
int pdf_field_event_validate(fz_context *ctx, pdf_document *doc, pdf_obj *field, const char *value, char **newvalue);
|
||||
void pdf_field_event_calculate(fz_context *ctx, pdf_document *doc, pdf_obj *field);
|
||||
char *pdf_field_event_format(fz_context *ctx, pdf_document *doc, pdf_obj *field);
|
||||
|
||||
int pdf_annot_field_event_keystroke(fz_context *ctx, pdf_document *doc, pdf_annot *annot, pdf_keystroke_event *evt);
|
||||
|
||||
/* Call these to trigger actions from various UI events: */
|
||||
|
||||
void pdf_document_event_will_close(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_document_event_will_save(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_document_event_did_save(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_document_event_will_print(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_document_event_did_print(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
void pdf_page_event_open(fz_context *ctx, pdf_page *page);
|
||||
void pdf_page_event_close(fz_context *ctx, pdf_page *page);
|
||||
|
||||
void pdf_annot_event_enter(fz_context *ctx, pdf_annot *annot);
|
||||
void pdf_annot_event_exit(fz_context *ctx, pdf_annot *annot);
|
||||
void pdf_annot_event_down(fz_context *ctx, pdf_annot *annot);
|
||||
void pdf_annot_event_up(fz_context *ctx, pdf_annot *annot);
|
||||
void pdf_annot_event_focus(fz_context *ctx, pdf_annot *annot);
|
||||
void pdf_annot_event_blur(fz_context *ctx, pdf_annot *annot);
|
||||
void pdf_annot_event_page_open(fz_context *ctx, pdf_annot *annot);
|
||||
void pdf_annot_event_page_close(fz_context *ctx, pdf_annot *annot);
|
||||
void pdf_annot_event_page_visible(fz_context *ctx, pdf_annot *annot);
|
||||
void pdf_annot_event_page_invisible(fz_context *ctx, pdf_annot *annot);
|
||||
|
||||
/*
|
||||
* Bake appearances of annotations and/or widgets into static page content,
|
||||
* and remove the corresponding interactive PDF objects.
|
||||
*/
|
||||
void pdf_bake_document(fz_context *ctx, pdf_document *doc, int bake_annots, int bake_widgets);
|
||||
|
||||
#endif
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
// Copyright (C) 2004-2021 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_IMAGE_REWRITER_H
|
||||
#define MUPDF_PDF_IMAGE_REWRITER_H
|
||||
|
||||
#include "mupdf/pdf/document.h"
|
||||
|
||||
enum
|
||||
{
|
||||
FZ_SUBSAMPLE_AVERAGE,
|
||||
FZ_SUBSAMPLE_BICUBIC
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
FZ_RECOMPRESS_NEVER,
|
||||
FZ_RECOMPRESS_SAME,
|
||||
FZ_RECOMPRESS_LOSSLESS,
|
||||
FZ_RECOMPRESS_JPEG,
|
||||
FZ_RECOMPRESS_J2K,
|
||||
FZ_RECOMPRESS_FAX
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
FZ_RECOMPRESS_WHEN_SMALLER,
|
||||
FZ_RECOMPRESS_WHEN_ALWAYS
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int color_lossless_image_subsample_method;
|
||||
int color_lossy_image_subsample_method;
|
||||
int color_lossless_image_subsample_threshold; /* 0, or the threshold dpi at which to subsample color images. */
|
||||
int color_lossless_image_subsample_to; /* 0, or the dpi to subsample to */
|
||||
int color_lossy_image_subsample_threshold; /* 0, or the threshold dpi at which to subsample color images. */
|
||||
int color_lossy_image_subsample_to; /* 0, or the dpi to subsample to */
|
||||
int color_lossless_image_recompress_method; /* Which compression method to use for losslessly compressed color images? */
|
||||
int color_lossy_image_recompress_method; /* Which compression method to use for lossy compressed color images? */
|
||||
char *color_lossy_image_recompress_quality;
|
||||
char *color_lossless_image_recompress_quality;
|
||||
int gray_lossless_image_subsample_method;
|
||||
int gray_lossy_image_subsample_method;
|
||||
int gray_lossless_image_subsample_threshold; /* 0, or the threshold at which to subsample gray images. */
|
||||
int gray_lossless_image_subsample_to; /* 0, or the dpi to subsample to */
|
||||
int gray_lossy_image_subsample_threshold; /* 0, or the threshold at which to subsample gray images. */
|
||||
int gray_lossy_image_subsample_to; /* 0, or the dpi to subsample to */
|
||||
int gray_lossless_image_recompress_method; /* Which compression method to use for losslessly compressed gray images? */
|
||||
int gray_lossy_image_recompress_method; /* Which compression method to use for lossy compressed gray images? */
|
||||
char *gray_lossy_image_recompress_quality;
|
||||
char *gray_lossless_image_recompress_quality;
|
||||
int bitonal_image_subsample_method;
|
||||
int bitonal_image_subsample_threshold; /* 0, or the threshold at which to subsample bitonal images. */
|
||||
int bitonal_image_subsample_to; /* 0, or the dpi to subsample to */
|
||||
int bitonal_image_recompress_method; /* Which compression method to use for bitonal images? */
|
||||
char *bitonal_image_recompress_quality;
|
||||
int recompress_when; /* 0 to only recompress if the new one is smaller, 1 to recompress always */
|
||||
} pdf_image_rewriter_options;
|
||||
|
||||
/*
|
||||
Rewrite images within the given document.
|
||||
*/
|
||||
void pdf_rewrite_images(fz_context *ctx, pdf_document *doc, pdf_image_rewriter_options *opts);
|
||||
|
||||
#endif
|
||||
+533
@@ -0,0 +1,533 @@
|
||||
// Copyright (C) 2004-2025 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef PDF_INTERPRET_H
|
||||
#define PDF_INTERPRET_H
|
||||
|
||||
#include "mupdf/pdf/font.h"
|
||||
#include "mupdf/pdf/resource.h"
|
||||
#include "mupdf/pdf/document.h"
|
||||
|
||||
typedef struct pdf_gstate pdf_gstate;
|
||||
typedef struct pdf_processor pdf_processor;
|
||||
|
||||
void *pdf_new_processor(fz_context *ctx, int size);
|
||||
pdf_processor *pdf_keep_processor(fz_context *ctx, pdf_processor *proc);
|
||||
void pdf_close_processor(fz_context *ctx, pdf_processor *proc);
|
||||
void pdf_drop_processor(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/*
|
||||
* Stack of resources used during interpretation (holding page and
|
||||
* xobject/font/type3 glyph resource dictionaries).
|
||||
*/
|
||||
|
||||
struct pdf_resource_stack
|
||||
{
|
||||
pdf_resource_stack *next;
|
||||
pdf_obj *resources;
|
||||
};
|
||||
|
||||
pdf_obj *pdf_lookup_resource(fz_context *ctx, pdf_resource_stack *stack, pdf_obj *type, const char *name);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PDF_PROCESSOR_REQUIRES_DECODED_IMAGES = 1
|
||||
} pdf_processor_requirements;
|
||||
|
||||
struct pdf_processor
|
||||
{
|
||||
int refs;
|
||||
|
||||
int closed;
|
||||
|
||||
/* close the processor. Also closes any chained processors. */
|
||||
void (*close_processor)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*drop_processor)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*reset_processor)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* At any stage, we can have one set of resources in place.
|
||||
* This function gives us a set of resources to use. We remember
|
||||
* any previous set on a stack, so we can pop back to it later.
|
||||
* Our responsibility (as well as remembering it for our own use)
|
||||
* is to pass either it, or a filtered version of it onto any
|
||||
* chained processor. */
|
||||
void (*push_resources)(fz_context *ctx, pdf_processor *proc, pdf_obj *res);
|
||||
|
||||
/* Pop the resources stack. This must be passed on to any chained
|
||||
* processors. This returns a pointer to the resource dict just
|
||||
* popped by the deepest filter. The caller inherits this reference.
|
||||
* NOTE: This must NOT throw as it may be called during cleanup!
|
||||
*/
|
||||
pdf_obj *(*pop_resources)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* general graphics state */
|
||||
void (*op_w)(fz_context *ctx, pdf_processor *proc, float linewidth);
|
||||
void (*op_j)(fz_context *ctx, pdf_processor *proc, int linejoin);
|
||||
void (*op_J)(fz_context *ctx, pdf_processor *proc, int linecap);
|
||||
void (*op_M)(fz_context *ctx, pdf_processor *proc, float miterlimit);
|
||||
void (*op_d)(fz_context *ctx, pdf_processor *proc, pdf_obj *array, float phase);
|
||||
void (*op_ri)(fz_context *ctx, pdf_processor *proc, const char *intent);
|
||||
void (*op_i)(fz_context *ctx, pdf_processor *proc, float flatness);
|
||||
|
||||
void (*op_gs_begin)(fz_context *ctx, pdf_processor *proc, const char *name, pdf_obj *extgstate);
|
||||
void (*op_gs_BM)(fz_context *ctx, pdf_processor *proc, const char *blendmode);
|
||||
void (*op_gs_ca)(fz_context *ctx, pdf_processor *proc, float alpha);
|
||||
void (*op_gs_CA)(fz_context *ctx, pdf_processor *proc, float alpha);
|
||||
void (*op_gs_SMask)(fz_context *ctx, pdf_processor *proc, pdf_obj *smask, fz_colorspace *smask_cs, float *bc, int luminosity, pdf_obj *tr);
|
||||
void (*op_gs_end)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* special graphics state */
|
||||
void (*op_q)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_Q)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_cm)(fz_context *ctx, pdf_processor *proc, float a, float b, float c, float d, float e, float f);
|
||||
|
||||
/* path construction */
|
||||
void (*op_m)(fz_context *ctx, pdf_processor *proc, float x, float y);
|
||||
void (*op_l)(fz_context *ctx, pdf_processor *proc, float x, float y);
|
||||
void (*op_c)(fz_context *ctx, pdf_processor *proc, float x1, float y1, float x2, float y2, float x3, float y3);
|
||||
void (*op_v)(fz_context *ctx, pdf_processor *proc, float x2, float y2, float x3, float y3);
|
||||
void (*op_y)(fz_context *ctx, pdf_processor *proc, float x1, float y1, float x3, float y3);
|
||||
void (*op_h)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_re)(fz_context *ctx, pdf_processor *proc, float x, float y, float w, float h);
|
||||
|
||||
/* path painting */
|
||||
void (*op_S)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_s)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_F)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_f)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_fstar)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_B)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_Bstar)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_b)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_bstar)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_n)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* clipping paths */
|
||||
void (*op_W)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_Wstar)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* text objects */
|
||||
void (*op_BT)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_ET)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* text state */
|
||||
void (*op_Tc)(fz_context *ctx, pdf_processor *proc, float charspace);
|
||||
void (*op_Tw)(fz_context *ctx, pdf_processor *proc, float wordspace);
|
||||
void (*op_Tz)(fz_context *ctx, pdf_processor *proc, float scale);
|
||||
void (*op_TL)(fz_context *ctx, pdf_processor *proc, float leading);
|
||||
void (*op_Tf)(fz_context *ctx, pdf_processor *proc, const char *name, pdf_font_desc *font, float size);
|
||||
void (*op_Tr)(fz_context *ctx, pdf_processor *proc, int render);
|
||||
void (*op_Ts)(fz_context *ctx, pdf_processor *proc, float rise);
|
||||
|
||||
/* text positioning */
|
||||
void (*op_Td)(fz_context *ctx, pdf_processor *proc, float tx, float ty);
|
||||
void (*op_TD)(fz_context *ctx, pdf_processor *proc, float tx, float ty);
|
||||
void (*op_Tm)(fz_context *ctx, pdf_processor *proc, float a, float b, float c, float d, float e, float f);
|
||||
void (*op_Tstar)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* text showing */
|
||||
void (*op_TJ)(fz_context *ctx, pdf_processor *proc, pdf_obj *array);
|
||||
void (*op_Tj)(fz_context *ctx, pdf_processor *proc, char *str, size_t len);
|
||||
void (*op_squote)(fz_context *ctx, pdf_processor *proc, char *str, size_t len);
|
||||
void (*op_dquote)(fz_context *ctx, pdf_processor *proc, float aw, float ac, char *str, size_t len);
|
||||
|
||||
/* type 3 fonts */
|
||||
void (*op_d0)(fz_context *ctx, pdf_processor *proc, float wx, float wy);
|
||||
void (*op_d1)(fz_context *ctx, pdf_processor *proc, float wx, float wy, float llx, float lly, float urx, float ury);
|
||||
|
||||
/* color */
|
||||
void (*op_CS)(fz_context *ctx, pdf_processor *proc, const char *name, fz_colorspace *cs);
|
||||
void (*op_cs)(fz_context *ctx, pdf_processor *proc, const char *name, fz_colorspace *cs);
|
||||
void (*op_SC_pattern)(fz_context *ctx, pdf_processor *proc, const char *name, pdf_pattern *pat, int n, float *color);
|
||||
void (*op_sc_pattern)(fz_context *ctx, pdf_processor *proc, const char *name, pdf_pattern *pat, int n, float *color);
|
||||
void (*op_SC_shade)(fz_context *ctx, pdf_processor *proc, const char *name, fz_shade *shade);
|
||||
void (*op_sc_shade)(fz_context *ctx, pdf_processor *proc, const char *name, fz_shade *shade);
|
||||
void (*op_SC_color)(fz_context *ctx, pdf_processor *proc, int n, float *color);
|
||||
void (*op_sc_color)(fz_context *ctx, pdf_processor *proc, int n, float *color);
|
||||
|
||||
void (*op_G)(fz_context *ctx, pdf_processor *proc, float g);
|
||||
void (*op_g)(fz_context *ctx, pdf_processor *proc, float g);
|
||||
void (*op_RG)(fz_context *ctx, pdf_processor *proc, float r, float g, float b);
|
||||
void (*op_rg)(fz_context *ctx, pdf_processor *proc, float r, float g, float b);
|
||||
void (*op_K)(fz_context *ctx, pdf_processor *proc, float c, float m, float y, float k);
|
||||
void (*op_k)(fz_context *ctx, pdf_processor *proc, float c, float m, float y, float k);
|
||||
|
||||
/* shadings, images, xobjects */
|
||||
void (*op_BI)(fz_context *ctx, pdf_processor *proc, fz_image *image, const char *colorspace_name);
|
||||
void (*op_sh)(fz_context *ctx, pdf_processor *proc, const char *name, fz_shade *shade);
|
||||
void (*op_Do_image)(fz_context *ctx, pdf_processor *proc, const char *name, fz_image *image);
|
||||
void (*op_Do_form)(fz_context *ctx, pdf_processor *proc, const char *name, pdf_obj *form);
|
||||
|
||||
/* marked content */
|
||||
void (*op_MP)(fz_context *ctx, pdf_processor *proc, const char *tag);
|
||||
void (*op_DP)(fz_context *ctx, pdf_processor *proc, const char *tag, pdf_obj *raw, pdf_obj *cooked);
|
||||
void (*op_BMC)(fz_context *ctx, pdf_processor *proc, const char *tag);
|
||||
void (*op_BDC)(fz_context *ctx, pdf_processor *proc, const char *tag, pdf_obj *raw, pdf_obj *cooked);
|
||||
void (*op_EMC)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* compatibility */
|
||||
void (*op_BX)(fz_context *ctx, pdf_processor *proc);
|
||||
void (*op_EX)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* Virtual ops for ExtGState entries */
|
||||
void (*op_gs_OP)(fz_context *ctx, pdf_processor *proc, int b);
|
||||
void (*op_gs_op)(fz_context *ctx, pdf_processor *proc, int b);
|
||||
void (*op_gs_OPM)(fz_context *ctx, pdf_processor *proc, int i);
|
||||
void (*op_gs_UseBlackPtComp)(fz_context *ctx, pdf_processor *proc, pdf_obj *name);
|
||||
|
||||
/* EOD is used to signify end of data (before any finalise/close down/
|
||||
* automatically added gstate pops). */
|
||||
void (*op_EOD)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* END is used to signify end of stream (finalise and close down) */
|
||||
void (*op_END)(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/* interpreter state that persists across content streams */
|
||||
const char *usage;
|
||||
int hidden;
|
||||
|
||||
pdf_processor_requirements requirements;
|
||||
|
||||
/* resource dictionary stack */
|
||||
pdf_resource_stack *rstack;
|
||||
|
||||
/* Unused, except when inited as chain processor */
|
||||
pdf_processor *chain;
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* input */
|
||||
pdf_document *doc;
|
||||
pdf_lexbuf *buf;
|
||||
fz_cookie *cookie;
|
||||
|
||||
/* state */
|
||||
int gstate;
|
||||
int xbalance;
|
||||
int in_text;
|
||||
fz_rect d1_rect;
|
||||
|
||||
/* stack */
|
||||
pdf_obj *obj;
|
||||
char name[256];
|
||||
char string[256];
|
||||
size_t string_len;
|
||||
int top;
|
||||
float stack[32];
|
||||
} pdf_csi;
|
||||
|
||||
void pdf_count_q_balance(fz_context *ctx, pdf_document *doc, pdf_obj *res, pdf_obj *stm, int *prepend, int *append);
|
||||
|
||||
/* Functions to set up pdf_process structures */
|
||||
|
||||
pdf_processor *pdf_new_run_processor(fz_context *ctx, pdf_document *doc, fz_device *dev, fz_matrix ctm, int struct_parent, const char *usage, pdf_gstate *gstate, fz_default_colorspaces *default_cs, fz_cookie *cookie, pdf_gstate *fill_gstate, pdf_gstate *stroke_gstate);
|
||||
|
||||
/*
|
||||
Create a buffer processor.
|
||||
|
||||
This collects the incoming PDF operator stream into an fz_buffer.
|
||||
|
||||
buffer: The (possibly empty) buffer to which operators will be
|
||||
appended.
|
||||
|
||||
ahxencode: If 0, then image streams will be send as binary,
|
||||
otherwise they will be asciihexencoded.
|
||||
|
||||
newlines: If 0, then minimal spacing will be sent. If 1
|
||||
then newlines will be sent after every operator.
|
||||
*/
|
||||
pdf_processor *pdf_new_buffer_processor(fz_context *ctx, fz_buffer *buffer, int ahxencode, int newlines);
|
||||
|
||||
/*
|
||||
Reopen a closed processor to be used again.
|
||||
|
||||
This brings a processor back to life after a close.
|
||||
Not all processors may support this, so this may throw
|
||||
an exception.
|
||||
*/
|
||||
void pdf_reset_processor(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
|
||||
/*
|
||||
Create an output processor. This
|
||||
sends the incoming PDF operator stream to an fz_output stream.
|
||||
|
||||
out: The output stream to which operators will be sent.
|
||||
|
||||
ahxencode: If 0, then image streams will be send as binary,
|
||||
otherwise they will be asciihexencoded.
|
||||
|
||||
newlines: If 0, then minimal spacing will be sent. If 1
|
||||
then newlines will be sent after every operator.
|
||||
*/
|
||||
pdf_processor *pdf_new_output_processor(fz_context *ctx, fz_output *out, int ahxencode, int newlines);
|
||||
|
||||
typedef struct pdf_filter_options pdf_filter_options;
|
||||
|
||||
/*
|
||||
Create a filter processor. This filters the PDF operators
|
||||
it is fed, and passes them down (with some changes) to the
|
||||
child filter.
|
||||
|
||||
chain: The child processor to which the filtered operators
|
||||
will be fed.
|
||||
|
||||
The options field contains a pointer to a structure with
|
||||
filter specific options in.
|
||||
*/
|
||||
typedef pdf_processor *(pdf_filter_factory_fn)(fz_context *ctx, pdf_document *doc, pdf_processor *chain, int struct_parents, fz_matrix transform, pdf_filter_options *options, void *factory_options);
|
||||
|
||||
/*
|
||||
A pdf_filter_factory is a pdf_filter_factory_fn, plus the options
|
||||
needed to instantiate it.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
pdf_filter_factory_fn *filter;
|
||||
void *options;
|
||||
} pdf_filter_factory;
|
||||
|
||||
/*
|
||||
recurse: Filter resources recursively.
|
||||
|
||||
instance_forms: Always recurse on XObject Form resources, but will
|
||||
create a new instance of each XObject Form that is used, filtered
|
||||
individually.
|
||||
|
||||
ascii: If true, escape all binary data in the output.
|
||||
|
||||
no_update: If true, do not update the document at the end.
|
||||
|
||||
opaque: Opaque value that is passed to the complete function.
|
||||
|
||||
complete: A function called at the end of processing.
|
||||
This allows the caller to insert some extra content after
|
||||
all other content.
|
||||
|
||||
filters: Pointer to an array of filter factory/options.
|
||||
The array is terminated by an entry with a NULL factory pointer.
|
||||
Operators will be fed into the filter generated from the first
|
||||
factory function in the list, and from there go to the filter
|
||||
generated from the second factory in the list etc.
|
||||
|
||||
newlines: If 0, then minimal whitespace will be produced. If 1,
|
||||
then a newline will be sent after every operator.
|
||||
*/
|
||||
struct pdf_filter_options
|
||||
{
|
||||
int recurse;
|
||||
int instance_forms;
|
||||
int ascii;
|
||||
int no_update;
|
||||
|
||||
void *opaque;
|
||||
void (*complete)(fz_context *ctx, fz_buffer *buffer, void *opaque);
|
||||
|
||||
pdf_filter_factory *filters;
|
||||
int newlines;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FZ_CULL_PATH_DROP = 0,
|
||||
FZ_CULL_PATH_FILL = 1,
|
||||
FZ_CULL_PATH_STROKE = 2,
|
||||
FZ_CULL_PATH_FILL_STROKE = 3,
|
||||
FZ_CULL_CLIP_PATH_DROP = 4,
|
||||
FZ_CULL_CLIP_PATH_FILL = 5,
|
||||
FZ_CULL_CLIP_PATH_STROKE = 6,
|
||||
FZ_CULL_CLIP_PATH_FILL_STROKE = 7,
|
||||
FZ_CULL_GLYPH = 8,
|
||||
FZ_CULL_IMAGE,
|
||||
FZ_CULL_SHADING
|
||||
} fz_cull_type;
|
||||
|
||||
/*
|
||||
image_filter: A function called to assess whether a given
|
||||
image should be removed or not.
|
||||
|
||||
text_filter: A function called to assess whether a given
|
||||
character should be removed or not.
|
||||
|
||||
after_text_object: A function called after each text object.
|
||||
This allows the caller to insert some extra content if
|
||||
desired.
|
||||
|
||||
culler: A function called to see whether each object should
|
||||
be culled or not.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void *opaque;
|
||||
fz_image *(*image_filter)(fz_context *ctx, void *opaque, fz_matrix ctm, const char *name, fz_image *image, fz_rect scissor);
|
||||
int (*text_filter)(fz_context *ctx, void *opaque, int *ucsbuf, int ucslen, fz_matrix trm, fz_matrix ctm, fz_rect bbox, int tr, float ca, float CA);
|
||||
void (*after_text_object)(fz_context *ctx, void *opaque, pdf_document *doc, pdf_processor *chain, fz_matrix ctm);
|
||||
int (*culler)(fz_context *ctx, void *opaque, fz_rect bbox, fz_cull_type type);
|
||||
}
|
||||
pdf_sanitize_filter_options;
|
||||
|
||||
/*
|
||||
A sanitize filter factory.
|
||||
|
||||
sopts = pointer to pdf_sanitize_filter_options.
|
||||
|
||||
The changes made by a filter generated from this are:
|
||||
|
||||
* No operations are allowed to change the top level gstate.
|
||||
Additional q/Q operators are inserted to prevent this.
|
||||
|
||||
* Repeated/unnecessary colour operators are removed (so,
|
||||
for example, "0 0 0 rg 0 1 rg 0.5 g" would be sanitised to
|
||||
"0.5 g")
|
||||
|
||||
The intention of these changes is to provide a simpler,
|
||||
but equivalent stream, repairing problems with mismatched
|
||||
operators, maintaining structure (such as BMC, EMC calls)
|
||||
and leaving the graphics state in an known (default) state
|
||||
so that subsequent operations (such as synthesising new
|
||||
operators to be appended to the stream) are easier.
|
||||
|
||||
The net graphical effect of the filtered operator stream
|
||||
should be identical to the incoming operator stream.
|
||||
*/
|
||||
pdf_processor *pdf_new_sanitize_filter(fz_context *ctx, pdf_document *doc, pdf_processor *chain, int struct_parents, fz_matrix transform, pdf_filter_options *options, void *sopts);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *opaque;
|
||||
/* To be expanded */
|
||||
}
|
||||
pdf_vectorize_filter_options;
|
||||
|
||||
pdf_processor *pdf_new_vectorize_filter(fz_context *ctx, pdf_document *doc, pdf_processor *chain, int structparents, fz_matrix transform, pdf_filter_options *options, void *vopts);
|
||||
|
||||
pdf_obj *pdf_filter_xobject_instance(fz_context *ctx, pdf_obj *old_xobj, pdf_obj *page_res, fz_matrix ctm, pdf_filter_options *options, pdf_cycle_list *cycle_up);
|
||||
|
||||
void pdf_processor_push_resources(fz_context *ctx, pdf_processor *proc, pdf_obj *res);
|
||||
|
||||
pdf_obj *pdf_processor_pop_resources(fz_context *ctx, pdf_processor *proc);
|
||||
|
||||
/*
|
||||
opaque: Opaque value that is passed to all the filter functions.
|
||||
|
||||
color_rewrite: function pointer called to rewrite a color
|
||||
On entry:
|
||||
*cs = reference to a pdf object representing the colorspace.
|
||||
|
||||
*n = number of color components
|
||||
|
||||
color = *n color values.
|
||||
|
||||
On exit:
|
||||
*cs either the same (for no change in colorspace) or
|
||||
updated to be a new one. Reference must be dropped, and
|
||||
a new kept reference returned!
|
||||
|
||||
*n = number of color components (maybe updated)
|
||||
|
||||
color = *n color values (maybe updated)
|
||||
|
||||
image_rewrite: function pointer called to rewrite an image
|
||||
On entry:
|
||||
*image = reference to an fz_image.
|
||||
|
||||
On exit:
|
||||
*image either the same (for no change) or updated
|
||||
to be a new one. Reference must be dropped, and a
|
||||
new kept reference returned.
|
||||
|
||||
share_rewrite: function pointer called to rewrite a shade
|
||||
|
||||
repeated_image_rewrite: If 0, then each image is rewritten only once.
|
||||
Otherwise, it is called for every instance (useful if gathering
|
||||
information about the ctm).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
void *opaque;
|
||||
void (*color_rewrite)(fz_context *ctx, void *opaque, pdf_obj **cs, int *n, float color[FZ_MAX_COLORS]);
|
||||
void (*image_rewrite)(fz_context *ctx, void *opaque, fz_image **image, fz_matrix ctm, pdf_obj *obj);
|
||||
pdf_shade_recolorer *shade_rewrite;
|
||||
int repeated_image_rewrite;
|
||||
} pdf_color_filter_options;
|
||||
|
||||
pdf_processor *
|
||||
pdf_new_color_filter(fz_context *ctx, pdf_document *doc, pdf_processor *chain, int struct_parents, fz_matrix transform, pdf_filter_options *options, void *copts);
|
||||
|
||||
/*
|
||||
Functions to actually process annotations, glyphs and general stream objects.
|
||||
*/
|
||||
void pdf_process_contents(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_obj *res, pdf_obj *stm, fz_cookie *cookie, pdf_obj **out_res);
|
||||
void pdf_process_annot(fz_context *ctx, pdf_processor *proc, pdf_annot *annot, fz_cookie *cookie);
|
||||
void pdf_process_glyph(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_obj *resources, fz_buffer *contents);
|
||||
|
||||
/*
|
||||
Function to process a contents stream without handling the resources.
|
||||
The caller is responsible for pushing/popping the resources.
|
||||
*/
|
||||
void pdf_process_raw_contents(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_obj *stmobj, fz_cookie *cookie);
|
||||
|
||||
/* Text handling helper functions */
|
||||
typedef struct
|
||||
{
|
||||
float char_space;
|
||||
float word_space;
|
||||
float scale;
|
||||
float leading;
|
||||
pdf_font_desc *font;
|
||||
fz_string *fontname;
|
||||
float size;
|
||||
int render;
|
||||
float rise;
|
||||
} pdf_text_state;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
fz_text *clip_text; /* accumulator for clip mode text */
|
||||
fz_text *text;
|
||||
fz_rect text_bbox;
|
||||
fz_matrix tlm;
|
||||
fz_matrix tm;
|
||||
int text_mode;
|
||||
|
||||
int cid;
|
||||
int gid;
|
||||
fz_rect char_bbox;
|
||||
pdf_font_desc *fontdesc;
|
||||
float char_tx;
|
||||
float char_ty;
|
||||
} pdf_text_object_state;
|
||||
|
||||
void pdf_tos_save(fz_context *ctx, pdf_text_object_state *tos, fz_matrix save[2]);
|
||||
void pdf_tos_restore(fz_context *ctx, pdf_text_object_state *tos, fz_matrix save[2]);
|
||||
fz_text *pdf_tos_get_text(fz_context *ctx, pdf_text_object_state *tos);
|
||||
fz_text *pdf_tos_get_clip_text(fz_context *ctx, pdf_text_object_state *tos);
|
||||
void pdf_tos_reset(fz_context *ctx, pdf_text_object_state *tos, int render);
|
||||
void pdf_tos_accumulate_clip(fz_context *ctx, pdf_text_object_state *tos);
|
||||
int pdf_tos_make_trm(fz_context *ctx, pdf_text_object_state *tos, pdf_text_state *text, pdf_font_desc *fontdesc, int cid, fz_matrix *trm, float *adv);
|
||||
void pdf_tos_move_after_char(fz_context *ctx, pdf_text_object_state *tos);
|
||||
void pdf_tos_translate(pdf_text_object_state *tos, float tx, float ty);
|
||||
void pdf_tos_set_matrix(pdf_text_object_state *tos, float a, float b, float c, float d, float e, float f);
|
||||
void pdf_tos_newline(pdf_text_object_state *tos, float leading);
|
||||
|
||||
#endif
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// Copyright (C) 2004-2025 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_JAVASCRIPT_H
|
||||
#define MUPDF_PDF_JAVASCRIPT_H
|
||||
|
||||
#include "mupdf/pdf/document.h"
|
||||
#include "mupdf/pdf/form.h"
|
||||
|
||||
void pdf_enable_js(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_disable_js(fz_context *ctx, pdf_document *doc);
|
||||
int pdf_js_supported(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_drop_js(fz_context *ctx, pdf_js *js);
|
||||
|
||||
void pdf_js_event_init(pdf_js *js, pdf_obj *target, const char *value, int willCommit);
|
||||
int pdf_js_event_result(pdf_js *js);
|
||||
int pdf_js_event_result_validate(pdf_js *js, char **newvalue);
|
||||
char *pdf_js_event_value(pdf_js *js);
|
||||
void pdf_js_event_init_keystroke(pdf_js *js, pdf_obj *target, pdf_keystroke_event *evt);
|
||||
int pdf_js_event_result_keystroke(pdf_js *js, pdf_keystroke_event *evt);
|
||||
|
||||
void pdf_js_execute(pdf_js *js, const char *name, const char *code, char **result);
|
||||
|
||||
#endif
|
||||
+631
@@ -0,0 +1,631 @@
|
||||
// Copyright (C) 2004-2025 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
/* Alphabetically sorted list of all PDF names to be available as constants */
|
||||
PDF_MAKE_NAME("1.2", 1_2)
|
||||
PDF_MAKE_NAME("1.5", 1_5)
|
||||
PDF_MAKE_NAME("3D", 3D)
|
||||
PDF_MAKE_NAME("A", A)
|
||||
PDF_MAKE_NAME("A85", A85)
|
||||
PDF_MAKE_NAME("AA", AA)
|
||||
PDF_MAKE_NAME("AC", AC)
|
||||
PDF_MAKE_NAME("AESV2", AESV2)
|
||||
PDF_MAKE_NAME("AESV3", AESV3)
|
||||
PDF_MAKE_NAME("AF", AF)
|
||||
PDF_MAKE_NAME("AFRelationship", AFRelationship)
|
||||
PDF_MAKE_NAME("AHx", AHx)
|
||||
PDF_MAKE_NAME("AP", AP)
|
||||
PDF_MAKE_NAME("AS", AS)
|
||||
PDF_MAKE_NAME("ASCII85Decode", ASCII85Decode)
|
||||
PDF_MAKE_NAME("ASCIIHexDecode", ASCIIHexDecode)
|
||||
PDF_MAKE_NAME("AbsoluteColorimetric", AbsoluteColorimetric)
|
||||
PDF_MAKE_NAME("AcroForm", AcroForm)
|
||||
PDF_MAKE_NAME("Action", Action)
|
||||
PDF_MAKE_NAME("ActualText", ActualText)
|
||||
PDF_MAKE_NAME("Adobe.PPKLite", Adobe_PPKLite)
|
||||
PDF_MAKE_NAME("All", All)
|
||||
PDF_MAKE_NAME("AllOff", AllOff)
|
||||
PDF_MAKE_NAME("AllOn", AllOn)
|
||||
PDF_MAKE_NAME("Alpha", Alpha)
|
||||
PDF_MAKE_NAME("Alt", Alt)
|
||||
PDF_MAKE_NAME("Alternate", Alternate)
|
||||
PDF_MAKE_NAME("Alternative", Alternative)
|
||||
PDF_MAKE_NAME("Annot", Annot)
|
||||
PDF_MAKE_NAME("Annots", Annots)
|
||||
PDF_MAKE_NAME("AnyOff", AnyOff)
|
||||
PDF_MAKE_NAME("App", App)
|
||||
PDF_MAKE_NAME("Approved", Approved)
|
||||
PDF_MAKE_NAME("Art", Art)
|
||||
PDF_MAKE_NAME("ArtBox", ArtBox)
|
||||
PDF_MAKE_NAME("Artifact", Artifact)
|
||||
PDF_MAKE_NAME("AsIs", AsIs)
|
||||
PDF_MAKE_NAME("Ascent", Ascent)
|
||||
PDF_MAKE_NAME("Aside", Aside)
|
||||
PDF_MAKE_NAME("AuthEvent", AuthEvent)
|
||||
PDF_MAKE_NAME("Author", Author)
|
||||
PDF_MAKE_NAME("B", B)
|
||||
PDF_MAKE_NAME("BBox", BBox)
|
||||
PDF_MAKE_NAME("BC", BC)
|
||||
PDF_MAKE_NAME("BE", BE)
|
||||
PDF_MAKE_NAME("BG", BG)
|
||||
PDF_MAKE_NAME("BM", BM)
|
||||
PDF_MAKE_NAME("BPC", BPC)
|
||||
PDF_MAKE_NAME("BS", BS)
|
||||
PDF_MAKE_NAME("Background", Background)
|
||||
PDF_MAKE_NAME("BaseEncoding", BaseEncoding)
|
||||
PDF_MAKE_NAME("BaseFont", BaseFont)
|
||||
PDF_MAKE_NAME("BaseState", BaseState)
|
||||
PDF_MAKE_NAME("BibEntry", BibEntry)
|
||||
PDF_MAKE_NAME("BitsPerComponent", BitsPerComponent)
|
||||
PDF_MAKE_NAME("BitsPerCoordinate", BitsPerCoordinate)
|
||||
PDF_MAKE_NAME("BitsPerFlag", BitsPerFlag)
|
||||
PDF_MAKE_NAME("BitsPerSample", BitsPerSample)
|
||||
PDF_MAKE_NAME("BlackIs1", BlackIs1)
|
||||
PDF_MAKE_NAME("BlackPoint", BlackPoint)
|
||||
PDF_MAKE_NAME("BleedBox", BleedBox)
|
||||
PDF_MAKE_NAME("Blinds", Blinds)
|
||||
PDF_MAKE_NAME("BlockQuote", BlockQuote)
|
||||
PDF_MAKE_NAME("Border", Border)
|
||||
PDF_MAKE_NAME("Bounds", Bounds)
|
||||
PDF_MAKE_NAME("Box", Box)
|
||||
PDF_MAKE_NAME("Br", Br)
|
||||
PDF_MAKE_NAME("BrotliDecode", BrotliDecode)
|
||||
PDF_MAKE_NAME("Bt", Bt)
|
||||
PDF_MAKE_NAME("Btn", Btn)
|
||||
PDF_MAKE_NAME("Butt", Butt)
|
||||
PDF_MAKE_NAME("ByteRange", ByteRange)
|
||||
PDF_MAKE_NAME("C", C)
|
||||
PDF_MAKE_NAME("C0", C0)
|
||||
PDF_MAKE_NAME("C1", C1)
|
||||
PDF_MAKE_NAME("CA", CA)
|
||||
PDF_MAKE_NAME("CCF", CCF)
|
||||
PDF_MAKE_NAME("CCITTFaxDecode", CCITTFaxDecode)
|
||||
PDF_MAKE_NAME("CF", CF)
|
||||
PDF_MAKE_NAME("CFM", CFM)
|
||||
PDF_MAKE_NAME("CI", CI)
|
||||
PDF_MAKE_NAME("CIDFontType0", CIDFontType0)
|
||||
PDF_MAKE_NAME("CIDFontType0C", CIDFontType0C)
|
||||
PDF_MAKE_NAME("CIDFontType2", CIDFontType2)
|
||||
PDF_MAKE_NAME("CIDSystemInfo", CIDSystemInfo)
|
||||
PDF_MAKE_NAME("CIDToGIDMap", CIDToGIDMap)
|
||||
PDF_MAKE_NAME("CL", CL)
|
||||
PDF_MAKE_NAME("CMYK", CMYK)
|
||||
PDF_MAKE_NAME("CO", CO)
|
||||
PDF_MAKE_NAME("CP", CP)
|
||||
PDF_MAKE_NAME("CS", CS)
|
||||
PDF_MAKE_NAME("CalCMYK", CalCMYK)
|
||||
PDF_MAKE_NAME("CalGray", CalGray)
|
||||
PDF_MAKE_NAME("CalRGB", CalRGB)
|
||||
PDF_MAKE_NAME("Cap", Cap)
|
||||
PDF_MAKE_NAME("CapHeight", CapHeight)
|
||||
PDF_MAKE_NAME("Caption", Caption)
|
||||
PDF_MAKE_NAME("Caret", Caret)
|
||||
PDF_MAKE_NAME("Catalog", Catalog)
|
||||
PDF_MAKE_NAME("Cert", Cert)
|
||||
PDF_MAKE_NAME("Ch", Ch)
|
||||
PDF_MAKE_NAME("Changes", Changes)
|
||||
PDF_MAKE_NAME("CharProcs", CharProcs)
|
||||
PDF_MAKE_NAME("CheckSum", CheckSum)
|
||||
PDF_MAKE_NAME("Circle", Circle)
|
||||
PDF_MAKE_NAME("ClosedArrow", ClosedArrow)
|
||||
PDF_MAKE_NAME("Code", Code)
|
||||
PDF_MAKE_NAME("ColSpan", ColSpan)
|
||||
PDF_MAKE_NAME("Collection", Collection)
|
||||
PDF_MAKE_NAME("ColorSpace", ColorSpace)
|
||||
PDF_MAKE_NAME("ColorTransform", ColorTransform)
|
||||
PDF_MAKE_NAME("Colorants", Colorants)
|
||||
PDF_MAKE_NAME("Colors", Colors)
|
||||
PDF_MAKE_NAME("Columns", Columns)
|
||||
PDF_MAKE_NAME("Confidential", Confidential)
|
||||
PDF_MAKE_NAME("Configs", Configs)
|
||||
PDF_MAKE_NAME("ContactInfo", ContactInfo)
|
||||
PDF_MAKE_NAME("Contents", Contents)
|
||||
PDF_MAKE_NAME("Coords", Coords)
|
||||
PDF_MAKE_NAME("Count", Count)
|
||||
PDF_MAKE_NAME("Cover", Cover)
|
||||
PDF_MAKE_NAME("CreationDate", CreationDate)
|
||||
PDF_MAKE_NAME("Creator", Creator)
|
||||
PDF_MAKE_NAME("CropBox", CropBox)
|
||||
PDF_MAKE_NAME("Crypt", Crypt)
|
||||
PDF_MAKE_NAME("D", D)
|
||||
PDF_MAKE_NAME("DA", DA)
|
||||
PDF_MAKE_NAME("DC", DC)
|
||||
PDF_MAKE_NAME("DCT", DCT)
|
||||
PDF_MAKE_NAME("DCTDecode", DCTDecode)
|
||||
PDF_MAKE_NAME("DL", DL)
|
||||
PDF_MAKE_NAME("DOS", DOS)
|
||||
PDF_MAKE_NAME("DP", DP)
|
||||
PDF_MAKE_NAME("DR", DR)
|
||||
PDF_MAKE_NAME("DS", DS)
|
||||
PDF_MAKE_NAME("DV", DV)
|
||||
PDF_MAKE_NAME("DW", DW)
|
||||
PDF_MAKE_NAME("DW2", DW2)
|
||||
PDF_MAKE_NAME("DamagedRowsBeforeError", DamagedRowsBeforeError)
|
||||
PDF_MAKE_NAME("Data", Data)
|
||||
PDF_MAKE_NAME("Date", Date)
|
||||
PDF_MAKE_NAME("Decode", Decode)
|
||||
PDF_MAKE_NAME("DecodeParms", DecodeParms)
|
||||
PDF_MAKE_NAME("Default", Default)
|
||||
PDF_MAKE_NAME("DefaultCMYK", DefaultCMYK)
|
||||
PDF_MAKE_NAME("DefaultGray", DefaultGray)
|
||||
PDF_MAKE_NAME("DefaultRGB", DefaultRGB)
|
||||
PDF_MAKE_NAME("Departmental", Departmental)
|
||||
PDF_MAKE_NAME("Desc", Desc)
|
||||
PDF_MAKE_NAME("DescendantFonts", DescendantFonts)
|
||||
PDF_MAKE_NAME("Descent", Descent)
|
||||
PDF_MAKE_NAME("Design", Design)
|
||||
PDF_MAKE_NAME("Dest", Dest)
|
||||
PDF_MAKE_NAME("DestOutputProfile", DestOutputProfile)
|
||||
PDF_MAKE_NAME("Dests", Dests)
|
||||
PDF_MAKE_NAME("DeviceCMYK", DeviceCMYK)
|
||||
PDF_MAKE_NAME("DeviceGray", DeviceGray)
|
||||
PDF_MAKE_NAME("DeviceN", DeviceN)
|
||||
PDF_MAKE_NAME("DeviceRGB", DeviceRGB)
|
||||
PDF_MAKE_NAME("Di", Di)
|
||||
PDF_MAKE_NAME("Diamond", Diamond)
|
||||
PDF_MAKE_NAME("Differences", Differences)
|
||||
PDF_MAKE_NAME("DigestLocation", DigestLocation)
|
||||
PDF_MAKE_NAME("DigestMethod", DigestMethod)
|
||||
PDF_MAKE_NAME("DigestValue", DigestValue)
|
||||
PDF_MAKE_NAME("Dissolve", Dissolve)
|
||||
PDF_MAKE_NAME("Div", Div)
|
||||
PDF_MAKE_NAME("Dm", Dm)
|
||||
PDF_MAKE_NAME("DocMDP", DocMDP)
|
||||
PDF_MAKE_NAME("Document", Document)
|
||||
PDF_MAKE_NAME("DocumentFragment", DocumentFragment)
|
||||
PDF_MAKE_NAME("Domain", Domain)
|
||||
PDF_MAKE_NAME("Draft", Draft)
|
||||
PDF_MAKE_NAME("Dur", Dur)
|
||||
PDF_MAKE_NAME("E", E)
|
||||
PDF_MAKE_NAME("EF", EF)
|
||||
PDF_MAKE_NAME("EarlyChange", EarlyChange)
|
||||
PDF_MAKE_NAME("Em", Em)
|
||||
PDF_MAKE_NAME("EmbeddedFile", EmbeddedFile)
|
||||
PDF_MAKE_NAME("EmbeddedFiles", EmbeddedFiles)
|
||||
PDF_MAKE_NAME("Encode", Encode)
|
||||
PDF_MAKE_NAME("EncodedByteAlign", EncodedByteAlign)
|
||||
PDF_MAKE_NAME("Encoding", Encoding)
|
||||
PDF_MAKE_NAME("Encrypt", Encrypt)
|
||||
PDF_MAKE_NAME("EncryptMetadata", EncryptMetadata)
|
||||
PDF_MAKE_NAME("EncryptedPayload", EncryptedPayload)
|
||||
PDF_MAKE_NAME("EndOfBlock", EndOfBlock)
|
||||
PDF_MAKE_NAME("EndOfLine", EndOfLine)
|
||||
PDF_MAKE_NAME("Exclude", Exclude)
|
||||
PDF_MAKE_NAME("Experimental", Experimental)
|
||||
PDF_MAKE_NAME("Expired", Expired)
|
||||
PDF_MAKE_NAME("ExtGState", ExtGState)
|
||||
PDF_MAKE_NAME("Extend", Extend)
|
||||
PDF_MAKE_NAME("F", F)
|
||||
PDF_MAKE_NAME("FENote", FENote)
|
||||
PDF_MAKE_NAME("FL", FL)
|
||||
PDF_MAKE_NAME("FRM", FRM)
|
||||
PDF_MAKE_NAME("FS", FS)
|
||||
PDF_MAKE_NAME("FT", FT)
|
||||
PDF_MAKE_NAME("Fade", Fade)
|
||||
PDF_MAKE_NAME("Ff", Ff)
|
||||
PDF_MAKE_NAME("FieldMDP", FieldMDP)
|
||||
PDF_MAKE_NAME("Fields", Fields)
|
||||
PDF_MAKE_NAME("Figure", Figure)
|
||||
PDF_MAKE_NAME("FileAttachment", FileAttachment)
|
||||
PDF_MAKE_NAME("FileSize", FileSize)
|
||||
PDF_MAKE_NAME("FileSpec", FileSpec)
|
||||
PDF_MAKE_NAME("Filespec", Filespec)
|
||||
PDF_MAKE_NAME("Filter", Filter)
|
||||
PDF_MAKE_NAME("Final", Final)
|
||||
PDF_MAKE_NAME("Fingerprint", Fingerprint)
|
||||
PDF_MAKE_NAME("First", First)
|
||||
PDF_MAKE_NAME("FirstChar", FirstChar)
|
||||
PDF_MAKE_NAME("FirstPage", FirstPage)
|
||||
PDF_MAKE_NAME("Fit", Fit)
|
||||
PDF_MAKE_NAME("FitB", FitB)
|
||||
PDF_MAKE_NAME("FitBH", FitBH)
|
||||
PDF_MAKE_NAME("FitBV", FitBV)
|
||||
PDF_MAKE_NAME("FitH", FitH)
|
||||
PDF_MAKE_NAME("FitR", FitR)
|
||||
PDF_MAKE_NAME("FitV", FitV)
|
||||
PDF_MAKE_NAME("Fl", Fl)
|
||||
PDF_MAKE_NAME("Flags", Flags)
|
||||
PDF_MAKE_NAME("FlateDecode", FlateDecode)
|
||||
PDF_MAKE_NAME("Fly", Fly)
|
||||
PDF_MAKE_NAME("Font", Font)
|
||||
PDF_MAKE_NAME("FontBBox", FontBBox)
|
||||
PDF_MAKE_NAME("FontDescriptor", FontDescriptor)
|
||||
PDF_MAKE_NAME("FontFile", FontFile)
|
||||
PDF_MAKE_NAME("FontFile2", FontFile2)
|
||||
PDF_MAKE_NAME("FontFile3", FontFile3)
|
||||
PDF_MAKE_NAME("FontMatrix", FontMatrix)
|
||||
PDF_MAKE_NAME("FontName", FontName)
|
||||
PDF_MAKE_NAME("ForComment", ForComment)
|
||||
PDF_MAKE_NAME("ForPublicRelease", ForPublicRelease)
|
||||
PDF_MAKE_NAME("Form", Form)
|
||||
PDF_MAKE_NAME("FormData", FormData)
|
||||
PDF_MAKE_NAME("FormEx", FormEx)
|
||||
PDF_MAKE_NAME("FormType", FormType)
|
||||
PDF_MAKE_NAME("Formula", Formula)
|
||||
PDF_MAKE_NAME("FreeText", FreeText)
|
||||
PDF_MAKE_NAME("FreeTextCallout", FreeTextCallout)
|
||||
PDF_MAKE_NAME("FreeTextTypeWriter", FreeTextTypeWriter)
|
||||
PDF_MAKE_NAME("Function", Function)
|
||||
PDF_MAKE_NAME("FunctionType", FunctionType)
|
||||
PDF_MAKE_NAME("Functions", Functions)
|
||||
PDF_MAKE_NAME("G", G)
|
||||
PDF_MAKE_NAME("GTS_PDFX", GTS_PDFX)
|
||||
PDF_MAKE_NAME("Gamma", Gamma)
|
||||
PDF_MAKE_NAME("Glitter", Glitter)
|
||||
PDF_MAKE_NAME("GoTo", GoTo)
|
||||
PDF_MAKE_NAME("GoToR", GoToR)
|
||||
PDF_MAKE_NAME("Group", Group)
|
||||
PDF_MAKE_NAME("H", H)
|
||||
PDF_MAKE_NAME("H1", H1)
|
||||
PDF_MAKE_NAME("H2", H2)
|
||||
PDF_MAKE_NAME("H3", H3)
|
||||
PDF_MAKE_NAME("H4", H4)
|
||||
PDF_MAKE_NAME("H5", H5)
|
||||
PDF_MAKE_NAME("H6", H6)
|
||||
PDF_MAKE_NAME("Height", Height)
|
||||
PDF_MAKE_NAME("Helv", Helv)
|
||||
PDF_MAKE_NAME("Highlight", Highlight)
|
||||
PDF_MAKE_NAME("HistoryPos", HistoryPos)
|
||||
PDF_MAKE_NAME("I", I)
|
||||
PDF_MAKE_NAME("IC", IC)
|
||||
PDF_MAKE_NAME("ICCBased", ICCBased)
|
||||
PDF_MAKE_NAME("ID", ID)
|
||||
PDF_MAKE_NAME("IM", IM)
|
||||
PDF_MAKE_NAME("IRT", IRT)
|
||||
PDF_MAKE_NAME("IT", IT)
|
||||
PDF_MAKE_NAME("Identity", Identity)
|
||||
PDF_MAKE_NAME("Identity-H", Identity_H)
|
||||
PDF_MAKE_NAME("Identity-V", Identity_V)
|
||||
PDF_MAKE_NAME("Image", Image)
|
||||
PDF_MAKE_NAME("ImageB", ImageB)
|
||||
PDF_MAKE_NAME("ImageC", ImageC)
|
||||
PDF_MAKE_NAME("ImageI", ImageI)
|
||||
PDF_MAKE_NAME("ImageMask", ImageMask)
|
||||
PDF_MAKE_NAME("Include", Include)
|
||||
PDF_MAKE_NAME("Index", Index)
|
||||
PDF_MAKE_NAME("Indexed", Indexed)
|
||||
PDF_MAKE_NAME("Info", Info)
|
||||
PDF_MAKE_NAME("Ink", Ink)
|
||||
PDF_MAKE_NAME("InkList", InkList)
|
||||
PDF_MAKE_NAME("Intent", Intent)
|
||||
PDF_MAKE_NAME("Interpolate", Interpolate)
|
||||
PDF_MAKE_NAME("IsMap", IsMap)
|
||||
PDF_MAKE_NAME("ItalicAngle", ItalicAngle)
|
||||
PDF_MAKE_NAME("JBIG2Decode", JBIG2Decode)
|
||||
PDF_MAKE_NAME("JBIG2Globals", JBIG2Globals)
|
||||
PDF_MAKE_NAME("JPXDecode", JPXDecode)
|
||||
PDF_MAKE_NAME("JS", JS)
|
||||
PDF_MAKE_NAME("JavaScript", JavaScript)
|
||||
PDF_MAKE_NAME("K", K)
|
||||
PDF_MAKE_NAME("Keywords", Keywords)
|
||||
PDF_MAKE_NAME("Kids", Kids)
|
||||
PDF_MAKE_NAME("L", L)
|
||||
PDF_MAKE_NAME("LBody", LBody)
|
||||
PDF_MAKE_NAME("LC", LC)
|
||||
PDF_MAKE_NAME("LE", LE)
|
||||
PDF_MAKE_NAME("LI", LI)
|
||||
PDF_MAKE_NAME("LJ", LJ)
|
||||
PDF_MAKE_NAME("LL", LL)
|
||||
PDF_MAKE_NAME("LLE", LLE)
|
||||
PDF_MAKE_NAME("LLO", LLO)
|
||||
PDF_MAKE_NAME("LW", LW)
|
||||
PDF_MAKE_NAME("LZ", LZ)
|
||||
PDF_MAKE_NAME("LZW", LZW)
|
||||
PDF_MAKE_NAME("LZWDecode", LZWDecode)
|
||||
PDF_MAKE_NAME("Lab", Lab)
|
||||
PDF_MAKE_NAME("Label", Label)
|
||||
PDF_MAKE_NAME("Lang", Lang)
|
||||
PDF_MAKE_NAME("Last", Last)
|
||||
PDF_MAKE_NAME("LastChar", LastChar)
|
||||
PDF_MAKE_NAME("LastPage", LastPage)
|
||||
PDF_MAKE_NAME("Launch", Launch)
|
||||
PDF_MAKE_NAME("Layer", Layer)
|
||||
PDF_MAKE_NAME("Lbl", Lbl)
|
||||
PDF_MAKE_NAME("Length", Length)
|
||||
PDF_MAKE_NAME("Length1", Length1)
|
||||
PDF_MAKE_NAME("Length2", Length2)
|
||||
PDF_MAKE_NAME("Length3", Length3)
|
||||
PDF_MAKE_NAME("Limits", Limits)
|
||||
PDF_MAKE_NAME("Line", Line)
|
||||
PDF_MAKE_NAME("LineArrow", LineArrow)
|
||||
PDF_MAKE_NAME("LineDimension", LineDimension)
|
||||
PDF_MAKE_NAME("Linearized", Linearized)
|
||||
PDF_MAKE_NAME("Link", Link)
|
||||
PDF_MAKE_NAME("List", List)
|
||||
PDF_MAKE_NAME("Location", Location)
|
||||
PDF_MAKE_NAME("Lock", Lock)
|
||||
PDF_MAKE_NAME("Locked", Locked)
|
||||
PDF_MAKE_NAME("Luminosity", Luminosity)
|
||||
PDF_MAKE_NAME("M", M)
|
||||
PDF_MAKE_NAME("MCID", MCID)
|
||||
PDF_MAKE_NAME("MCR", MCR)
|
||||
PDF_MAKE_NAME("MK", MK)
|
||||
PDF_MAKE_NAME("ML", ML)
|
||||
PDF_MAKE_NAME("MMType1", MMType1)
|
||||
PDF_MAKE_NAME("Mac", Mac)
|
||||
PDF_MAKE_NAME("Mask", Mask)
|
||||
PDF_MAKE_NAME("Matrix", Matrix)
|
||||
PDF_MAKE_NAME("Matte", Matte)
|
||||
PDF_MAKE_NAME("MaxLen", MaxLen)
|
||||
PDF_MAKE_NAME("MediaBox", MediaBox)
|
||||
PDF_MAKE_NAME("Metadata", Metadata)
|
||||
PDF_MAKE_NAME("MissingWidth", MissingWidth)
|
||||
PDF_MAKE_NAME("ModDate", ModDate)
|
||||
PDF_MAKE_NAME("Movie", Movie)
|
||||
PDF_MAKE_NAME("Msg", Msg)
|
||||
PDF_MAKE_NAME("Multiply", Multiply)
|
||||
PDF_MAKE_NAME("N", N)
|
||||
PDF_MAKE_NAME("NM", NM)
|
||||
PDF_MAKE_NAME("Name", Name)
|
||||
PDF_MAKE_NAME("Named", Named)
|
||||
PDF_MAKE_NAME("Names", Names)
|
||||
PDF_MAKE_NAME("NeedAppearances", NeedAppearances)
|
||||
PDF_MAKE_NAME("NewWindow", NewWindow)
|
||||
PDF_MAKE_NAME("Next", Next)
|
||||
PDF_MAKE_NAME("NextPage", NextPage)
|
||||
PDF_MAKE_NAME("NonEFontNoWarn", NonEFontNoWarn)
|
||||
PDF_MAKE_NAME("NonStruct", NonStruct)
|
||||
PDF_MAKE_NAME("None", None)
|
||||
PDF_MAKE_NAME("Normal", Normal)
|
||||
PDF_MAKE_NAME("NotApproved", NotApproved)
|
||||
PDF_MAKE_NAME("NotForPublicRelease", NotForPublicRelease)
|
||||
PDF_MAKE_NAME("Note", Note)
|
||||
PDF_MAKE_NAME("NumSections", NumSections)
|
||||
PDF_MAKE_NAME("Nums", Nums)
|
||||
PDF_MAKE_NAME("O", O)
|
||||
PDF_MAKE_NAME("OBJR", OBJR)
|
||||
PDF_MAKE_NAME("OC", OC)
|
||||
PDF_MAKE_NAME("OCG", OCG)
|
||||
PDF_MAKE_NAME("OCGs", OCGs)
|
||||
PDF_MAKE_NAME("OCMD", OCMD)
|
||||
PDF_MAKE_NAME("OCProperties", OCProperties)
|
||||
PDF_MAKE_NAME("OE", OE)
|
||||
PDF_MAKE_NAME("OFF", OFF)
|
||||
PDF_MAKE_NAME("ON", ON)
|
||||
PDF_MAKE_NAME("OP", OP)
|
||||
PDF_MAKE_NAME("OPM", OPM)
|
||||
PDF_MAKE_NAME("OS", OS)
|
||||
PDF_MAKE_NAME("ObjStm", ObjStm)
|
||||
PDF_MAKE_NAME("Of", Of)
|
||||
PDF_MAKE_NAME("Off", Off)
|
||||
PDF_MAKE_NAME("Open", Open)
|
||||
PDF_MAKE_NAME("OpenArrow", OpenArrow)
|
||||
PDF_MAKE_NAME("OpenType", OpenType)
|
||||
PDF_MAKE_NAME("Opt", Opt)
|
||||
PDF_MAKE_NAME("Order", Order)
|
||||
PDF_MAKE_NAME("Ordering", Ordering)
|
||||
PDF_MAKE_NAME("Outlines", Outlines)
|
||||
PDF_MAKE_NAME("OutputCondition", OutputCondition)
|
||||
PDF_MAKE_NAME("OutputConditionIdentifier", OutputConditionIdentifier)
|
||||
PDF_MAKE_NAME("OutputIntent", OutputIntent)
|
||||
PDF_MAKE_NAME("OutputIntents", OutputIntents)
|
||||
PDF_MAKE_NAME("P", P)
|
||||
PDF_MAKE_NAME("PDF", PDF)
|
||||
PDF_MAKE_NAME("PS", PS)
|
||||
PDF_MAKE_NAME("Page", Page)
|
||||
PDF_MAKE_NAME("PageLabels", PageLabels)
|
||||
PDF_MAKE_NAME("PageMode", PageMode)
|
||||
PDF_MAKE_NAME("Pages", Pages)
|
||||
PDF_MAKE_NAME("PaintType", PaintType)
|
||||
PDF_MAKE_NAME("Params", Params)
|
||||
PDF_MAKE_NAME("Parent", Parent)
|
||||
PDF_MAKE_NAME("ParentTree", ParentTree)
|
||||
PDF_MAKE_NAME("Part", Part)
|
||||
PDF_MAKE_NAME("Pattern", Pattern)
|
||||
PDF_MAKE_NAME("PatternType", PatternType)
|
||||
PDF_MAKE_NAME("Perceptual", Perceptual)
|
||||
PDF_MAKE_NAME("Perms", Perms)
|
||||
PDF_MAKE_NAME("PieceInfo", PieceInfo)
|
||||
PDF_MAKE_NAME("PolyLine", PolyLine)
|
||||
PDF_MAKE_NAME("PolyLineDimension", PolyLineDimension)
|
||||
PDF_MAKE_NAME("Polygon", Polygon)
|
||||
PDF_MAKE_NAME("PolygonCloud", PolygonCloud)
|
||||
PDF_MAKE_NAME("PolygonDimension", PolygonDimension)
|
||||
PDF_MAKE_NAME("Popup", Popup)
|
||||
PDF_MAKE_NAME("PreRelease", PreRelease)
|
||||
PDF_MAKE_NAME("Predictor", Predictor)
|
||||
PDF_MAKE_NAME("Prev", Prev)
|
||||
PDF_MAKE_NAME("PrevPage", PrevPage)
|
||||
PDF_MAKE_NAME("Preview", Preview)
|
||||
PDF_MAKE_NAME("Print", Print)
|
||||
PDF_MAKE_NAME("PrinterMark", PrinterMark)
|
||||
PDF_MAKE_NAME("Private", Private)
|
||||
PDF_MAKE_NAME("ProcSet", ProcSet)
|
||||
PDF_MAKE_NAME("Producer", Producer)
|
||||
PDF_MAKE_NAME("Prop_AuthTime", Prop_AuthTime)
|
||||
PDF_MAKE_NAME("Prop_AuthType", Prop_AuthType)
|
||||
PDF_MAKE_NAME("Prop_Build", Prop_Build)
|
||||
PDF_MAKE_NAME("Properties", Properties)
|
||||
PDF_MAKE_NAME("PubSec", PubSec)
|
||||
PDF_MAKE_NAME("Push", Push)
|
||||
PDF_MAKE_NAME("Q", Q)
|
||||
PDF_MAKE_NAME("QuadPoints", QuadPoints)
|
||||
PDF_MAKE_NAME("Quote", Quote)
|
||||
PDF_MAKE_NAME("R", R)
|
||||
PDF_MAKE_NAME("RB", RB)
|
||||
PDF_MAKE_NAME("RBGroups", RBGroups)
|
||||
PDF_MAKE_NAME("RC", RC)
|
||||
PDF_MAKE_NAME("RClosedArrow", RClosedArrow)
|
||||
PDF_MAKE_NAME("RD", RD)
|
||||
PDF_MAKE_NAME("REx", REx)
|
||||
PDF_MAKE_NAME("RGB", RGB)
|
||||
PDF_MAKE_NAME("RI", RI)
|
||||
PDF_MAKE_NAME("RL", RL)
|
||||
PDF_MAKE_NAME("RO", RO)
|
||||
PDF_MAKE_NAME("ROpenArrow", ROpenArrow)
|
||||
PDF_MAKE_NAME("RP", RP)
|
||||
PDF_MAKE_NAME("RT", RT)
|
||||
PDF_MAKE_NAME("RV", RV)
|
||||
PDF_MAKE_NAME("Range", Range)
|
||||
PDF_MAKE_NAME("Reason", Reason)
|
||||
PDF_MAKE_NAME("Rect", Rect)
|
||||
PDF_MAKE_NAME("Redact", Redact)
|
||||
PDF_MAKE_NAME("Ref", Ref)
|
||||
PDF_MAKE_NAME("Reference", Reference)
|
||||
PDF_MAKE_NAME("Registry", Registry)
|
||||
PDF_MAKE_NAME("RelativeColorimetric", RelativeColorimetric)
|
||||
PDF_MAKE_NAME("ResetForm", ResetForm)
|
||||
PDF_MAKE_NAME("Resources", Resources)
|
||||
PDF_MAKE_NAME("RichMedia", RichMedia)
|
||||
PDF_MAKE_NAME("RoleMap", RoleMap)
|
||||
PDF_MAKE_NAME("Root", Root)
|
||||
PDF_MAKE_NAME("Rotate", Rotate)
|
||||
PDF_MAKE_NAME("RowSpan", RowSpan)
|
||||
PDF_MAKE_NAME("Rows", Rows)
|
||||
PDF_MAKE_NAME("Ruby", Ruby)
|
||||
PDF_MAKE_NAME("RunLengthDecode", RunLengthDecode)
|
||||
PDF_MAKE_NAME("S", S)
|
||||
PDF_MAKE_NAME("SMask", SMask)
|
||||
PDF_MAKE_NAME("SMaskInData", SMaskInData)
|
||||
PDF_MAKE_NAME("Saturation", Saturation)
|
||||
PDF_MAKE_NAME("Schema", Schema)
|
||||
PDF_MAKE_NAME("Screen", Screen)
|
||||
PDF_MAKE_NAME("Sect", Sect)
|
||||
PDF_MAKE_NAME("Separation", Separation)
|
||||
PDF_MAKE_NAME("Shading", Shading)
|
||||
PDF_MAKE_NAME("ShadingType", ShadingType)
|
||||
PDF_MAKE_NAME("Si", Si)
|
||||
PDF_MAKE_NAME("Sig", Sig)
|
||||
PDF_MAKE_NAME("SigFlags", SigFlags)
|
||||
PDF_MAKE_NAME("SigQ", SigQ)
|
||||
PDF_MAKE_NAME("SigRef", SigRef)
|
||||
PDF_MAKE_NAME("Size", Size)
|
||||
PDF_MAKE_NAME("Slash", Slash)
|
||||
PDF_MAKE_NAME("Sold", Sold)
|
||||
PDF_MAKE_NAME("Sound", Sound)
|
||||
PDF_MAKE_NAME("Source", Source)
|
||||
PDF_MAKE_NAME("Span", Span)
|
||||
PDF_MAKE_NAME("Split", Split)
|
||||
PDF_MAKE_NAME("Square", Square)
|
||||
PDF_MAKE_NAME("Squiggly", Squiggly)
|
||||
PDF_MAKE_NAME("St", St)
|
||||
PDF_MAKE_NAME("Stamp", Stamp)
|
||||
PDF_MAKE_NAME("StampImage", StampImage)
|
||||
PDF_MAKE_NAME("StampSnapshot", StampSnapshot)
|
||||
PDF_MAKE_NAME("Standard", Standard)
|
||||
PDF_MAKE_NAME("StdCF", StdCF)
|
||||
PDF_MAKE_NAME("StemV", StemV)
|
||||
PDF_MAKE_NAME("StmF", StmF)
|
||||
PDF_MAKE_NAME("StrF", StrF)
|
||||
PDF_MAKE_NAME("StrikeOut", StrikeOut)
|
||||
PDF_MAKE_NAME("Strong", Strong)
|
||||
PDF_MAKE_NAME("StructElem", StructElem)
|
||||
PDF_MAKE_NAME("StructParent", StructParent)
|
||||
PDF_MAKE_NAME("StructParents", StructParents)
|
||||
PDF_MAKE_NAME("StructTreeRoot", StructTreeRoot)
|
||||
PDF_MAKE_NAME("Sub", Sub)
|
||||
PDF_MAKE_NAME("SubFilter", SubFilter)
|
||||
PDF_MAKE_NAME("Subj", Subj)
|
||||
PDF_MAKE_NAME("Subject", Subject)
|
||||
PDF_MAKE_NAME("Subtype", Subtype)
|
||||
PDF_MAKE_NAME("Subtype2", Subtype2)
|
||||
PDF_MAKE_NAME("Supplement", Supplement)
|
||||
PDF_MAKE_NAME("Symb", Symb)
|
||||
PDF_MAKE_NAME("T", T)
|
||||
PDF_MAKE_NAME("TBody", TBody)
|
||||
PDF_MAKE_NAME("TD", TD)
|
||||
PDF_MAKE_NAME("TFoot", TFoot)
|
||||
PDF_MAKE_NAME("TH", TH)
|
||||
PDF_MAKE_NAME("THead", THead)
|
||||
PDF_MAKE_NAME("TI", TI)
|
||||
PDF_MAKE_NAME("TOC", TOC)
|
||||
PDF_MAKE_NAME("TOCI", TOCI)
|
||||
PDF_MAKE_NAME("TR", TR)
|
||||
PDF_MAKE_NAME("TR2", TR2)
|
||||
PDF_MAKE_NAME("TU", TU)
|
||||
PDF_MAKE_NAME("Table", Table)
|
||||
PDF_MAKE_NAME("Text", Text)
|
||||
PDF_MAKE_NAME("Thumb", Thumb)
|
||||
PDF_MAKE_NAME("TilingType", TilingType)
|
||||
PDF_MAKE_NAME("Times", Times)
|
||||
PDF_MAKE_NAME("Title", Title)
|
||||
PDF_MAKE_NAME("ToUnicode", ToUnicode)
|
||||
PDF_MAKE_NAME("Top", Top)
|
||||
PDF_MAKE_NAME("TopSecret", TopSecret)
|
||||
PDF_MAKE_NAME("Trans", Trans)
|
||||
PDF_MAKE_NAME("TransformMethod", TransformMethod)
|
||||
PDF_MAKE_NAME("TransformParams", TransformParams)
|
||||
PDF_MAKE_NAME("Transparency", Transparency)
|
||||
PDF_MAKE_NAME("TrapNet", TrapNet)
|
||||
PDF_MAKE_NAME("TrimBox", TrimBox)
|
||||
PDF_MAKE_NAME("TrueType", TrueType)
|
||||
PDF_MAKE_NAME("TrustedMode", TrustedMode)
|
||||
PDF_MAKE_NAME("Tx", Tx)
|
||||
PDF_MAKE_NAME("Type", Type)
|
||||
PDF_MAKE_NAME("Type0", Type0)
|
||||
PDF_MAKE_NAME("Type1", Type1)
|
||||
PDF_MAKE_NAME("Type1C", Type1C)
|
||||
PDF_MAKE_NAME("Type3", Type3)
|
||||
PDF_MAKE_NAME("U", U)
|
||||
PDF_MAKE_NAME("UE", UE)
|
||||
PDF_MAKE_NAME("UF", UF)
|
||||
PDF_MAKE_NAME("URI", URI)
|
||||
PDF_MAKE_NAME("URL", URL)
|
||||
PDF_MAKE_NAME("Unchanged", Unchanged)
|
||||
PDF_MAKE_NAME("Uncover", Uncover)
|
||||
PDF_MAKE_NAME("Underline", Underline)
|
||||
PDF_MAKE_NAME("Unix", Unix)
|
||||
PDF_MAKE_NAME("Unspecified", Unspecified)
|
||||
PDF_MAKE_NAME("Usage", Usage)
|
||||
PDF_MAKE_NAME("UseBlackPtComp", UseBlackPtComp)
|
||||
PDF_MAKE_NAME("UseCMap", UseCMap)
|
||||
PDF_MAKE_NAME("UseOutlines", UseOutlines)
|
||||
PDF_MAKE_NAME("UserUnit", UserUnit)
|
||||
PDF_MAKE_NAME("V", V)
|
||||
PDF_MAKE_NAME("V2", V2)
|
||||
PDF_MAKE_NAME("VE", VE)
|
||||
PDF_MAKE_NAME("Version", Version)
|
||||
PDF_MAKE_NAME("Vertices", Vertices)
|
||||
PDF_MAKE_NAME("VerticesPerRow", VerticesPerRow)
|
||||
PDF_MAKE_NAME("View", View)
|
||||
PDF_MAKE_NAME("W", W)
|
||||
PDF_MAKE_NAME("W2", W2)
|
||||
PDF_MAKE_NAME("WMode", WMode)
|
||||
PDF_MAKE_NAME("WP", WP)
|
||||
PDF_MAKE_NAME("WT", WT)
|
||||
PDF_MAKE_NAME("Warichu", Warichu)
|
||||
PDF_MAKE_NAME("Watermark", Watermark)
|
||||
PDF_MAKE_NAME("WhitePoint", WhitePoint)
|
||||
PDF_MAKE_NAME("Widget", Widget)
|
||||
PDF_MAKE_NAME("Width", Width)
|
||||
PDF_MAKE_NAME("Widths", Widths)
|
||||
PDF_MAKE_NAME("WinAnsiEncoding", WinAnsiEncoding)
|
||||
PDF_MAKE_NAME("Wipe", Wipe)
|
||||
PDF_MAKE_NAME("XFA", XFA)
|
||||
PDF_MAKE_NAME("XHeight", XHeight)
|
||||
PDF_MAKE_NAME("XML", XML)
|
||||
PDF_MAKE_NAME("XObject", XObject)
|
||||
PDF_MAKE_NAME("XRef", XRef)
|
||||
PDF_MAKE_NAME("XRefStm", XRefStm)
|
||||
PDF_MAKE_NAME("XStep", XStep)
|
||||
PDF_MAKE_NAME("XYZ", XYZ)
|
||||
PDF_MAKE_NAME("YStep", YStep)
|
||||
PDF_MAKE_NAME("Yes", Yes)
|
||||
PDF_MAKE_NAME("ZaDb", ZaDb)
|
||||
PDF_MAKE_NAME("a", a)
|
||||
PDF_MAKE_NAME("adbe.pkcs7.detached", adbe_pkcs7_detached)
|
||||
PDF_MAKE_NAME("ca", ca)
|
||||
PDF_MAKE_NAME("n0", n0)
|
||||
PDF_MAKE_NAME("n1", n1)
|
||||
PDF_MAKE_NAME("n2", n2)
|
||||
PDF_MAKE_NAME("op", op)
|
||||
PDF_MAKE_NAME("r", r)
|
||||
+459
@@ -0,0 +1,459 @@
|
||||
// Copyright (C) 2004-2025 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_OBJECT_H
|
||||
#define MUPDF_PDF_OBJECT_H
|
||||
|
||||
#include "mupdf/fitz/stream.h"
|
||||
|
||||
typedef struct pdf_document pdf_document;
|
||||
typedef struct pdf_crypt pdf_crypt;
|
||||
typedef struct pdf_journal pdf_journal;
|
||||
|
||||
typedef struct pdf_resource_stack pdf_resource_stack;
|
||||
|
||||
/* Defined in PDF 1.7 according to Acrobat limit. */
|
||||
#define PDF_MAX_OBJECT_NUMBER 8388607
|
||||
#define PDF_MAX_GEN_NUMBER 65535
|
||||
|
||||
/*
|
||||
* Dynamic objects.
|
||||
* The same type of objects as found in PDF and PostScript.
|
||||
* Used by the filters and the mupdf parser.
|
||||
*/
|
||||
|
||||
typedef struct pdf_obj pdf_obj;
|
||||
|
||||
pdf_obj *pdf_new_int(fz_context *ctx, int64_t i);
|
||||
pdf_obj *pdf_new_real(fz_context *ctx, float f);
|
||||
pdf_obj *pdf_new_name(fz_context *ctx, const char *str);
|
||||
pdf_obj *pdf_new_string(fz_context *ctx, const char *str, size_t len);
|
||||
|
||||
/*
|
||||
Create a PDF 'text string' by encoding input string as either ASCII or UTF-16BE.
|
||||
In theory, we could also use PDFDocEncoding.
|
||||
*/
|
||||
pdf_obj *pdf_new_text_string(fz_context *ctx, const char *s);
|
||||
pdf_obj *pdf_new_indirect(fz_context *ctx, pdf_document *doc, int64_t num, int gen);
|
||||
pdf_obj *pdf_new_array(fz_context *ctx, pdf_document *doc, int initialcap);
|
||||
pdf_obj *pdf_new_dict(fz_context *ctx, pdf_document *doc, int initialcap);
|
||||
pdf_obj *pdf_new_point(fz_context *ctx, pdf_document *doc, fz_point point);
|
||||
pdf_obj *pdf_new_rect(fz_context *ctx, pdf_document *doc, fz_rect rect);
|
||||
pdf_obj *pdf_new_matrix(fz_context *ctx, pdf_document *doc, fz_matrix mtx);
|
||||
pdf_obj *pdf_new_date(fz_context *ctx, pdf_document *doc, int64_t time);
|
||||
pdf_obj *pdf_copy_array(fz_context *ctx, pdf_obj *array);
|
||||
pdf_obj *pdf_copy_dict(fz_context *ctx, pdf_obj *dict);
|
||||
pdf_obj *pdf_deep_copy_obj(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
pdf_obj *pdf_keep_obj(fz_context *ctx, pdf_obj *obj);
|
||||
void pdf_drop_obj(fz_context *ctx, pdf_obj *obj);
|
||||
pdf_obj *pdf_drop_singleton_obj(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_obj_is_singleton(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
int pdf_is_null(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_bool(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_int(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_real(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_number(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_name(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_string(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_array(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_dict(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_indirect(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
/*
|
||||
If obj is an indirect object, return it. If not,
|
||||
throw an error.
|
||||
*/
|
||||
pdf_obj *pdf_ensure_indirect(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
/*
|
||||
Check if an object is a stream or not.
|
||||
*/
|
||||
int pdf_obj_num_is_stream(fz_context *ctx, pdf_document *doc, int num);
|
||||
int pdf_is_stream(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
/* Compare 2 objects. Returns 0 on match, non-zero on mismatch.
|
||||
* Streams always mismatch.
|
||||
*/
|
||||
int pdf_objcmp(fz_context *ctx, pdf_obj *a, pdf_obj *b);
|
||||
int pdf_objcmp_resolve(fz_context *ctx, pdf_obj *a, pdf_obj *b);
|
||||
|
||||
/* Compare 2 objects. Returns 0 on match, non-zero on mismatch.
|
||||
* Stream contents are explicitly checked.
|
||||
*/
|
||||
int pdf_objcmp_deep(fz_context *ctx, pdf_obj *a, pdf_obj *b);
|
||||
|
||||
int pdf_name_eq(fz_context *ctx, pdf_obj *a, pdf_obj *b);
|
||||
|
||||
int pdf_obj_marked(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_mark_obj(fz_context *ctx, pdf_obj *obj);
|
||||
void pdf_unmark_obj(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
typedef struct pdf_cycle_list pdf_cycle_list;
|
||||
struct pdf_cycle_list {
|
||||
pdf_cycle_list *up;
|
||||
int num;
|
||||
};
|
||||
/*
|
||||
Check for a cycle (or stack overflow) in PDF structures.
|
||||
|
||||
Returns 1 if a cycle found.
|
||||
Returns -1 if we pass some arbitrary depth (currently 256).
|
||||
Otherwise returns 0.
|
||||
*/
|
||||
int pdf_cycle(fz_context *ctx, pdf_cycle_list *here, pdf_cycle_list *prev, pdf_obj *obj);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int len;
|
||||
unsigned char bits[FZ_FLEXIBLE_ARRAY];
|
||||
} pdf_mark_bits;
|
||||
|
||||
pdf_mark_bits *pdf_new_mark_bits(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_drop_mark_bits(fz_context *ctx, pdf_mark_bits *marks);
|
||||
void pdf_mark_bits_reset(fz_context *ctx, pdf_mark_bits *marks);
|
||||
int pdf_mark_bits_set(fz_context *ctx, pdf_mark_bits *marks, pdf_obj *obj);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int len;
|
||||
int max;
|
||||
int *list;
|
||||
int local_list[8];
|
||||
} pdf_mark_list;
|
||||
|
||||
int pdf_mark_list_push(fz_context *ctx, pdf_mark_list *list, pdf_obj *obj);
|
||||
void pdf_mark_list_pop(fz_context *ctx, pdf_mark_list *list);
|
||||
int pdf_mark_list_check(fz_context *ctx, pdf_mark_list *list, pdf_obj *obj);
|
||||
void pdf_mark_list_init(fz_context *ctx, pdf_mark_list *list);
|
||||
void pdf_mark_list_free(fz_context *ctx, pdf_mark_list *list);
|
||||
|
||||
void pdf_set_obj_memo(fz_context *ctx, pdf_obj *obj, int bit, int memo);
|
||||
int pdf_obj_memo(fz_context *ctx, pdf_obj *obj, int bit, int *memo);
|
||||
|
||||
int pdf_obj_is_dirty(fz_context *ctx, pdf_obj *obj);
|
||||
void pdf_dirty_obj(fz_context *ctx, pdf_obj *obj);
|
||||
void pdf_clean_obj(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
int pdf_to_bool(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_to_int(fz_context *ctx, pdf_obj *obj);
|
||||
int64_t pdf_to_int64(fz_context *ctx, pdf_obj *obj);
|
||||
float pdf_to_real(fz_context *ctx, pdf_obj *obj);
|
||||
const char *pdf_to_name(fz_context *ctx, pdf_obj *obj);
|
||||
const char *pdf_to_text_string(fz_context *ctx, pdf_obj *obj);
|
||||
const char *pdf_to_string(fz_context *ctx, pdf_obj *obj, size_t *sizep);
|
||||
char *pdf_to_str_buf(fz_context *ctx, pdf_obj *obj);
|
||||
size_t pdf_to_str_len(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_to_num(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_to_gen(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
int pdf_to_bool_default(fz_context *ctx, pdf_obj *obj, int def);
|
||||
int pdf_to_int_default(fz_context *ctx, pdf_obj *obj, int def);
|
||||
float pdf_to_real_default(fz_context *ctx, pdf_obj *obj, float def);
|
||||
|
||||
int pdf_array_len(fz_context *ctx, pdf_obj *array);
|
||||
pdf_obj *pdf_array_get(fz_context *ctx, pdf_obj *array, int i);
|
||||
void pdf_array_put(fz_context *ctx, pdf_obj *array, int i, pdf_obj *obj);
|
||||
void pdf_array_put_drop(fz_context *ctx, pdf_obj *array, int i, pdf_obj *obj);
|
||||
void pdf_array_push(fz_context *ctx, pdf_obj *array, pdf_obj *obj);
|
||||
void pdf_array_push_drop(fz_context *ctx, pdf_obj *array, pdf_obj *obj);
|
||||
void pdf_array_insert(fz_context *ctx, pdf_obj *array, pdf_obj *obj, int index);
|
||||
void pdf_array_insert_drop(fz_context *ctx, pdf_obj *array, pdf_obj *obj, int index);
|
||||
void pdf_array_delete(fz_context *ctx, pdf_obj *array, int index);
|
||||
int pdf_array_find(fz_context *ctx, pdf_obj *array, pdf_obj *obj);
|
||||
int pdf_array_contains(fz_context *ctx, pdf_obj *array, pdf_obj *obj);
|
||||
|
||||
int pdf_dict_len(fz_context *ctx, pdf_obj *dict);
|
||||
pdf_obj *pdf_dict_get_key(fz_context *ctx, pdf_obj *dict, int idx);
|
||||
pdf_obj *pdf_dict_get_val(fz_context *ctx, pdf_obj *dict, int idx);
|
||||
void pdf_dict_put_val_null(fz_context *ctx, pdf_obj *obj, int idx);
|
||||
pdf_obj *pdf_dict_get(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
pdf_obj *pdf_dict_getp(fz_context *ctx, pdf_obj *dict, const char *path);
|
||||
pdf_obj *pdf_dict_getl(fz_context *ctx, pdf_obj *dict, ...);
|
||||
pdf_obj *pdf_dict_geta(fz_context *ctx, pdf_obj *dict, pdf_obj *key, pdf_obj *abbrev);
|
||||
pdf_obj *pdf_dict_gets(fz_context *ctx, pdf_obj *dict, const char *key);
|
||||
pdf_obj *pdf_dict_getsa(fz_context *ctx, pdf_obj *dict, const char *key, const char *abbrev);
|
||||
pdf_obj *pdf_dict_get_inheritable(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
pdf_obj *pdf_dict_getp_inheritable(fz_context *ctx, pdf_obj *dict, const char *path);
|
||||
pdf_obj *pdf_dict_gets_inheritable(fz_context *ctx, pdf_obj *dict, const char *key);
|
||||
void pdf_dict_put(fz_context *ctx, pdf_obj *dict, pdf_obj *key, pdf_obj *val);
|
||||
void pdf_dict_put_drop(fz_context *ctx, pdf_obj *dict, pdf_obj *key, pdf_obj *val);
|
||||
void pdf_dict_get_put_drop(fz_context *ctx, pdf_obj *dict, pdf_obj *key, pdf_obj *val, pdf_obj **old_val);
|
||||
void pdf_dict_puts(fz_context *ctx, pdf_obj *dict, const char *key, pdf_obj *val);
|
||||
void pdf_dict_puts_drop(fz_context *ctx, pdf_obj *dict, const char *key, pdf_obj *val);
|
||||
void pdf_dict_putp(fz_context *ctx, pdf_obj *dict, const char *path, pdf_obj *val);
|
||||
void pdf_dict_putp_drop(fz_context *ctx, pdf_obj *dict, const char *path, pdf_obj *val);
|
||||
void pdf_dict_putl(fz_context *ctx, pdf_obj *dict, pdf_obj *val, ...);
|
||||
void pdf_dict_putl_drop(fz_context *ctx, pdf_obj *dict, pdf_obj *val, ...);
|
||||
void pdf_dict_del(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
void pdf_dict_dels(fz_context *ctx, pdf_obj *dict, const char *key);
|
||||
void pdf_sort_dict(fz_context *ctx, pdf_obj *dict);
|
||||
|
||||
void pdf_dict_put_bool(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int x);
|
||||
void pdf_dict_put_int(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int64_t x);
|
||||
void pdf_dict_put_real(fz_context *ctx, pdf_obj *dict, pdf_obj *key, double x);
|
||||
void pdf_dict_put_name(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const char *x);
|
||||
void pdf_dict_put_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const char *x, size_t n);
|
||||
void pdf_dict_put_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, const char *x);
|
||||
void pdf_dict_put_indirect(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int num);
|
||||
void pdf_dict_put_point(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_point x);
|
||||
void pdf_dict_put_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_rect x);
|
||||
void pdf_dict_put_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key, fz_matrix x);
|
||||
void pdf_dict_put_date(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int64_t time);
|
||||
pdf_obj *pdf_dict_put_array(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int initial);
|
||||
pdf_obj *pdf_dict_put_dict(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int initial);
|
||||
pdf_obj *pdf_dict_puts_dict(fz_context *ctx, pdf_obj *dict, const char *key, int initial);
|
||||
|
||||
int pdf_dict_get_bool(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
int pdf_dict_get_int(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
int64_t pdf_dict_get_int64(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
float pdf_dict_get_real(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
const char *pdf_dict_get_name(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
const char *pdf_dict_get_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, size_t *sizep);
|
||||
const char *pdf_dict_get_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
const char *pdf_dict_get_text_string_opt(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
fz_point pdf_dict_get_point(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
fz_rect pdf_dict_get_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
fz_matrix pdf_dict_get_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
int64_t pdf_dict_get_date(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
|
||||
int pdf_dict_get_bool_default(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int def);
|
||||
int pdf_dict_get_int_default(fz_context *ctx, pdf_obj *dict, pdf_obj *key, int def);
|
||||
float pdf_dict_get_real_default(fz_context *ctx, pdf_obj *dict, pdf_obj *key, float def);
|
||||
|
||||
int pdf_dict_get_inheritable_bool(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
int pdf_dict_get_inheritable_int(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
int64_t pdf_dict_get_inheritable_int64(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
float pdf_dict_get_inheritable_real(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
const char *pdf_dict_get_inheritable_name(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
const char *pdf_dict_get_inheritable_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key, size_t *sizep);
|
||||
const char *pdf_dict_get_inheritable_text_string(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
fz_rect pdf_dict_get_inheritable_rect(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
fz_matrix pdf_dict_get_inheritable_matrix(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
int64_t pdf_dict_get_inheritable_date(fz_context *ctx, pdf_obj *dict, pdf_obj *key);
|
||||
|
||||
void pdf_array_push_bool(fz_context *ctx, pdf_obj *array, int x);
|
||||
void pdf_array_push_int(fz_context *ctx, pdf_obj *array, int64_t x);
|
||||
void pdf_array_push_real(fz_context *ctx, pdf_obj *array, double x);
|
||||
void pdf_array_push_name(fz_context *ctx, pdf_obj *array, const char *x);
|
||||
void pdf_array_push_string(fz_context *ctx, pdf_obj *array, const char *x, size_t n);
|
||||
void pdf_array_push_text_string(fz_context *ctx, pdf_obj *array, const char *x);
|
||||
pdf_obj *pdf_array_push_array(fz_context *ctx, pdf_obj *array, int initial);
|
||||
pdf_obj *pdf_array_push_dict(fz_context *ctx, pdf_obj *array, int initial);
|
||||
|
||||
void pdf_array_put_bool(fz_context *ctx, pdf_obj *array, int i, int x);
|
||||
void pdf_array_put_int(fz_context *ctx, pdf_obj *array, int i, int64_t x);
|
||||
void pdf_array_put_real(fz_context *ctx, pdf_obj *array, int i, double x);
|
||||
void pdf_array_put_name(fz_context *ctx, pdf_obj *array, int i, const char *x);
|
||||
void pdf_array_put_string(fz_context *ctx, pdf_obj *array, int i, const char *x, size_t n);
|
||||
void pdf_array_put_text_string(fz_context *ctx, pdf_obj *array, int i, const char *x);
|
||||
pdf_obj *pdf_array_put_array(fz_context *ctx, pdf_obj *array, int i, int initial);
|
||||
pdf_obj *pdf_array_put_dict(fz_context *ctx, pdf_obj *array, int i, int initial);
|
||||
|
||||
int pdf_array_get_bool(fz_context *ctx, pdf_obj *array, int index);
|
||||
int pdf_array_get_int(fz_context *ctx, pdf_obj *array, int index);
|
||||
float pdf_array_get_real(fz_context *ctx, pdf_obj *array, int index);
|
||||
const char *pdf_array_get_name(fz_context *ctx, pdf_obj *array, int index);
|
||||
const char *pdf_array_get_string(fz_context *ctx, pdf_obj *array, int index, size_t *sizep);
|
||||
const char *pdf_array_get_text_string(fz_context *ctx, pdf_obj *array, int index);
|
||||
fz_rect pdf_array_get_rect(fz_context *ctx, pdf_obj *array, int index);
|
||||
fz_matrix pdf_array_get_matrix(fz_context *ctx, pdf_obj *array, int index);
|
||||
|
||||
void pdf_set_obj_parent(fz_context *ctx, pdf_obj *obj, int num);
|
||||
|
||||
int pdf_obj_refs(fz_context *ctx, pdf_obj *ref);
|
||||
|
||||
int pdf_obj_parent_num(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
char *pdf_sprint_obj(fz_context *ctx, char *buf, size_t cap, size_t *len, pdf_obj *obj, int tight, int ascii);
|
||||
void pdf_print_obj(fz_context *ctx, fz_output *out, pdf_obj *obj, int tight, int ascii);
|
||||
void pdf_print_encrypted_obj(fz_context *ctx, fz_output *out, pdf_obj *obj, int tight, int ascii, pdf_crypt *crypt, int num, int gen, int *sep);
|
||||
|
||||
void pdf_debug_obj(fz_context *ctx, pdf_obj *obj);
|
||||
void pdf_debug_ref(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
/*
|
||||
Convert Unicode/PdfDocEncoding string into utf-8.
|
||||
|
||||
The returned string must be freed by the caller.
|
||||
*/
|
||||
char *pdf_new_utf8_from_pdf_string(fz_context *ctx, const char *srcptr, size_t srclen);
|
||||
|
||||
/*
|
||||
Convert text string object to UTF-8.
|
||||
|
||||
The returned string must be freed by the caller.
|
||||
*/
|
||||
char *pdf_new_utf8_from_pdf_string_obj(fz_context *ctx, pdf_obj *src);
|
||||
|
||||
/*
|
||||
Load text stream and convert to UTF-8.
|
||||
|
||||
The returned string must be freed by the caller.
|
||||
*/
|
||||
char *pdf_new_utf8_from_pdf_stream_obj(fz_context *ctx, pdf_obj *src);
|
||||
|
||||
/*
|
||||
Load text stream or text string and convert to UTF-8.
|
||||
|
||||
The returned string must be freed by the caller.
|
||||
*/
|
||||
char *pdf_load_stream_or_string_as_utf8(fz_context *ctx, pdf_obj *src);
|
||||
|
||||
fz_quad pdf_to_quad(fz_context *ctx, pdf_obj *array, int offset);
|
||||
fz_point pdf_to_point(fz_context *ctx, pdf_obj *array, int offset);
|
||||
fz_rect pdf_to_rect(fz_context *ctx, pdf_obj *array);
|
||||
fz_matrix pdf_to_matrix(fz_context *ctx, pdf_obj *array);
|
||||
int64_t pdf_to_date(fz_context *ctx, pdf_obj *time);
|
||||
|
||||
/*
|
||||
pdf_get_indirect_document and pdf_get_bound_document are
|
||||
now deprecated. Please do not use them in future. They will
|
||||
be removed.
|
||||
|
||||
Please use pdf_pin_document instead.
|
||||
*/
|
||||
pdf_document *pdf_get_indirect_document(fz_context *ctx, pdf_obj *obj);
|
||||
pdf_document *pdf_get_bound_document(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
/*
|
||||
pdf_pin_document returns a new reference to the document
|
||||
to which obj is bound. The caller is responsible for
|
||||
dropping this reference once they have finished with it.
|
||||
|
||||
This is a replacement for pdf_get_indirect_document
|
||||
and pdf_get_bound_document that are now deprecated. Those
|
||||
returned a borrowed reference that did not need to be
|
||||
dropped.
|
||||
|
||||
Note that this can validly return NULL in various cases:
|
||||
1) When the object is of a simple type (such as a number
|
||||
or a string), it contains no reference to the enclosing
|
||||
document. 2) When the object has yet to be inserted into
|
||||
a PDF document (such as during parsing). 3) And (in
|
||||
future versions) when the document has been destroyed
|
||||
but the object reference remains.
|
||||
|
||||
It is the caller's responsibility to deal with a NULL
|
||||
return here.
|
||||
*/
|
||||
pdf_document *pdf_pin_document(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
void pdf_set_int(fz_context *ctx, pdf_obj *obj, int64_t i);
|
||||
|
||||
/* Voodoo to create PDF_NAME(Foo) macros from name-table.h */
|
||||
|
||||
#define PDF_NAME(X) ((pdf_obj*)(intptr_t)PDF_ENUM_NAME_##X)
|
||||
|
||||
#define PDF_MAKE_NAME(STRING,NAME) PDF_ENUM_NAME_##NAME,
|
||||
enum {
|
||||
PDF_ENUM_NULL,
|
||||
PDF_ENUM_TRUE,
|
||||
PDF_ENUM_FALSE,
|
||||
#include "mupdf/pdf/name-table.h"
|
||||
PDF_ENUM_LIMIT,
|
||||
};
|
||||
#undef PDF_MAKE_NAME
|
||||
|
||||
#define PDF_NULL ((pdf_obj*)(intptr_t)PDF_ENUM_NULL)
|
||||
#define PDF_TRUE ((pdf_obj*)(intptr_t)PDF_ENUM_TRUE)
|
||||
#define PDF_FALSE ((pdf_obj*)(intptr_t)PDF_ENUM_FALSE)
|
||||
#define PDF_LIMIT ((pdf_obj*)(intptr_t)PDF_ENUM_LIMIT)
|
||||
|
||||
|
||||
/* Implementation details: subject to change. */
|
||||
|
||||
/*
|
||||
for use by pdf_crypt_obj_imp to decrypt AES string in place
|
||||
*/
|
||||
void pdf_set_str_len(fz_context *ctx, pdf_obj *obj, size_t newlen);
|
||||
|
||||
|
||||
/* Journalling */
|
||||
|
||||
/* Call this to enable journalling on a given document. */
|
||||
void pdf_enable_journal(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/* Call this to start an operation. Undo/redo works at 'operation'
|
||||
* granularity. Nested operations are all counted within the outermost
|
||||
* operation. Any modification performed on a journalled PDF without an
|
||||
* operation having been started will throw an error. */
|
||||
void pdf_begin_operation(fz_context *ctx, pdf_document *doc, const char *operation);
|
||||
|
||||
/* Call this to start an implicit operation. Implicit operations are
|
||||
* operations that happen as a consequence of things like updating
|
||||
* an annotation. They get rolled into the previous operation, because
|
||||
* they generally happen as a result of them. */
|
||||
void pdf_begin_implicit_operation(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/* Call this to end an operation. */
|
||||
void pdf_end_operation(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/* Call this to abandon an operation. Revert to the state
|
||||
* when you began. */
|
||||
void pdf_abandon_operation(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/* Call this to find out how many undo/redo steps there are, and the
|
||||
* current position we are within those. 0 = original document,
|
||||
* *steps = final edited version. */
|
||||
int pdf_undoredo_state(fz_context *ctx, pdf_document *doc, int *steps);
|
||||
|
||||
/* Call this to find the title of the operation within the undo state. */
|
||||
const char *pdf_undoredo_step(fz_context *ctx, pdf_document *doc, int step);
|
||||
|
||||
/* Helper functions to identify if we are in a state to be able to undo
|
||||
* or redo. */
|
||||
int pdf_can_undo(fz_context *ctx, pdf_document *doc);
|
||||
int pdf_can_redo(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/* Move backwards in the undo history. Throws an error if we are at the
|
||||
* start. Any edits to the document at this point will discard all
|
||||
* subsequent history. */
|
||||
void pdf_undo(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/* Move forwards in the undo history. Throws an error if we are at the
|
||||
* end. */
|
||||
void pdf_redo(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/* Called to reset the entire history. This is called implicitly when
|
||||
* a non-undoable change occurs (such as a pdf repair). */
|
||||
void pdf_discard_journal(fz_context *ctx, pdf_journal *journal);
|
||||
|
||||
/* Internal destructor. */
|
||||
void pdf_drop_journal(fz_context *ctx, pdf_journal *journal);
|
||||
|
||||
/* Internal call as part of saving a snapshot of a PDF document. */
|
||||
void pdf_serialise_journal(fz_context *ctx, pdf_document *doc, fz_output *out);
|
||||
|
||||
/* Internal call as part of loading a snapshot of a PDF document. */
|
||||
void pdf_deserialise_journal(fz_context *ctx, pdf_document *doc, fz_stream *stm);
|
||||
|
||||
/* Internal call as part of creating objects. */
|
||||
void pdf_add_journal_fragment(fz_context *ctx, pdf_document *doc, int parent, pdf_obj *copy, fz_buffer *copy_stream, int newobj);
|
||||
|
||||
char *pdf_format_date(fz_context *ctx, int64_t time, char *s, size_t n);
|
||||
int64_t pdf_parse_date(fz_context *ctx, const char *s);
|
||||
|
||||
int pdf_is_image_stream(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
#endif
|
||||
+342
@@ -0,0 +1,342 @@
|
||||
// Copyright (C) 2004-2024 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_PAGE_H
|
||||
#define MUPDF_PDF_PAGE_H
|
||||
|
||||
#include "mupdf/pdf/interpret.h"
|
||||
|
||||
pdf_page *pdf_keep_page(fz_context *ctx, pdf_page *page);
|
||||
void pdf_drop_page(fz_context *ctx, pdf_page *page);
|
||||
|
||||
int pdf_lookup_page_number(fz_context *ctx, pdf_document *doc, pdf_obj *pageobj);
|
||||
int pdf_count_pages(fz_context *ctx, pdf_document *doc);
|
||||
int pdf_count_pages_imp(fz_context *ctx, fz_document *doc, int chapter);
|
||||
pdf_obj *pdf_lookup_page_obj(fz_context *ctx, pdf_document *doc, int needle);
|
||||
pdf_obj *pdf_lookup_page_loc(fz_context *ctx, pdf_document *doc, int needle, pdf_obj **parentp, int *indexp);
|
||||
|
||||
/*
|
||||
Enable or disable the page tree cache that is used to speed up page object lookups.
|
||||
The page tree cache is used unless explicitly disabled with this function.
|
||||
*/
|
||||
void pdf_set_page_tree_cache(fz_context *ctx, pdf_document *doc, int enabled);
|
||||
|
||||
/*
|
||||
Cache the page tree for fast forward/reverse page lookups.
|
||||
|
||||
No longer required. This is a No Op, now as page tree
|
||||
maps are loaded automatically 'just in time'.
|
||||
*/
|
||||
void pdf_load_page_tree(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/*
|
||||
Discard the page tree maps.
|
||||
|
||||
No longer required. This is a No Op, now as page tree
|
||||
maps are discarded automatically 'just in time'.
|
||||
*/
|
||||
void pdf_drop_page_tree(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/*
|
||||
Internal function used to drop the page tree.
|
||||
|
||||
Library users should not call this directly.
|
||||
*/
|
||||
void pdf_drop_page_tree_internal(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/*
|
||||
Make page self sufficient.
|
||||
|
||||
Copy any inheritable page keys into the actual page object, removing
|
||||
any dependencies on the page tree parents.
|
||||
*/
|
||||
void pdf_flatten_inheritable_page_items(fz_context *ctx, pdf_obj *page);
|
||||
|
||||
/*
|
||||
Load a page and its resources.
|
||||
|
||||
Locates the page in the PDF document and loads the page and its
|
||||
resources. After pdf_load_page is it possible to retrieve the size
|
||||
of the page using pdf_bound_page, or to render the page using
|
||||
pdf_run_page_*.
|
||||
|
||||
number: page number, where 0 is the first page of the document.
|
||||
*/
|
||||
pdf_page *pdf_load_page(fz_context *ctx, pdf_document *doc, int number);
|
||||
|
||||
/*
|
||||
Internal function to perform pdf_load_page.
|
||||
|
||||
Do not call this directly.
|
||||
*/
|
||||
fz_page *pdf_load_page_imp(fz_context *ctx, fz_document *doc, int chapter, int number);
|
||||
|
||||
/*
|
||||
Enquire as to whether a given page uses transparency or not.
|
||||
*/
|
||||
int pdf_page_has_transparency(fz_context *ctx, pdf_page *page);
|
||||
|
||||
/*
|
||||
Fetch the given box for a page, together with a transform that converts
|
||||
from fitz coords to PDF coords.
|
||||
|
||||
pageobj: The object that represents the page.
|
||||
|
||||
outbox: If non-NULL, this will be filled in with the requested box
|
||||
in fitz coordinates.
|
||||
|
||||
outctm: A transform to map from fitz page space to PDF page space.
|
||||
|
||||
box: Which box to return.
|
||||
*/
|
||||
void pdf_page_obj_transform_box(fz_context *ctx, pdf_obj *pageobj, fz_rect *outbox, fz_matrix *out, fz_box_type box);
|
||||
|
||||
/*
|
||||
As for pdf_page_obj_transform_box, always requesting the
|
||||
cropbox.
|
||||
*/
|
||||
void pdf_page_obj_transform(fz_context *ctx, pdf_obj *pageobj, fz_rect *outbox, fz_matrix *outctm);
|
||||
|
||||
/*
|
||||
As for pdf_page_obj_transform_box, but working from a pdf_page
|
||||
object rather than the pdf_obj representing the page.
|
||||
*/
|
||||
void pdf_page_transform_box(fz_context *ctx, pdf_page *page, fz_rect *mediabox, fz_matrix *ctm, fz_box_type box);
|
||||
|
||||
/*
|
||||
As for pdf_page_transform_box, always requesting the
|
||||
cropbox.
|
||||
*/
|
||||
void pdf_page_transform(fz_context *ctx, pdf_page *page, fz_rect *mediabox, fz_matrix *ctm);
|
||||
|
||||
/*
|
||||
Find the pdf object that represents the resources dictionary
|
||||
for a page.
|
||||
|
||||
This is a borrowed pointer that the caller should pdf_keep_obj
|
||||
if. This may be NULL.
|
||||
*/
|
||||
pdf_obj *pdf_page_resources(fz_context *ctx, pdf_page *page);
|
||||
|
||||
/*
|
||||
Find the pdf object that represents the page contents
|
||||
for a page.
|
||||
|
||||
This is a borrowed pointer that the caller should pdf_keep_obj
|
||||
if. This may be NULL.
|
||||
*/
|
||||
pdf_obj *pdf_page_contents(fz_context *ctx, pdf_page *page);
|
||||
|
||||
/*
|
||||
Find the pdf object that represents the transparency group
|
||||
for a page.
|
||||
|
||||
This is a borrowed pointer that the caller should pdf_keep_obj
|
||||
if. This may be NULL.
|
||||
*/
|
||||
pdf_obj *pdf_page_group(fz_context *ctx, pdf_page *page);
|
||||
|
||||
/*
|
||||
Modify the page boxes (using fitz space coordinates).
|
||||
|
||||
Note that changing the CropBox will change the fitz coordinate space mapping,
|
||||
invalidating all bounding boxes previously acquired.
|
||||
*/
|
||||
void pdf_set_page_box(fz_context *ctx, pdf_page *page, fz_box_type box, fz_rect rect);
|
||||
|
||||
/*
|
||||
Get the separation details for a page.
|
||||
*/
|
||||
fz_separations *pdf_page_separations(fz_context *ctx, pdf_page *page);
|
||||
|
||||
pdf_ocg_descriptor *pdf_read_ocg(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_drop_ocg(fz_context *ctx, pdf_document *doc);
|
||||
int pdf_is_ocg_hidden(fz_context *ctx, pdf_document *doc, pdf_resource_stack *rdb, const char *usage, pdf_obj *ocg);
|
||||
|
||||
fz_link *pdf_load_links(fz_context *ctx, pdf_page *page);
|
||||
|
||||
/*
|
||||
Determine the size of a page.
|
||||
|
||||
Determine the page size in points, taking page rotation
|
||||
into account. The page size is taken to be the crop box if it
|
||||
exists (visible area after cropping), otherwise the media box will
|
||||
be used (possibly including printing marks).
|
||||
*/
|
||||
fz_rect pdf_bound_page(fz_context *ctx, pdf_page *page, fz_box_type box);
|
||||
|
||||
/*
|
||||
Interpret a loaded page and render it on a device.
|
||||
|
||||
page: A page loaded by pdf_load_page.
|
||||
|
||||
dev: Device used for rendering, obtained from fz_new_*_device.
|
||||
|
||||
ctm: A transformation matrix applied to the objects on the page,
|
||||
e.g. to scale or rotate the page contents as desired.
|
||||
*/
|
||||
void pdf_run_page(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie);
|
||||
|
||||
/*
|
||||
Interpret a loaded page and render it on a device.
|
||||
|
||||
page: A page loaded by pdf_load_page.
|
||||
|
||||
dev: Device used for rendering, obtained from fz_new_*_device.
|
||||
|
||||
ctm: A transformation matrix applied to the objects on the page,
|
||||
e.g. to scale or rotate the page contents as desired.
|
||||
|
||||
usage: The 'usage' for displaying the file (typically
|
||||
'View', 'Print' or 'Export'). NULL means 'View'.
|
||||
|
||||
cookie: A pointer to an optional fz_cookie structure that can be used
|
||||
to track progress, collect errors etc.
|
||||
*/
|
||||
void pdf_run_page_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie);
|
||||
|
||||
/*
|
||||
Interpret a loaded page and render it on a device.
|
||||
Just the main page contents without the annotations
|
||||
|
||||
page: A page loaded by pdf_load_page.
|
||||
|
||||
dev: Device used for rendering, obtained from fz_new_*_device.
|
||||
|
||||
ctm: A transformation matrix applied to the objects on the page,
|
||||
e.g. to scale or rotate the page contents as desired.
|
||||
*/
|
||||
void pdf_run_page_contents(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie);
|
||||
void pdf_run_page_annots(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie);
|
||||
void pdf_run_page_widgets(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, fz_cookie *cookie);
|
||||
void pdf_run_page_contents_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie);
|
||||
void pdf_run_page_annots_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie);
|
||||
void pdf_run_page_widgets_with_usage(fz_context *ctx, pdf_page *page, fz_device *dev, fz_matrix ctm, const char *usage, fz_cookie *cookie);
|
||||
|
||||
void pdf_filter_page_contents(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_filter_options *options);
|
||||
void pdf_filter_annot_contents(fz_context *ctx, pdf_document *doc, pdf_annot *annot, pdf_filter_options *options);
|
||||
|
||||
fz_pixmap *pdf_new_pixmap_from_page_contents_with_usage(fz_context *ctx, pdf_page *page, fz_matrix ctm, fz_colorspace *cs, int alpha, const char *usage, fz_box_type box);
|
||||
fz_pixmap *pdf_new_pixmap_from_page_with_usage(fz_context *ctx, pdf_page *page, fz_matrix ctm, fz_colorspace *cs, int alpha, const char *usage, fz_box_type box);
|
||||
fz_pixmap *pdf_new_pixmap_from_page_contents_with_separations_and_usage(fz_context *ctx, pdf_page *page, fz_matrix ctm, fz_colorspace *cs, fz_separations *seps, int alpha, const char *usage, fz_box_type box);
|
||||
fz_pixmap *pdf_new_pixmap_from_page_with_separations_and_usage(fz_context *ctx, pdf_page *page, fz_matrix ctm, fz_colorspace *cs, fz_separations *seps, int alpha, const char *usage, fz_box_type box);
|
||||
|
||||
enum {
|
||||
/* Do not change images at all */
|
||||
PDF_REDACT_IMAGE_NONE,
|
||||
|
||||
/* If the image intrudes across the redaction region (even if clipped),
|
||||
* remove it. */
|
||||
PDF_REDACT_IMAGE_REMOVE,
|
||||
|
||||
/* If the image intrudes across the redaction region (even if clipped),
|
||||
* replace the bit that intrudes with black pixels. */
|
||||
PDF_REDACT_IMAGE_PIXELS,
|
||||
|
||||
/* If the image, when clipped, intrudes across the redaction
|
||||
* region, remove it completely. Note: clipped is a rough estimate
|
||||
* based on the bbox of clipping paths.
|
||||
*
|
||||
* Essentially this says "remove any image that has visible parts
|
||||
* that extend into the redaction region".
|
||||
*
|
||||
* This method can effectively 'leak' invisible information during
|
||||
* the redaction phase, so should be used with caution.
|
||||
*/
|
||||
PDF_REDACT_IMAGE_REMOVE_UNLESS_INVISIBLE
|
||||
};
|
||||
|
||||
enum {
|
||||
PDF_REDACT_LINE_ART_NONE,
|
||||
PDF_REDACT_LINE_ART_REMOVE_IF_COVERED,
|
||||
PDF_REDACT_LINE_ART_REMOVE_IF_TOUCHED
|
||||
};
|
||||
|
||||
enum {
|
||||
/* Remove any text that overlaps with the redaction region,
|
||||
* however slightly. This is the default option, and is the
|
||||
* correct option for secure behaviour. */
|
||||
PDF_REDACT_TEXT_REMOVE,
|
||||
/* Do not remove any text at all as part of this redaction
|
||||
* operation. Using this option is INSECURE! Use at your own
|
||||
* risk. */
|
||||
PDF_REDACT_TEXT_NONE,
|
||||
/* Remove any invisible text that overlaps with the redaction
|
||||
* region however slightly. This is intended to allow the
|
||||
* removal of invisible text layers added by OCR passes.
|
||||
* This will remove text that is made invisible by rendering
|
||||
* mode, but will NOT remove other cases (like white-on-white
|
||||
* text, etc). */
|
||||
PDF_REDACT_TEXT_REMOVE_INVISIBLE,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int black_boxes;
|
||||
int image_method;
|
||||
int line_art;
|
||||
int text;
|
||||
} pdf_redact_options;
|
||||
|
||||
int pdf_redact_page(fz_context *ctx, pdf_document *doc, pdf_page *page, pdf_redact_options *opts);
|
||||
|
||||
fz_transition *pdf_page_presentation(fz_context *ctx, pdf_page *page, fz_transition *transition, float *duration);
|
||||
|
||||
fz_default_colorspaces *pdf_load_default_colorspaces(fz_context *ctx, pdf_document *doc, pdf_page *page);
|
||||
|
||||
void pdf_clip_page(fz_context *ctx, pdf_page *page, fz_rect *clip);
|
||||
|
||||
void pdf_vectorize_page(fz_context *ctx, pdf_page *page);
|
||||
|
||||
/*
|
||||
Update default colorspaces for an xobject.
|
||||
*/
|
||||
fz_default_colorspaces *pdf_update_default_colorspaces(fz_context *ctx, fz_default_colorspaces *old_cs, pdf_obj *res);
|
||||
|
||||
/*
|
||||
* Page tree, pages and related objects
|
||||
*/
|
||||
|
||||
struct pdf_page
|
||||
{
|
||||
fz_page super;
|
||||
pdf_document *doc; /* type alias for super.doc */
|
||||
pdf_obj *obj;
|
||||
|
||||
int transparency;
|
||||
int overprint;
|
||||
|
||||
fz_link *links;
|
||||
pdf_annot *annots, **annot_tailp;
|
||||
pdf_annot *widgets, **widget_tailp;
|
||||
};
|
||||
|
||||
/* Keep pdf_page, pdf_annot, and pdf_link structs in sync with underlying pdf objects. */
|
||||
void pdf_sync_open_pages(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_sync_page(fz_context *ctx, pdf_page *page);
|
||||
void pdf_sync_links(fz_context *ctx, pdf_page *page);
|
||||
void pdf_sync_annots(fz_context *ctx, pdf_page *page);
|
||||
void pdf_nuke_page(fz_context *ctx, pdf_page *page);
|
||||
void pdf_nuke_links(fz_context *ctx, pdf_page *page);
|
||||
void pdf_nuke_annots(fz_context *ctx, pdf_page *page);
|
||||
|
||||
#endif
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
// Copyright (C) 2004-2021 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_PARSE_H
|
||||
#define MUPDF_PDF_PARSE_H
|
||||
|
||||
#include "mupdf/pdf/document.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PDF_TOK_ERROR,
|
||||
PDF_TOK_EOF,
|
||||
PDF_TOK_OPEN_ARRAY,
|
||||
PDF_TOK_CLOSE_ARRAY,
|
||||
PDF_TOK_OPEN_DICT,
|
||||
PDF_TOK_CLOSE_DICT,
|
||||
PDF_TOK_OPEN_BRACE,
|
||||
PDF_TOK_CLOSE_BRACE,
|
||||
PDF_TOK_NAME,
|
||||
PDF_TOK_INT,
|
||||
PDF_TOK_REAL,
|
||||
PDF_TOK_STRING,
|
||||
PDF_TOK_KEYWORD,
|
||||
PDF_TOK_R,
|
||||
PDF_TOK_TRUE,
|
||||
PDF_TOK_FALSE,
|
||||
PDF_TOK_NULL,
|
||||
PDF_TOK_OBJ,
|
||||
PDF_TOK_ENDOBJ,
|
||||
PDF_TOK_STREAM,
|
||||
PDF_TOK_ENDSTREAM,
|
||||
PDF_TOK_XREF,
|
||||
PDF_TOK_TRAILER,
|
||||
PDF_TOK_STARTXREF,
|
||||
PDF_TOK_NEWOBJ,
|
||||
PDF_NUM_TOKENS
|
||||
} pdf_token;
|
||||
|
||||
void pdf_lexbuf_init(fz_context *ctx, pdf_lexbuf *lexbuf, int size);
|
||||
void pdf_lexbuf_fin(fz_context *ctx, pdf_lexbuf *lexbuf);
|
||||
ptrdiff_t pdf_lexbuf_grow(fz_context *ctx, pdf_lexbuf *lexbuf);
|
||||
|
||||
pdf_token pdf_lex(fz_context *ctx, fz_stream *f, pdf_lexbuf *lexbuf);
|
||||
pdf_token pdf_lex_no_string(fz_context *ctx, fz_stream *f, pdf_lexbuf *lexbuf);
|
||||
|
||||
pdf_obj *pdf_parse_array(fz_context *ctx, pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
|
||||
pdf_obj *pdf_parse_dict(fz_context *ctx, pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
|
||||
pdf_obj *pdf_parse_stm_obj(fz_context *ctx, pdf_document *doc, fz_stream *f, pdf_lexbuf *buf);
|
||||
pdf_obj *pdf_parse_ind_obj(fz_context *ctx, pdf_document *doc, fz_stream *f, int *num, int *gen, int64_t *stm_ofs, int *try_repair);
|
||||
pdf_obj *pdf_parse_journal_obj(fz_context *ctx, pdf_document *doc, fz_stream *stm, int *onum, fz_buffer **ostm, int *newobj);
|
||||
|
||||
/*
|
||||
print a lexed token to a buffer, growing if necessary
|
||||
*/
|
||||
void pdf_append_token(fz_context *ctx, fz_buffer *buf, int tok, pdf_lexbuf *lex);
|
||||
|
||||
#endif
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2024 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_RECOLOR_H
|
||||
#define MUPDF_PDF_RECOLOR_H
|
||||
|
||||
#include "mupdf/pdf/document.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* For gray, use num_comp = 1.
|
||||
* For rgb, use num_comp = 3.
|
||||
* For cmyk use num_comp = 4.
|
||||
* All other values reserved. */
|
||||
int num_comp;
|
||||
} pdf_recolor_options;
|
||||
|
||||
/*
|
||||
Recolor a given document page.
|
||||
|
||||
All other values reserved.
|
||||
*/
|
||||
void pdf_recolor_page(fz_context *ctx, pdf_document *doc, int pagenum, const pdf_recolor_options *opts);
|
||||
|
||||
/*
|
||||
Remove output intents from a document.
|
||||
*/
|
||||
void pdf_remove_output_intents(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
#endif
|
||||
+165
@@ -0,0 +1,165 @@
|
||||
// Copyright (C) 2004-2025 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_RESOURCE_H
|
||||
#define MUPDF_PDF_RESOURCE_H
|
||||
|
||||
#include "mupdf/fitz/font.h"
|
||||
#include "mupdf/fitz/image.h"
|
||||
#include "mupdf/fitz/shade.h"
|
||||
#include "mupdf/fitz/store.h"
|
||||
#include "mupdf/pdf/object.h"
|
||||
|
||||
void pdf_store_item(fz_context *ctx, pdf_obj *key, void *val, size_t itemsize);
|
||||
void *pdf_find_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key);
|
||||
void pdf_remove_item(fz_context *ctx, fz_store_drop_fn *drop, pdf_obj *key);
|
||||
void pdf_empty_store(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_purge_locals_from_store(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_purge_object_from_store(fz_context *ctx, pdf_document *doc, int num);
|
||||
|
||||
int pdf_pattern_uses_blending(fz_context *ctx, pdf_obj *dict, pdf_cycle_list *cycle_up);
|
||||
|
||||
/*
|
||||
* Structures used for managing resource locations and avoiding multiple
|
||||
* occurrences when resources are added to the document. The search for existing
|
||||
* resources will be performed when we are first trying to add an item. Object
|
||||
* refs are stored in a fz_hash_table structure using a hash of the md5 sum of
|
||||
* the data, enabling rapid lookup.
|
||||
*/
|
||||
|
||||
enum { PDF_SIMPLE_FONT_RESOURCE=1, PDF_CID_FONT_RESOURCE=2, PDF_CJK_FONT_RESOURCE=3 };
|
||||
enum { PDF_SIMPLE_ENCODING_LATIN, PDF_SIMPLE_ENCODING_GREEK, PDF_SIMPLE_ENCODING_CYRILLIC };
|
||||
|
||||
/* The contents of this structure are defined publicly just so we can
|
||||
* define this on the stack. */
|
||||
typedef struct
|
||||
{
|
||||
unsigned char digest[16];
|
||||
int type;
|
||||
int encoding;
|
||||
int local_xref;
|
||||
} pdf_font_resource_key;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned char digest[16];
|
||||
int local_xref;
|
||||
} pdf_colorspace_resource_key;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int w, h;
|
||||
int decode;
|
||||
unsigned int bpc : 3;
|
||||
unsigned int n : 6;
|
||||
unsigned int imagemask : 1;
|
||||
unsigned int use_colorkey : 1;
|
||||
unsigned int use_decode : 1;
|
||||
unsigned int local_xref : 1;
|
||||
unsigned char mask[16];
|
||||
unsigned char digest[16];
|
||||
} pdf_image_resource_key;
|
||||
|
||||
pdf_obj *pdf_find_font_resource(fz_context *ctx, pdf_document *doc, int type, int encoding, fz_font *item, pdf_font_resource_key *key);
|
||||
pdf_obj *pdf_insert_font_resource(fz_context *ctx, pdf_document *doc, pdf_font_resource_key *key, pdf_obj *obj);
|
||||
pdf_obj *pdf_find_colorspace_resource(fz_context *ctx, pdf_document *doc, fz_colorspace *item, pdf_colorspace_resource_key *key);
|
||||
pdf_obj *pdf_insert_colorspace_resource(fz_context *ctx, pdf_document *doc, pdf_colorspace_resource_key *key, pdf_obj *obj);
|
||||
pdf_obj *pdf_find_image_resource(fz_context *ctx, pdf_document *doc, fz_image *item, pdf_image_resource_key *key);
|
||||
pdf_obj *pdf_insert_image_resource(fz_context *ctx, pdf_document *doc, pdf_image_resource_key *key, pdf_obj *obj);
|
||||
void pdf_drop_resource_tables(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_purge_local_resources(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
typedef struct pdf_function pdf_function;
|
||||
|
||||
void pdf_eval_function(fz_context *ctx, pdf_function *func, const float *in, int inlen, float *out, int outlen);
|
||||
pdf_function *pdf_keep_function(fz_context *ctx, pdf_function *func);
|
||||
void pdf_drop_function(fz_context *ctx, pdf_function *func);
|
||||
size_t pdf_function_size(fz_context *ctx, pdf_function *func);
|
||||
pdf_function *pdf_load_function(fz_context *ctx, pdf_obj *ref, int in, int out);
|
||||
|
||||
fz_colorspace *pdf_document_output_intent(fz_context *ctx, pdf_document *doc);
|
||||
fz_colorspace *pdf_load_colorspace(fz_context *ctx, pdf_obj *obj);
|
||||
int pdf_is_tint_colorspace(fz_context *ctx, fz_colorspace *cs);
|
||||
|
||||
fz_shade *pdf_load_shading(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
|
||||
void pdf_sample_shade_function(fz_context *ctx, float *samples, int n, int funcs, pdf_function **func, float t0, float t1);
|
||||
|
||||
int pdf_guess_colorspace_components(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
/**
|
||||
Function to recolor a single color from a shade.
|
||||
*/
|
||||
typedef void (pdf_recolor_vertex)(fz_context *ctx, void *opaque, fz_colorspace *dst_cs, float *d, fz_colorspace *src_cs, const float *src);
|
||||
|
||||
/**
|
||||
Function to handle recoloring a shade.
|
||||
|
||||
Called with src_cs from the shade. If no recoloring is required, return NULL. Otherwise
|
||||
fill in *dst_cs, and return a vertex recolorer.
|
||||
*/
|
||||
typedef pdf_recolor_vertex *(pdf_shade_recolorer)(fz_context *ctx, void *opaque, fz_colorspace *src_cs, fz_colorspace **dst_cs);
|
||||
|
||||
/**
|
||||
Recolor a shade.
|
||||
*/
|
||||
pdf_obj *pdf_recolor_shade(fz_context *ctx, pdf_obj *shade, pdf_shade_recolorer *reshade, void *opaque);
|
||||
|
||||
fz_image *pdf_load_inline_image(fz_context *ctx, pdf_document *doc, pdf_resource_stack *rdb, pdf_obj *dict, fz_stream *file);
|
||||
int pdf_is_jpx_image(fz_context *ctx, pdf_obj *dict);
|
||||
|
||||
fz_image *pdf_load_image(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
|
||||
|
||||
pdf_obj *pdf_add_image(fz_context *ctx, pdf_document *doc, fz_image *image);
|
||||
|
||||
pdf_obj *pdf_add_colorspace(fz_context *ctx, pdf_document *doc, fz_colorspace *cs);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
fz_storable storable;
|
||||
int ismask;
|
||||
float xstep;
|
||||
float ystep;
|
||||
fz_matrix matrix;
|
||||
fz_rect bbox;
|
||||
pdf_document *document;
|
||||
pdf_obj *resources;
|
||||
pdf_obj *contents;
|
||||
int id; /* unique ID for caching rendered tiles */
|
||||
int uses_blending;
|
||||
} pdf_pattern;
|
||||
|
||||
pdf_pattern *pdf_load_pattern(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
|
||||
pdf_pattern *pdf_keep_pattern(fz_context *ctx, pdf_pattern *pat);
|
||||
void pdf_drop_pattern(fz_context *ctx, pdf_pattern *pat);
|
||||
|
||||
pdf_obj *pdf_new_xobject(fz_context *ctx, pdf_document *doc, fz_rect bbox, fz_matrix matrix, pdf_obj *res, fz_buffer *buffer);
|
||||
void pdf_update_xobject(fz_context *ctx, pdf_document *doc, pdf_obj *xobj, fz_rect bbox, fz_matrix mat, pdf_obj *res, fz_buffer *buffer);
|
||||
|
||||
pdf_obj *pdf_xobject_resources(fz_context *ctx, pdf_obj *xobj);
|
||||
fz_rect pdf_xobject_bbox(fz_context *ctx, pdf_obj *xobj);
|
||||
fz_matrix pdf_xobject_matrix(fz_context *ctx, pdf_obj *xobj);
|
||||
int pdf_xobject_isolated(fz_context *ctx, pdf_obj *xobj);
|
||||
int pdf_xobject_knockout(fz_context *ctx, pdf_obj *xobj);
|
||||
int pdf_xobject_transparency(fz_context *ctx, pdf_obj *xobj);
|
||||
fz_colorspace *pdf_xobject_colorspace(fz_context *ctx, pdf_obj *xobj);
|
||||
|
||||
#endif
|
||||
+304
@@ -0,0 +1,304 @@
|
||||
// Copyright (C) 2004-2026 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_XREF_H
|
||||
#define MUPDF_PDF_XREF_H
|
||||
|
||||
#include "mupdf/pdf/document.h"
|
||||
|
||||
/*
|
||||
Allocate a slot in the xref table and return a fresh unused object number.
|
||||
*/
|
||||
int pdf_create_object(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/*
|
||||
Remove object from xref table, marking the slot as free.
|
||||
*/
|
||||
void pdf_delete_object(fz_context *ctx, pdf_document *doc, int num);
|
||||
|
||||
/*
|
||||
Replace object in xref table with the passed in object.
|
||||
*/
|
||||
void pdf_update_object(fz_context *ctx, pdf_document *doc, int num, pdf_obj *obj);
|
||||
|
||||
/*
|
||||
Replace stream contents for object in xref table with the passed in buffer.
|
||||
|
||||
The buffer contents must match the /Filter setting if 'compressed' is true.
|
||||
If 'compressed' is false, the /Filter and /DecodeParms entries are deleted.
|
||||
The /Length entry is updated.
|
||||
*/
|
||||
void pdf_update_stream(fz_context *ctx, pdf_document *doc, pdf_obj *ref, fz_buffer *buf, int compressed);
|
||||
|
||||
/*
|
||||
Return true if 'obj' is an indirect reference to an object that is held
|
||||
by the "local" xref section.
|
||||
*/
|
||||
int pdf_is_local_object(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
|
||||
|
||||
pdf_obj *pdf_add_object(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
|
||||
pdf_obj *pdf_add_object_drop(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
|
||||
pdf_obj *pdf_add_stream(fz_context *ctx, pdf_document *doc, fz_buffer *buf, pdf_obj *obj, int compressed);
|
||||
|
||||
pdf_obj *pdf_add_new_dict(fz_context *ctx, pdf_document *doc, int initial);
|
||||
pdf_obj *pdf_add_new_array(fz_context *ctx, pdf_document *doc, int initial);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char type; /* 0=unset (f)ree i(n)use (o)bjstm */
|
||||
unsigned char marked; /* marked to keep alive with pdf_mark_xref */
|
||||
unsigned short gen; /* generation / objstm index */
|
||||
int num; /* original object number (for decryption after renumbering) */
|
||||
int64_t ofs; /* file offset / objstm object number */
|
||||
int64_t stm_ofs; /* on-disk stream */
|
||||
fz_buffer *stm_buf; /* in-memory stream (for updated objects) */
|
||||
pdf_obj *obj; /* stored/cached object */
|
||||
} pdf_xref_entry;
|
||||
|
||||
typedef struct pdf_xref_subsec
|
||||
{
|
||||
struct pdf_xref_subsec *next;
|
||||
int len;
|
||||
int start;
|
||||
pdf_xref_entry *table;
|
||||
} pdf_xref_subsec;
|
||||
|
||||
struct pdf_xref
|
||||
{
|
||||
int num_objects;
|
||||
int num_subsecs;
|
||||
pdf_xref_subsec *subsec;
|
||||
pdf_obj *trailer;
|
||||
pdf_obj *pre_repair_trailer;
|
||||
pdf_unsaved_sig *unsaved_sigs;
|
||||
pdf_unsaved_sig **unsaved_sigs_end;
|
||||
int64_t end_ofs; /* file offset to end of xref */
|
||||
};
|
||||
|
||||
/**
|
||||
Retrieve the pdf_xref_entry for a given object.
|
||||
|
||||
This can cause xref reorganisations (solidifications etc) due to
|
||||
repairs, so all held pdf_xref_entries should be considered
|
||||
invalid after this call (other than the returned one).
|
||||
*/
|
||||
pdf_xref_entry *pdf_cache_object(fz_context *ctx, pdf_document *doc, int num);
|
||||
|
||||
int pdf_object_exists(fz_context *ctx, pdf_document *doc, int num);
|
||||
|
||||
int pdf_count_objects(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/**
|
||||
Resolve an indirect object (or chain of objects).
|
||||
|
||||
This can cause xref reorganisations (solidifications etc) due to
|
||||
repairs, so all held pdf_xref_entries should be considered
|
||||
invalid after this call (other than the returned one).
|
||||
*/
|
||||
pdf_obj *pdf_resolve_indirect(fz_context *ctx, pdf_obj *ref);
|
||||
pdf_obj *pdf_resolve_indirect_chain(fz_context *ctx, pdf_obj *ref);
|
||||
|
||||
/**
|
||||
Load a given object.
|
||||
|
||||
This can cause xref reorganisations (solidifications etc) due to
|
||||
repairs, so all held pdf_xref_entries should be considered
|
||||
invalid after this call (other than the returned one).
|
||||
*/
|
||||
pdf_obj *pdf_load_object(fz_context *ctx, pdf_document *doc, int num);
|
||||
pdf_obj *pdf_load_unencrypted_object(fz_context *ctx, pdf_document *doc, int num);
|
||||
|
||||
/*
|
||||
Load raw (compressed but decrypted) contents of a stream into buf.
|
||||
*/
|
||||
fz_buffer *pdf_load_raw_stream_number(fz_context *ctx, pdf_document *doc, int num);
|
||||
fz_buffer *pdf_load_raw_stream(fz_context *ctx, pdf_obj *ref);
|
||||
|
||||
/*
|
||||
Load uncompressed contents of a stream into buf.
|
||||
*/
|
||||
fz_buffer *pdf_load_stream_number(fz_context *ctx, pdf_document *doc, int num);
|
||||
fz_buffer *pdf_load_stream(fz_context *ctx, pdf_obj *ref);
|
||||
|
||||
/*
|
||||
Open a stream for reading the raw (compressed but decrypted) data.
|
||||
*/
|
||||
fz_stream *pdf_open_raw_stream_number(fz_context *ctx, pdf_document *doc, int num);
|
||||
fz_stream *pdf_open_raw_stream(fz_context *ctx, pdf_obj *ref);
|
||||
|
||||
/*
|
||||
Open a stream for reading uncompressed data.
|
||||
Put the opened file in doc->stream.
|
||||
Using doc->file while a stream is open is a Bad idea.
|
||||
*/
|
||||
fz_stream *pdf_open_stream_number(fz_context *ctx, pdf_document *doc, int num);
|
||||
fz_stream *pdf_open_stream(fz_context *ctx, pdf_obj *ref);
|
||||
|
||||
/*
|
||||
Construct a filter to decode a stream, without
|
||||
constraining to stream length, and without decryption.
|
||||
*/
|
||||
fz_stream *pdf_open_inline_stream(fz_context *ctx, pdf_document *doc, pdf_obj *stmobj, size_t length, fz_stream *chain, fz_compression_params *params);
|
||||
fz_compressed_buffer *pdf_load_compressed_stream(fz_context *ctx, pdf_document *doc, int num, size_t worst_case);
|
||||
void pdf_load_compressed_inline_image(fz_context *ctx, pdf_document *doc, pdf_obj *dict, size_t length, fz_stream *cstm, int indexed, fz_compressed_image *image);
|
||||
fz_stream *pdf_open_stream_with_offset(fz_context *ctx, pdf_document *doc, int num, pdf_obj *dict, int64_t stm_ofs);
|
||||
fz_stream *pdf_open_contents_stream(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
|
||||
fz_buffer *pdf_load_image_stream(fz_context *ctx, pdf_document *doc, int num, fz_compression_params *params, int *truncated, size_t worst_case);
|
||||
|
||||
int pdf_version(fz_context *ctx, pdf_document *doc);
|
||||
pdf_obj *pdf_trailer(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_set_trailer(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
|
||||
void pdf_set_populating_xref_trailer(fz_context *ctx, pdf_document *doc, pdf_obj *trailer);
|
||||
int pdf_xref_len(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
pdf_obj *pdf_metadata(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/*
|
||||
Used while reading the individual xref sections from a file.
|
||||
*/
|
||||
pdf_xref_entry *pdf_get_populating_xref_entry(fz_context *ctx, pdf_document *doc, int i);
|
||||
|
||||
/*
|
||||
Used after loading a document to access entries.
|
||||
|
||||
This will never throw anything, or return NULL if it is
|
||||
only asked to return objects in range within a 'solid'
|
||||
xref.
|
||||
|
||||
This may "solidify" the xref (so can cause allocations).
|
||||
*/
|
||||
pdf_xref_entry *pdf_get_xref_entry(fz_context *ctx, pdf_document *doc, int i);
|
||||
|
||||
/*
|
||||
Map a function across all xref entries in a document.
|
||||
*/
|
||||
void pdf_xref_entry_map(fz_context *ctx, pdf_document *doc, void (*fn)(fz_context *, pdf_xref_entry *, int i, pdf_document *doc, void *), void *arg);
|
||||
|
||||
|
||||
/*
|
||||
Used after loading a document to access entries.
|
||||
|
||||
This will never throw anything, or return NULL if it is
|
||||
only asked to return objects in range within a 'solid'
|
||||
xref.
|
||||
|
||||
This will never "solidify" the xref, so no entry may be found
|
||||
(NULL will be returned) for free entries.
|
||||
|
||||
Called with a valid i, this will never try/catch or throw.
|
||||
*/
|
||||
pdf_xref_entry *pdf_get_xref_entry_no_change(fz_context *ctx, pdf_document *doc, int i);
|
||||
pdf_xref_entry *pdf_get_xref_entry_no_null(fz_context *ctx, pdf_document *doc, int i);
|
||||
void pdf_replace_xref(fz_context *ctx, pdf_document *doc, pdf_xref_entry *entries, int n);
|
||||
void pdf_forget_xref(fz_context *ctx, pdf_document *doc);
|
||||
pdf_xref_entry *pdf_get_incremental_xref_entry(fz_context *ctx, pdf_document *doc, int i);
|
||||
|
||||
/*
|
||||
Ensure that an object has been cloned into the incremental xref section.
|
||||
*/
|
||||
int pdf_xref_ensure_incremental_object(fz_context *ctx, pdf_document *doc, int num);
|
||||
int pdf_xref_is_incremental(fz_context *ctx, pdf_document *doc, int num);
|
||||
void pdf_xref_store_unsaved_signature(fz_context *ctx, pdf_document *doc, pdf_obj *field, pdf_pkcs7_signer *signer);
|
||||
void pdf_xref_remove_unsaved_signature(fz_context *ctx, pdf_document *doc, pdf_obj *field);
|
||||
int pdf_xref_obj_is_unsaved_signature(pdf_document *doc, pdf_obj *obj);
|
||||
void pdf_xref_ensure_local_object(fz_context *ctx, pdf_document *doc, int num);
|
||||
int pdf_obj_is_incremental(fz_context *ctx, pdf_obj *obj);
|
||||
|
||||
void pdf_repair_xref(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/*
|
||||
Ensure that the current populating xref has a single subsection
|
||||
that covers the entire range.
|
||||
*/
|
||||
void pdf_ensure_solid_xref(fz_context *ctx, pdf_document *doc, int num);
|
||||
void pdf_mark_xref(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_clear_xref(fz_context *ctx, pdf_document *doc);
|
||||
void pdf_clear_xref_to_mark(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
int pdf_repair_obj(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf, int64_t *stmofsp, int64_t *stmlenp, pdf_obj **encrypt, pdf_obj **id, pdf_obj **page, int64_t *tmpofs, pdf_obj **root);
|
||||
|
||||
pdf_obj *pdf_progressive_advance(fz_context *ctx, pdf_document *doc, int pagenum);
|
||||
|
||||
/*
|
||||
Return the number of versions that there
|
||||
are in a file. i.e. 1 + the number of updates that
|
||||
the file on disc has been through. i.e. internal
|
||||
unsaved changes to the file (such as appearance streams)
|
||||
are ignored. Also, the initial write of a linearized
|
||||
file (which appears as a base file write + an incremental
|
||||
update) is treated as a single version.
|
||||
*/
|
||||
int pdf_count_versions(fz_context *ctx, pdf_document *doc);
|
||||
int pdf_count_unsaved_versions(fz_context *ctx, pdf_document *doc);
|
||||
int pdf_validate_changes(fz_context *ctx, pdf_document *doc, int version);
|
||||
int pdf_doc_was_linearized(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
typedef struct pdf_locked_fields pdf_locked_fields;
|
||||
int pdf_is_field_locked(fz_context *ctx, pdf_locked_fields *locked, const char *name);
|
||||
void pdf_drop_locked_fields(fz_context *ctx, pdf_locked_fields *locked);
|
||||
pdf_locked_fields *pdf_find_locked_fields(fz_context *ctx, pdf_document *doc, int version);
|
||||
pdf_locked_fields *pdf_find_locked_fields_for_sig(fz_context *ctx, pdf_document *doc, pdf_obj *sig);
|
||||
|
||||
/*
|
||||
Check the entire history of the document, and return the number of
|
||||
the last version that checked out OK.
|
||||
i.e. 0 = "the entire history checks out OK".
|
||||
n = "none of the history checked out OK".
|
||||
*/
|
||||
int pdf_validate_change_history(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/*
|
||||
Find which version of a document the current version of obj
|
||||
was defined in.
|
||||
|
||||
version = 0 = latest, 1 = previous update etc, allowing for
|
||||
the first incremental update in a linearized file being ignored.
|
||||
*/
|
||||
int pdf_find_version_for_obj(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
|
||||
|
||||
/*
|
||||
Return the number of updates ago when a signature field
|
||||
became invalid, not counting any unsaved changes.
|
||||
|
||||
Thus:
|
||||
-1 => Has changed in the current unsaved changes.
|
||||
0 => still valid.
|
||||
1 => became invalid on the last save
|
||||
n => became invalid n saves ago
|
||||
*/
|
||||
int pdf_validate_signature(fz_context *ctx, pdf_document *doc, pdf_obj *field);
|
||||
int pdf_validate_signature_widget(fz_context *ctx, pdf_annot *widget);
|
||||
int pdf_was_pure_xfa(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/* Local xrefs - designed for holding stuff that shouldn't be written
|
||||
* back into the actual document, such as synthesized appearance
|
||||
* streams. */
|
||||
pdf_xref *pdf_new_local_xref(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
void pdf_drop_local_xref(fz_context *ctx, pdf_xref *xref);
|
||||
void pdf_drop_local_xref_and_resources(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
/* Debug call to dump the incremental/local xrefs to the
|
||||
* debug channel. */
|
||||
void pdf_debug_doc_changes(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
#endif
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// Copyright (C) 2024 Artifex Software, Inc.
|
||||
//
|
||||
// This file is part of MuPDF.
|
||||
//
|
||||
// MuPDF is free software: you can redistribute it and/or modify it under the
|
||||
// terms of the GNU Affero General Public License as published by the Free
|
||||
// Software Foundation, either version 3 of the License, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||||
// details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
|
||||
//
|
||||
// Alternative licensing terms are available from the licensor.
|
||||
// For commercial licensing, see <https://www.artifex.com/> or contact
|
||||
// Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
|
||||
// CA 94129, USA, for further information.
|
||||
|
||||
#ifndef MUPDF_PDF_ZUGFERD_H
|
||||
#define MUPDF_PDF_ZUGFERD_H
|
||||
|
||||
#include "mupdf/pdf/document.h"
|
||||
|
||||
enum pdf_zugferd_profile
|
||||
{
|
||||
PDF_NOT_ZUGFERD = 0,
|
||||
/* ZUGFeRD 1.0 */
|
||||
PDF_ZUGFERD_COMFORT,
|
||||
PDF_ZUGFERD_BASIC,
|
||||
PDF_ZUGFERD_EXTENDED,
|
||||
/* ZUGFeRD 2.01 */
|
||||
PDF_ZUGFERD_BASIC_WL,
|
||||
PDF_ZUGFERD_MINIMUM,
|
||||
/* ZUGFeRD 2.2 */
|
||||
PDF_ZUGFERD_XRECHNUNG,
|
||||
PDF_ZUGFERD_UNKNOWN
|
||||
};
|
||||
|
||||
enum pdf_zugferd_profile pdf_zugferd_profile(fz_context *ctx, pdf_document *doc, float *version);
|
||||
|
||||
fz_buffer *pdf_zugferd_xml(fz_context *ctx, pdf_document *doc);
|
||||
|
||||
const char *pdf_zugferd_profile_to_string(fz_context *ctx, enum pdf_zugferd_profile profile);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user