[gs-commits] ghostpdl branch, pdfi, updated. jbig2dec-0.14-2648-gfa51251

[email protected] (Nancy Durgin) Fri, 13 Dec 2019 01:12:27 +0000 (UTC)
Newsgroups gmane.comp.printing.ghostscript.cvs
Message-ID <[email protected]>
The ghostpdl branch, pdfi has been updated
       via  fa512511bba56054a9402f4331a4fc45a9e1ab5d (commit)
      from  62572baee1390a4ee59faec1bc037ee69249a199 (commit)

----------------------------------------------------------------------
commit fa512511bba56054a9402f4331a4fc45a9e1ab5d
Author: Nancy Durgin <[email protected]>
Date:   Thu Dec 12 13:39:51 2019 -0800

    Set the default matrix during initialization
    
    Default matrix needs to be properly setup so that annotations will
    work right.  Basically annotations will do a gs_initgraphics() which
    needs the default matrix to be properly set.
    
    Fixes bug when page is rotated, for example:
    tests_private/comparefiles/jpx-689261.pdf
    
    Plus, fix typo in check for Open in PopUp annotation.

diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c
index 09dbedf..607f199 100644
--- a/pdf/pdf_annot.c
+++ b/pdf/pdf_annot.c
@@ -546,7 +546,7 @@ static int pdfi_annot_draw_Popup(pdf_context *ctx, pdf_dict *annot, pdf_dict *No
     bool Open = false;
 
     /* Render only if open */
-    code = pdfi_dict_get_bool(ctx, annot, "Annots", &Open);
+    code = pdfi_dict_get_bool(ctx, annot, "Open", &Open);
     if (code < 0 && (code != gs_error_undefined))
         goto exit;
 
diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c
index 504f57b..180d01f 100644
--- a/pdf/pdf_page.c
+++ b/pdf/pdf_page.c
@@ -155,21 +155,27 @@ static int pdfi_process_one_page(pdf_context *ctx, pdf_dict *page_dict)
     return code;
 }
 
-/* Just dealing with UserUnit for now.
- * See pdf_PDF2PS_matrix and .pdfshowpage_Install
- */
+/* See pdf_PDF2PS_matrix and .pdfshowpage_Install */
 static void pdfi_set_ctm(pdf_context *ctx)
 {
     gs_matrix mat;
 
+    /* Adjust for UserUnits */
     mat.xx = ctx->UserUnit;
     mat.xy = 0;
     mat.yx = 0;
     mat.yy = ctx->UserUnit;
     mat.tx = 0;
     mat.ty = 0;
-
     gs_concat(ctx->pgs, &mat);
+
+    /* We need to make sure the default matrix is properly set.
+     * If we do gs_initgraphics() later (such as for annotations)
+     * then it uses this default matrix if it is set.
+     * Needed for page rotations to work correctly with Annotations.
+     */
+    gs_setdefaultmatrix(ctx->pgs, &ctm_only(ctx->pgs));
+
 }
 
 static int pdfi_set_media_size(pdf_context *ctx, pdf_dict *page_dict)
@@ -269,6 +275,11 @@ static int pdfi_set_media_size(pdf_context *ctx, pdf_dict *page_dict)
     }
     gs_c_param_list_release(&list);
 
+    /* Resets the default matrix to NULL before doing initgraphics, because
+     * otherwise initgraphics would keep old matrix.
+     * (see pdfi_set_ctm())
+     */
+    gs_setdefaultmatrix(ctx->pgs, NULL);
     gs_initgraphics(ctx->pgs);
 
     switch(rotate) {


Summary of changes:
 pdf/pdf_annot.c |  2 +-
 pdf/pdf_page.c  | 19 +++++++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)