summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam James <sam@gentoo.org>2022-03-29 10:27:10 +0100
committerSam James <sam@gentoo.org>2022-04-17 12:53:05 +0100
commit085bde903b9e684c3c1160e4df912bea9a660997 (patch)
treec4f5e6e9f2422e869ca5bc0b944520d451001282 /pdf/pdf_page.c
parentImport Ghostscript 9.55 (diff)
downloadghostscript-gpl-patches-085bde903b9e684c3c1160e4df912bea9a660997.tar.gz
ghostscript-gpl-patches-085bde903b9e684c3c1160e4df912bea9a660997.tar.bz2
ghostscript-gpl-patches-085bde903b9e684c3c1160e4df912bea9a660997.zip
Import Ghostscript 9.56.0ghostscript-9.56
Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'pdf/pdf_page.c')
-rw-r--r--pdf/pdf_page.c97
1 files changed, 21 insertions, 76 deletions
diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c
index 58833076..f2389fea 100644
--- a/pdf/pdf_page.c
+++ b/pdf/pdf_page.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2019-2021 Artifex Software, Inc.
+/* Copyright (C) 2019-2022 Artifex Software, Inc.
All Rights Reserved.
This software is provided AS-IS with no warranty, either express or
@@ -26,6 +26,7 @@
#include "pdf_loop_detect.h"
#include "pdf_colour.h"
#include "pdf_trans.h"
+#include "pdf_font_types.h"
#include "pdf_gstate.h"
#include "pdf_misc.h"
#include "pdf_optcontent.h"
@@ -677,72 +678,10 @@ static void release_page_DefaultSpaces(pdf_context *ctx)
static int setup_page_DefaultSpaces(pdf_context *ctx, pdf_dict *page_dict)
{
- int code = 0;
- pdf_dict *resources_dict = NULL, *colorspaces_dict = NULL;
- pdf_obj *DefaultSpace = NULL;
-
/* First off, discard any dangling Default* colour spaces, just in case. */
release_page_DefaultSpaces(ctx);
- if (ctx->args.NOSUBSTDEVICECOLORS)
- return 0;
-
- /* Create any required DefaultGray, DefaultRGB or DefaultCMYK
- * spaces.
- */
- code = pdfi_dict_knownget(ctx, page_dict, "Resources", (pdf_obj **)&resources_dict);
- if (code > 0) {
- code = pdfi_dict_knownget(ctx, resources_dict, "ColorSpace", (pdf_obj **)&colorspaces_dict);
- if (code > 0) {
- code = pdfi_dict_knownget(ctx, colorspaces_dict, "DefaultGray", &DefaultSpace);
- if (code > 0) {
- gs_color_space *pcs;
- code = pdfi_create_colorspace(ctx, DefaultSpace, NULL, page_dict, &pcs, false);
- /* If any given Default* space fails simply ignore it, we wil then use the Device
- * space instead, this is as per the spec.
- */
- if (code >= 0) {
- ctx->page.DefaultGray_cs = pcs;
- pdfi_set_colour_callback(pcs, ctx, NULL);
- }
- }
- pdfi_countdown(DefaultSpace);
- DefaultSpace = NULL;
- code = pdfi_dict_knownget(ctx, colorspaces_dict, "DefaultRGB", &DefaultSpace);
- if (code > 0) {
- gs_color_space *pcs;
- code = pdfi_create_colorspace(ctx, DefaultSpace, NULL, page_dict, &pcs, false);
- /* If any given Default* space fails simply ignore it, we wil then use the Device
- * space instead, this is as per the spec.
- */
- if (code >= 0) {
- ctx->page.DefaultRGB_cs = pcs;
- pdfi_set_colour_callback(pcs, ctx, NULL);
- }
- }
- pdfi_countdown(DefaultSpace);
- DefaultSpace = NULL;
- code = pdfi_dict_knownget(ctx, colorspaces_dict, "DefaultCMYK", &DefaultSpace);
- if (code > 0) {
- gs_color_space *pcs;
- code = pdfi_create_colorspace(ctx, DefaultSpace, NULL, page_dict, &pcs, false);
- /* If any given Default* space fails simply ignore it, we wil then use the Device
- * space instead, this is as per the spec.
- */
- if (code >= 0) {
- ctx->page.DefaultCMYK_cs = pcs;
- pdfi_set_colour_callback(pcs, ctx, NULL);
- }
- }
- pdfi_countdown(DefaultSpace);
- DefaultSpace = NULL;
- }
- }
-
- pdfi_countdown(DefaultSpace);
- pdfi_countdown(resources_dict);
- pdfi_countdown(colorspaces_dict);
- return 0;
+ return(pdfi_setup_DefaultSpaces(ctx, page_dict));
}
int pdfi_page_render(pdf_context *ctx, uint64_t page_num, bool init_graphics)
@@ -766,18 +705,18 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num, bool init_graphics)
char extra_info[256];
page_dict_error = true;
- gs_sprintf(extra_info, "*** ERROR: Page %ld has invalid Page dict, skipping\n", page_num+1);
+ gs_snprintf(extra_info, sizeof(extra_info), "*** ERROR: Page %ld has invalid Page dict, skipping\n", page_num+1);
pdfi_set_error(ctx, 0, NULL, E_PDF_PAGEDICTERROR, "pdfi_page_render", extra_info);
if (code != gs_error_VMerror && !ctx->args.pdfstoponerror)
code = 0;
- goto exit2;
+ goto exit3;
}
pdfi_device_set_flags(ctx);
code = pdfi_check_page(ctx, page_dict, init_graphics);
if (code < 0)
- goto exit2;
+ goto exit3;
if (ctx->args.pdfdebug) {
dbgmprintf2(ctx->memory, "Current page %ld transparency setting is %d", page_num+1,
@@ -791,7 +730,7 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num, bool init_graphics)
code = pdfi_dict_knownget_type(ctx, page_dict, "Group", PDF_DICT, (pdf_obj **)&group_dict);
if (code < 0)
- goto exit2;
+ goto exit3;
if (group_dict != NULL)
page_group_known = true;
@@ -829,7 +768,7 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num, bool init_graphics)
}
/* Write the various CropBox, TrimBox etc to the device */
- pdfi_write_boxes_pdfmark(ctx, page_dict);
+ pdfi_pdfmark_write_boxes(ctx, page_dict);
code = setup_page_DefaultSpaces(ctx, page_dict);
if (code < 0)
@@ -866,7 +805,7 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num, bool init_graphics)
/* We don't retain the PDF14 device */
code = gs_push_pdf14trans_device(ctx->pgs, false, false, trans_depth, ctx->page.num_spots);
if (code >= 0) {
- if (page_group_known) {
+ if (ctx->page.has_transparency && page_group_known) {
code = pdfi_trans_begin_page_group(ctx, page_dict, group_dict);
/* If setting the page group failed for some reason, abandon the page group,
* but continue with the page
@@ -889,18 +828,19 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num, bool init_graphics)
pdfi_set_DefaultQState(ctx, ctx->pgs);
/* Render one page (including annotations) */
+ if (!ctx->args.QUIET)
+ outprintf(ctx->memory, "Page %"PRId64"\n", page_num + 1);
+
code = pdfi_process_one_page(ctx, page_dict);
- if (ctx->page.has_transparency && page_group_known) {
+ if (need_pdf14 && ctx->page.has_transparency && page_group_known) {
code1 = pdfi_trans_end_group(ctx);
}
- pdfi_countdown(ctx->page.CurrentPageDict);
- ctx->page.CurrentPageDict = NULL;
-
if (need_pdf14) {
if (code1 < 0) {
(void)gs_abort_pdf14trans_device(ctx->pgs);
+ code = code1;
goto exit1;
}
@@ -910,10 +850,15 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num, bool init_graphics)
}
}
- exit1:
+exit1:
pdfi_free_DefaultQState(ctx);
pdfi_grestore(ctx);
- exit2:
+
+exit2:
+ pdfi_countdown(ctx->page.CurrentPageDict);
+ ctx->page.CurrentPageDict = NULL;
+
+exit3:
pdfi_countdown(page_dict);
pdfi_countdown(group_dict);