0

In adobe acrobat x i was inserting text objects and when it is opened in adobe reader 10 it was opening properly.but in adobe reader 11 when i click on that pdf file text objects gets deleted.why this happens? How to solve it? The source pdf file click here

The pdf file which has problem when double clicking on it in adobe reader 11. click here

Kara
  • 6,115
  • 16
  • 50
  • 57
IT researcher
  • 3,274
  • 17
  • 79
  • 143

1 Answers1

1

In a nutshell:

You try to change the contents of a free text annotation by changing its normal appearance stream.

This is insufficient: A compliant PDF viewer may ignore this entry and provide their own appearances. So it's mere luck that older Adobe Reader versions chose to not ignore your change.

Thus, you also need to change the information a PDF viewer is expected to create their own appearance from, i.e. foremost the rich text value of RC (in the free text annotation dictionary) that shall be used to generate the appearance of the annotation, and also the Contents value which is the Text that shall be displayed for the annotation.

Furthermore there are defects in your PDFs:

  • the cross reference table in your first attempt result.pdf was broken;
  • the intent (IT value) of the free text annotation in your source files is spelled incorrectly.

In detail:

Your result.pdf is broken. Different PDF viewers may display broken PDFs differently.

Some details:

It has been created based on your Src.pdf in append mode but additionally the following change in the original revision has been made to its /Pages object:

In the source:

6 0 obj
<</Count 6
/Type /Pages
/Kids [ 7 0 R 8 0 R 9 0 R 10 0 R 11 0 R 12 0 R ]
>>
endobj

In the result:

6 0 obj
<</Count 3
/Type /Pages
/Kids [ 7 0 R 8 0 R 9 0 R 12 0 R 11 0 R 10 0 R ]
>>
endobj

So the order of the last three pages was changed (which is ok) and the /Count was reduced from 6 to 3. This is inconsistent as there still are 6 child objects but according to the PDF specification ISO 32000-1, Count is

The number of leaf nodes (page objects) that are descendants of this node within the page tree.

Furthermore the cross reference stream of the appended revision is broken.

xref
0 1
0000000000 65535 f
24 1
0001465240 00000 n
57 1
0001466075 00000 n
66 1
0001466909 00000 n
73 1
0001467744 00000 n
93 1
0001473484 00000 n
131 1
0001478703 00000 n 

The entries are 19 bytes long including their respectively ending single byte newline character According to the spec, though,

Each entry shall be exactly 20 bytes long, including the end-of-line marker.

The format of an in-use entry shall be: nnnnnnnnnn ggggg n eol

where [...] eol shall be a 2-character end-of-line sequence

There may be more errors in the PDF but you may want to start fixing these.

EDIT

Now with the new PDF Pay-in.pdf with a proper cross reference at hand, let's look at it more in-depth.

Adobe Preflight complains about many occurances of:

[...]
An unexpected value is associated with the key
    Key: IT
    Value: /FreeTextTypewriter
    Type: CosName
    Formal Representation: Annot.AnnotFreeText
    Cos ID: 86
    Traversal Path: ->Pages->Kids->[0]->Annots->[13]
[...]

Ok, let's look at that object 86:

