summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNancy Durgin <nancy.durgin@artifex.com>2021-05-06 12:21:48 -0700
committerNancy Durgin <nancy.durgin@artifex.com>2021-05-06 14:27:55 -0700
commit566957f79d7a1249bf8daf122e00a99b287735e7 (patch)
tree07d43d0ae293de836bc9bcb73248c69771d59ac2
parent4a611489eacf2cad1ba3ca38cca86051861de65e (diff)
downloadghostpdl-566957f79d7a1249bf8daf122e00a99b287735e7.tar.gz
Annotation enhancements -- AP and field /CH
If there is no /N AP, then find /R or /D. This is what gs does. Also, apparently not finding the matching AS doesn't seem to be an error, it just means don't use an AP? Implement field /Ch This is a text choice field, and gs implements it basically the same as Tx, except making sure to regenerate the AP if NeedAppearances is set.
-rw-r--r--pdf/pdf_annot.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c
index 458e8ae2a..0a7d64740 100644
--- a/pdf/pdf_annot.c
+++ b/pdf/pdf_annot.c
@@ -1511,9 +1511,25 @@ static int pdfi_annot_get_NormAP(pdf_context *ctx, pdf_dict *annot, pdf_obj **No
if (code <= 0) goto exit;
code = pdfi_dict_knownget(ctx, AP_dict, "N", (pdf_obj **)&baseAP);
- if (code <= 0) goto exit;
+ if (code < 0) goto exit;
- code = 0;
+ /* Look for /R and /D if there was no /N */
+ if (code == 0) {
+ dbgmprintf(ctx->memory, "*** Error: Annotation (AP) lacks the mandatory normal (N) appearance.\n");
+ dbgmprintf(ctx->memory, " Output may be incorrect.\n");
+ ctx->pdf_warnings |= W_PDF_ANNOT_AP_ERROR;
+
+ code = pdfi_dict_knownget(ctx, AP_dict, "R", (pdf_obj **)&baseAP);
+ if (code < 0) goto exit;
+
+ if (code == 0) {
+ code = pdfi_dict_knownget(ctx, AP_dict, "D", (pdf_obj **)&baseAP);
+ if (code < 0) goto exit;
+ }
+ }
+
+ /* Nothing found */
+ if (code == 0) goto exit;
if (baseAP->type == PDF_STREAM) {
/* Use baseAP for the AP */
@@ -1536,8 +1552,7 @@ static int pdfi_annot_get_NormAP(pdf_context *ctx, pdf_dict *annot, pdf_obj **No
/* Lookup the AS in the NormAP and use that as the AP */
code = pdfi_dict_get_by_key(ctx, (pdf_dict *)baseAP, AS, (pdf_obj **)&AP);
if (code < 0) {
- dbgmprintf(ctx->memory, "WARNING Annotation has non-stream AP AS key doesn't match. Don't know what to render.\n");
- ctx->pdf_warnings |= W_PDF_ANNOT_AP_ERROR;
+ /* Apparently this is not an error, just silently don't have an AP */
code = 0;
goto exit;
}
@@ -3434,8 +3449,8 @@ static int pdfi_form_display_Tx(pdf_context *ctx, pdf_dict *annot, gs_rect *rect
}
-/* draw field Tx */
-static int pdfi_form_draw_Tx(pdf_context *ctx, pdf_dict *annot, pdf_obj *AP)
+/* At least for now, Tx and Ch are handled the same */
+static int pdfi_form_draw_Tx_Ch(pdf_context *ctx, pdf_dict *annot)
{
int code = 0;
pdf_string *V = NULL;
@@ -3444,9 +3459,6 @@ static int pdfi_form_draw_Tx(pdf_context *ctx, pdf_dict *annot, pdf_obj *AP)
int64_t MaxLen;
int64_t Q;
- if (AP != NULL)
- return pdfi_annot_draw_AP(ctx, annot, AP);
-
code = pdfi_annot_Rect(ctx, annot, &annotrect);
if (code < 0) goto exit;
@@ -3477,17 +3489,22 @@ static int pdfi_form_draw_Tx(pdf_context *ctx, pdf_dict *annot, pdf_obj *AP)
return code;
}
+/* draw field Tx */
+static int pdfi_form_draw_Tx(pdf_context *ctx, pdf_dict *annot, pdf_obj *AP)
+{
+ if (AP != NULL)
+ return pdfi_annot_draw_AP(ctx, annot, AP);
+
+ return pdfi_form_draw_Tx_Ch(ctx, annot);
+}
+
/* draw field Ch */
static int pdfi_form_draw_Ch(pdf_context *ctx, pdf_dict *field, pdf_obj *AP)
{
- int code = 0;
-
if (!ctx->NeedAppearances && AP != NULL)
return pdfi_annot_draw_AP(ctx, field, AP);
- dmprintf(ctx->memory, "WARNING: AcroForm field 'Ch' with no AP not implemented.\n");
-
- return code;
+ return pdfi_form_draw_Tx_Ch(ctx, field);
}
/* draw field Sig */