From ea58680eb07d1551d1f179532a3880e2d89f6c69 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 22 Feb 2020 12:10:13 -0500 Subject: [PATCH] Mention appearances in pdf-set-form-values example --- ChangeLog | 4 +++ examples/pdf-set-form-values.cc | 26 ++++++++++---------- examples/qtest/set-form-values/form-out.pdf | Bin 32166 -> 32300 bytes 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3d492e78..18328ca0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2020-02-22 Jay Berkenbilt + * Update pdf-set-form-values.cc to use and mention + generateAppearance, which hadn't been added when the example was + originally created. + * Detect, warn, and correct the case of /Pages in the document catalog incorrectly pointing to a page or intermediate node instead of the root of the pages tree. Fixes #398. diff --git a/examples/pdf-set-form-values.cc b/examples/pdf-set-form-values.cc index b0a4f2ad..becbedf3 100644 --- a/examples/pdf-set-form-values.cc +++ b/examples/pdf-set-form-values.cc @@ -73,23 +73,23 @@ int main(int argc, char* argv[]) annot_iter != annotations.end(); ++annot_iter) { // For each annotation, find its associated field. If - // it's a text field, set its value. This will - // automatically update the document to indicate that - // appearance streams need to be regenerated. At the - // time of this writing, qpdf doesn't have any helper - // code to assist with appearance stream generation, - // though there's nothing that prevents it from being - // possible. + // it's a text field, set its value. QPDFFormFieldObjectHelper ffh = afdh.getFieldForAnnotation(*annot_iter); if (ffh.getFieldType() == "/Tx") { - // Set the value. This will automatically set - // /NeedAppearances to true. If you don't want to - // do that, pass false as the second argument. For - // details see comments in - // QPDFFormFieldObjectHelper.hh. - ffh.setV(value); + // Set the value. Passing false as the second + // value prevents qpdf from setting + // /NeedAppearances to true (but will not turn it + // off if it's already on), so we call + // generateAppearance after setting the value. You + // may or may not want to do this depending on + // whether the appearance streams generated by + // qpdf are good enough for your purposes. For + // additional details, please see comments in + // QPDFFormFieldObjectHelper.hh for this method. + ffh.setV(value, false); + ffh.generateAppearance(*annot_iter); } } } diff --git a/examples/qtest/set-form-values/form-out.pdf b/examples/qtest/set-form-values/form-out.pdf index 011cb05be670a0ff47b833d71f471d967ba7a67b..e40027c55db8c1071ed4d687741c9988184938cf 100644 GIT binary patch delta 976 zcma))Jxc>Y5QdZ3$dMwDV3Fz+Q~1HLv%9mq)7dB~{Oas2g;-bz&&EPXAaH-c%0ff} z`2jI?6vf6$1hKcVGlh4tFxgRXs^#H*cRnvZ^H-yMw;B{2CIehZx+}9Y%Wp?Xvs8^< z?&^bw`ut*hxO<-~R$3poVXIS#+OMO>!q#bLHF_#tuSI+3XSst$`M9?oG>ZTDX7l9o z=C5yTx!HT48}7$e%1~qx9)`jAAtVv_Oi3dcL&bIG7cT)aFFDFsJegR79>Xc7tn$qo z6=xQ$uR|dnW0EFyY5p`24HsH6zS#&qEt}eXodseAT1`ynbj*`Di_A>biZ{96E_q+c}%?KrdOPY^^}p*I--n7)r}{s0R7Ljsv{-z>G#j2Xp} pC}I7MA?;&w@7dNtX|v>CH7JLEcT$mc$#b(GkfoqjTi@9Tz5q>7+eH8X delta 852 zcmZvaElvbM5QVe0LxLnhjah-K|E@Z~Vz~ecJU1ZYxWL{3fkKerFkA@_f|kIUAE)b`QiP!-JWfir;Crf*;FT3&-5_0?E(}enK1?zCRTO!kJrVE zH;7g?kAnq#gC~r^vRT9`vw)%t!_1U;)GhOuqY72nDT>*>Br)&B+d+%BbA62SY$dT9 z7PEU4U4T}`RO$@z%DVmqnTOsZFsDPn$mtMRE33UDbkF;N2-?SAUH>1E@C0tmt+1uK rvAeZ7B!x1BLULkcq`bh$Ojmi4kUQmc#4d8YfBbAN+V=ay&2{?)M-iyv