86 0 obj
<<  /P 8 0 R
    /Type /Annot
    /CreationDate (D:20130219194939+05'30')
    /T (winman)
    /NM (0f202782-2274-44b8-9081-af4010be86d4)
    /Subj (Typewritten Text)
    /M (D:20130219195100+05'30')
    /F 4
    /Rect [ 53.2308 33.488 552.088 826.019 ]
    /DS (font: Helv 12.0pt;font-stretch:Normal; text-align:left; color:#000000 )
    /AP <</N 107 0 R >>
    /Contents (wwww)
    /IT /FreeTextTypewriter
    /BS 108 0 R
    /Subtype /FreeText
    /Rotate 90
    /DA (16.25 TL /Cour 12 Tf)
    /RC (<?xml version="1.0"?>
         <body xmlns="http://www.w3.org/1999/xhtml"
               xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"
               xfa:APIVersion="Acrobat:10.0.0"
               xfa:spec="2.0.2"
               style="font-size:12.0pt;text-align:left;color:#000000;font-weight:normal;
                      font-style:normal;font-family:Helv;font-stretch:normal">
           <p dir="ltr">
             <span style="line-height:16.3pt;font-family:Helvetica">wwww</span>
           </p>
         </body>)
>>
endobj 

Preflight stated that it is unhappy about the line /IT /FreeTextTypewriter. Looking at the PDF specification again uncovers for annotations with /Subtype /FreeText, i.e. Free Text Annotations specified in section 12.5.6.6:

IT name (Optional; PDF 1.6) A name describing the intent of the free text annotation (see also the IT entry in Table 170). The following values shall be valid:

FreeText The annotation is intended to function as a plain free-text annotation. A plain free-text annotation is also known as a text box comment.

FreeTextCallout The annotation is intended to function as a callout. The callout is associated with an area on the page through the callout line specified in CL.

FreeTextTypeWriter The annotation is intended to function as a click-to-type or typewriter object and no callout line is drawn.

Default value: FreeText

Thus, your value FreeTextTypewriter is invalid (remember, PDF names are case sensitive!). Therefore, the annotation is (slightly) broken which may already result in all kinds of problems.

But there are other important entries here, too, to understand your issue: All you do in your appended changes is to replace the appearance stream in object 107 (as per /AP <</N 107 0 R >>) of this annotation by a different one. But this annotation contains an RC value, too, which according to the specification is

A rich text string (see 12.7.3.4, “Rich Text Strings”) that shall be used to generate the appearance of the annotation.

Thus, any PDF viewer may regenerate the appearance from that rich text description, especially as the specification in section 12.5.2 says about the content of the AP dictionary

Individual annotation handlers may ignore this entry and provide their own appearances.

Thus, simply replacing the normal appearance stream does not suffice to permanently change the appearance of that annotation, you have to change the appearance dictionary and at least remove any alternative source for the appearance.

Furthermore the entry /Contents (wwww) is not replaced by your appended changes either. So a PDF viewer trying to decide whether to use the appearance stream or not will feel tempted to somehow create a new appearance as your appearance stream in no way represents that value.

Especially when starting to manipulate the free text (e.g. when clicking into the PDF in your case), the PDF viewer knows it eventually will have to create a new appearance anyways, and unless the current appearance is as it would have created it anyway, the viewer may prefer to begin anew starting with an appearance derived from the rich text or even the contents value.

mkl
  • 90,588
  • 15
  • 125
  • 265
  • I think count is the number of pages. I have another pdf with only one page.This pdf also has same problem. [link](http://incometaxsoft.com/pdf/Pay-in.pdf) Please check this. – IT researcher Feb 27 '13 at 05:22
  • In this pdf [link] (incometaxsoft.com/pdf/Pay-in.pdf) i have made corrections related to xref etc. but still i have same problem. – IT researcher Feb 27 '13 at 05:58
  • Extended the answer to include an analysis of [Pay-in.pdf](http://incometaxsoft.com/pdf/Pay-in.pdf). – mkl Feb 27 '13 at 12:51
  • How i insert text to the pdf is by using "Incremental Updates" specified in the pdf specification u have mentioned. What i used to do is copy the 107 0 obj to the end and add text using "Incremental Updates" and then set the proper position for the text. I have another pdf which i used as source [link]http://incometaxsoft.com/pdf/source.pdf .To this pdf i added a single text "B"(u can see it in bank fileld in pdf file).The modified pdf after editing is [link]http://incometaxsoft.com/pdf/modified.pdf . So please tell me what i am doing using is wrong? If wrong den please inform me. – IT researcher Feb 28 '13 at 07:52
  • plz read my above comment before this. This modified pdf displays properly in all adobe reader except adobe reader 11.In adobe reader 11 on double clicking the pdf the added text("B") gets deleted. – IT researcher Feb 28 '13 at 08:02
  • @winman Yes, you do an incremental update, and using that technique is an appropriate way. But you do not update all that needs to be updated. All you updated in result.pdf and Pay-in.pdf (I have yet to inspect your new files) was the **normal appearance stream** of the free text annotation. As quoted in my answer, though, PDF viewers are free to **ignore this entry and provide their own appearances.** So it's mere *luck* that older Adobe Reader versions chose to *not ignore* your addition. If you want your changes to be respected by viewers, also update the **RC** and **Contents** values. – mkl Feb 28 '13 at 09:13
  • I just looked into your new file [modified.pdf](http://incometaxsoft.com/pdf/modified.pdf). You still merely change the appearance stream of the free text annotation which is the part of the annotation a compliant PDF viewer is free to ignore. – mkl Feb 28 '13 at 09:29
  • As an aside, already your source documents Src.pdf and source.pdf exhibit the special behaviour in Adobe Reader XI --- just try it, either one when clicked into suddenly displays **wwww** in the upper left corner of the document (which, BTW, is the text contained in **RC** and **Contents**). So, not only you in your updating application but also the person supplying you with the source documents should correct their free text annotation. – mkl Feb 28 '13 at 10:14
  • If i delete the annotation then this issue will be solved? Also can u guide me how to add the new text to the existing pdf? – IT researcher Feb 28 '13 at 12:01
  • *If i delete the annotation then this issue will be solved?* --- No, at least as long as your intention is to add text like you do it now, because your current approach is manipulating that very annotation. You only have to update *all* relevant fields of it, not merely the appearance. If you want to change your general approach, please make that a stackoverflow question in its own right. – mkl Feb 28 '13 at 12:07
  • i tried to correct the RC and content values. But i didn't able to find what exactly wrong with what i am doing. So please help with an example on this. – IT researcher Feb 28 '13 at 14:05
  • What have you tried? Furthermore, as mentioned before, this starts to be a question in its own right along the lines of "How do the **Contents** and **RC** of a free text annotation have to be to allow Adobe Reader to reconstruct my desired appearance." – mkl Feb 28 '13 at 14:32
  • 1
    please see my new question here http://stackoverflow.com/questions/15151097/how-to-add-text-object-to-existing-pdf – IT researcher Mar 01 '13 at 05:32