diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2021-08-16 17:24:30 +0100 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2021-08-16 17:24:30 +0100 |
commit | ddc6a47ac703ded6518b2bc5069023006c1e7c01 (patch) | |
tree | 5ee50e58c8cfc13fec271135b749fd1942ed97cd | |
parent | b37862e5390ac1ab02256088195e10a2b181d12e (diff) | |
download | ghostpdl-ddc6a47ac703ded6518b2bc5069023006c1e7c01.tar.gz |
Fix pdfi+GS with spot capable devices
This is a chain of problems. Firstly we were unconditionally setting
the 'init_graphics' parameter to pdfi_check_page() which caused it to
close and reopen the device. This throws away the Media Size, CTM and
any cropping/rotation etc which we set up in the PostScript world.
Resolving that then showed that we were not resetting the number of
spots on each page.
Resolving that then showed up a failure to determine that a device was
spot colour capable, because we were doing the pdfi_check_page() call
to retrieve the per-page transparency and spot information when the
PDF graphics state wasn't pointing to the PostScript graphics state,
which meant we were using the nulldevice.
This commit fixes all of the above problems. The various spot-capable
devices now render their content to the correct size/orientation/clip
and get the correct number of spots.
-rw-r--r-- | Resource/Init/pdf_main.ps | 11 | ||||
-rw-r--r-- | pdf/pdf_check.c | 6 | ||||
-rw-r--r-- | pdf/pdf_page.c | 2 | ||||
-rw-r--r-- | psi/zpdfops.c | 17 |
4 files changed, 28 insertions, 8 deletions
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps index aaf808072..877b0e1f5 100644 --- a/Resource/Init/pdf_main.ps +++ b/Resource/Init/pdf_main.ps @@ -341,13 +341,10 @@ systemdict /NEWPDF known not {/NEWPDF //false def} if /PageUsesTransparency exch % << >> <<page dict>> /PageUsesTransparency bool 3 index 3 1 roll % << >> <<page dict>> <<info dict>> << >> /PageUsesTransparency bool put % <</PageUsesTransparency bool>> <<page dict>> - /NumSpots get dup 0 gt { - /PageSpotColours exch % <</PageUsesTransparency bool>> /PageSpotColours int - 2 index 3 1 roll % <</PageUsesTransparency bool>> <</PageUsesTransparency bool>> /PageSpotColours int - put % <</PageUsesTransparency bool /PageSpotColours int>> - }{ - pop % <</PageUsesTransparency bool>> - } ifelse + /NumSpots get % <</PageUsesTransparency bool>> int + /PageSpotColors exch % <</PageUsesTransparency bool>> /PageSpotColors int + 2 index 3 1 roll % <</PageUsesTransparency bool>> <<page dict>> /PageSpotColors int + put % <</PageUsesTransparency bool /PageSpotColors int >> setpagedevice }bind def diff --git a/pdf/pdf_check.c b/pdf/pdf_check.c index d20e3a61d..7c5dd562d 100644 --- a/pdf/pdf_check.c +++ b/pdf/pdf_check.c @@ -1135,6 +1135,12 @@ int pdfi_check_page(pdf_context *ctx, pdf_dict *page_dict, bool do_setup) ctx->page.num_spots = 0; ctx->page.has_transparency = false; + /* Need to do this here so that pdfi_check_init_tracker will be setup + * for spot colours, if the device i s spot colour capable. + * It is also called in pdfi_page_render() and pdfi_process_pdf_file() + * TODO: Should probably look into that.. + */ + pdfi_device_set_flags(ctx); code = pdfi_check_init_tracker(ctx, &tracker); /* Check for spots and transparency in this page */ diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c index c93874eba..98945f0e9 100644 --- a/pdf/pdf_page.c +++ b/pdf/pdf_page.c @@ -778,7 +778,7 @@ int pdfi_page_render(pdf_context *ctx, uint64_t page_num, bool init_graphics) } pdfi_device_set_flags(ctx); - code = pdfi_check_page(ctx, page_dict, true); + code = pdfi_check_page(ctx, page_dict, init_graphics); if (code < 0) goto exit2; diff --git a/psi/zpdfops.c b/psi/zpdfops.c index 8386acbdf..30f34b8bc 100644 --- a/psi/zpdfops.c +++ b/psi/zpdfops.c @@ -585,6 +585,9 @@ static int zPDFpageinfo(i_ctx_t *i_ctx_p) int page = 0, code = 0, i; pdfctx_t *pdfctx; pdf_info_t info; + gs_gstate *pgs = NULL; + gs_gstate_client_procs procs; + void *client_data; check_op(2); @@ -594,7 +597,21 @@ static int zPDFpageinfo(i_ctx_t *i_ctx_p) check_type(*(op - 1), t_pdfctx); pdfctx = r_ptr(op - 1, pdfctx_t); + pgs = pdfctx->ctx->pgs; + procs = igs->client_procs; + client_data = igs->client_data; + pdfi_gstate_from_PS(pdfctx->ctx, igs, &client_data, &procs); + pdfctx->ctx->pgs = igs; + code = pdfi_page_info(pdfctx->ctx, (uint64_t)page, &info); + + pdfi_gstate_to_PS(pdfctx->ctx, igs, client_data, &procs); + if (code == 0) + code = gs_grestore(igs); + else + (void)gs_grestore(igs); + pdfctx->ctx->pgs = pgs; + if (code < 0) return code; |