This is to continue for this question, When I am trying to resolve Form Xobjects in pdf I am getting some error when I open it in adobe.
The source file is here.
After Form Xobject extraction this pdf is having some issues.
But, I verified the content stream it's not rendering the full content stream after extraction. For some reason, it's broken. While writing content stream to page the full page operators are there. After rendering it's missing some tokens as shown in below figure.
But same way (as coded in above question) I am extracting form Xobjects in other pdf's its working but not here. Am I missing anything?
You have an error in your pattern renaming code.
When embedding the form XObject content streams into the page content stream you try to rename the resources of the XObject to prevent name collisions. In case of pattern resources, though, your follow-up renaming in the content stream is incorrect, you rename the identifier for the pattern color space instead of the actual pattern.
For example, when embedding
/Pattern cs
/P50 scn
you change it to
/Pattern_Fm1 cs
/P50 scn
while you should have changed it to
/Pattern cs
/P50_Fm1 scn
PS: Of course the argument of cs and CS must be renamed wherever it refers to a specific resource. But there are a few possible values that have a fixed meaning and don't refer to a specific resource. According to the specification:
ISO 32000-1, Table 74 – Colour Operators, entry for CS |
---|
The names DeviceGray, DeviceRGB, DeviceCMYK, and Pattern always identify the corresponding colour spaces directly; they never refer to resources in the ColorSpace subdictionary. |
Thus, you must not rename these colorspace names. The other names, referring to resources, must be renamed.