summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pdf/ghostpdf.h')
-rw-r--r--pdf/ghostpdf.h47
1 files changed, 45 insertions, 2 deletions
diff --git a/pdf/ghostpdf.h b/pdf/ghostpdf.h
index 49c91808..1c2ffe78 100644
--- a/pdf/ghostpdf.h
+++ b/pdf/ghostpdf.h
@@ -22,6 +22,12 @@
#define BUF_SIZE 2048
+/* Limit nesting of arrays and dictionaries. We don't want to allow this
+ * to be unbounded, because on exit we could end up exceeding the C execution stack
+ * if we get too deeply nested.
+ */
+#define MAX_NESTING_DEPTH 100
+
#include "pdf_types.h"
#if defined(MEMENTO)
@@ -143,8 +149,11 @@ typedef struct cmd_args_s {
bool QUIET;
bool verbose_errors;
bool verbose_warnings;
- gs_string cidsubstpath;
- gs_string cidsubstfont;
+ gs_string cidfsubstpath;
+ gs_string cidfsubstfont;
+ gs_string defaultfont;
+ bool defaultfont_is_name;
+
bool ignoretounicode;
bool nonativefontmap;
} cmd_args_t;
@@ -321,6 +330,11 @@ typedef struct pdf_context_s
/* Doing a high level form for pdfwrite (annotations) */
bool PreservePDFForm;
+ /* If processing multiple files, the number of pages to add to /Page Destinations
+ * when handling Outlines and Annotations. This is the number of pages in all
+ * files completely processed so far.
+ */
+ int Pdfmark_InitialPage;
/* Optional things from Root */
pdf_dict *OCProperties;
@@ -339,6 +353,27 @@ typedef struct pdf_context_s
gs_font_dir * font_dir;
/* Obviously we need a graphics state */
gs_gstate *pgs;
+
+ /* PDF really doesn't have a path in the graphics state. This is different to
+ * PostScript and has implications; changing the CTM partway through path
+ * construction affects path segments already accumulated. The path is
+ * unaffected by gsvae and grestore. Previously we've unwound any pending
+ * path and rerun it, this is causing problems so instead we'll do what
+ * Acrobat obviously does and build the path outside the graphics state
+ */
+ /* We make allocations in chunks for the path to avoid lots of little
+ * allocations, but we need to know where the end of the current allocation
+ * is so that we can tell if we would overflow and increase it.
+ */
+ char *PathSegments;
+ /* The current insertion point. */
+ char *PathSegmentsCurrent;
+ /* The current limit of the block */
+ char *PathSegmentsTop;
+ double *PathPts;
+ double *PathPtsCurrent;
+ double *PathPtsTop;
+
/* set up by pdf_impl_set_device, this is the 'high water mark' for
* restoring back to when we close a PDF file. This ensures the device
* is correctly set up for any subesquent file to be run.
@@ -406,6 +441,12 @@ typedef struct pdf_context_s
uint32_t loop_detection_entries;
uint64_t *loop_detection;
+ /* A counter for nesting of arrays and dictionaries. We don't want to allow this
+ * to be unbounded, because on exit we could end up exceeding the C execution stack
+ * if we get too deeply nested.
+ */
+ uint32_t object_nesting;
+
/* Used to set the 'parent' stream of a stream that gets created by dereferencing
* We should not need this but badly fromed PDF files can use Resources defined in
* an earlier (non-Page) stream object, and Acrobat handles this, so we need to.
@@ -423,6 +464,7 @@ typedef struct pdf_context_s
search_paths_t search_paths;
pdf_dict *pdffontmap;
pdf_dict *pdfnativefontmap; /* Explicit mappings take precedence, hence we need separate dictionaries */
+ pdf_dict *pdf_substitute_fonts;
pdf_dict *pdfcidfmap;
/* These function pointers can be replaced by ones intended to replicate
@@ -468,6 +510,7 @@ int pdfi_prep_collection(pdf_context *ctx, uint64_t *TotalFiles, char ***names_a
int pdfi_close_pdf_file(pdf_context *ctx);
int pdfi_gstate_from_PS(pdf_context *ctx, gs_gstate *pgs, pdfi_switch_t *i_switch, gsicc_profile_cache_t *profile_cache);
void pdfi_gstate_to_PS(pdf_context *ctx, gs_gstate *pgs, pdfi_switch_t *i_switch);
+int pdfi_output_page_info(pdf_context *ctx, uint64_t page_num);
void pdfi_report_errors(pdf_context *ctx);
void pdfi_verbose_error(pdf_context *ctx, int gs_error, const char *gs_lib_function, int pdfi_error, const char *pdfi_function_name, const char *extra_info);