Rectangle vs. Graphic Frame
Copy link to clipboard
Copied
Hi all,
does anyone have any idea how to differentiate between these two rectangles using ExtendScript.
About the creation process: An XML tag was assigned to the lower rectangle, which was then removed. This way, the appearance in the layer palette can be recreated.
They do not differ in IDML. Thus, the lower element becomes a “normal” rectangle when the IDML file is opened.
Thanks for any hints
Roland
Copy link to clipboard
Copied
I am not sure what your goal or needs are, but ID frames are... malleable entities that shift with the designer's whim. Drag out a "Rectangle"; drag out a rectangular "Frame"; either can be used as a graphics element or tagged as a graphics or text frame by subsequent actions.
Not a Script Guy, but I'd wager that script-level actions are no more differentiated. That is, I'd bet you can create a (graphics) Rectangle and follow up with assigning and formatting text in it, or placing a graphic, and vicey-versey-alleey-roundy.
Copy link to clipboard
Copied
Thank you for your answer. That's right, you can convert it back to its original state. But what I want to find out is how these two states of the rectangle can be distinguished at script level.
Both are rectangle frames, both have (it seems) the same script properties and are the same in IDML. Only one rectangle was tagged once (XML) and the tag removed again.
Background, why I want to find out: one rectangle is tagged when exporting a PDF, the other is not.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
In principle, I just want to identify these specific spline items. I get an unknown document, loop through the items and analyze them. These items that are not “normal” should be listed.
The reason is that they are treated differently when exported to a tagged PDF.
InDesign:
Copy link to clipboard
Copied
Define "not normal".
As I've suspected - XML creates a "structure" in your document - tree to your object.
Still - what is your end goal?
Tag objects that hasn't been "touched" by XML?
Copy link to clipboard
Copied
Define "not normal".
By Robert at ID-Tasker
Normal is perhaps the wrong term. But look in the layer palette, there the two rectangles differ in their automatically assigned names. The tag behavior is different when exporting. If you create an IDML and open a document from it, “Rectangle” appears again in the layer palette. So they are obviously different, but not in the script properties. And I think that's strange.
Copy link to clipboard
Copied
OK, but still - what is your end goal? Why do you need to find the "wrong" ones?
What do you have to do with them?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
What options do you have set in the PDF export dialog?
Because in print and interactive - I got this from you file:
Copy link to clipboard
Copied
No special settings. Only Interactive PDF and “Create PDF with tags”. You get the same result, don't you?
Copy link to clipboard
Copied
No special settings. Only Interactive PDF and “Create PDF with tags”. You get the same result, don't you?
By Roland Dreger
Looks that way:
I think it's because of XML. Some kind of leftovers after tagging?
Copy link to clipboard
Copied
But tagging is pulled from ObjectStyle / XML info - objects don't have a "accessiblity tag" property...
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#TagType.html
Copy link to clipboard
Copied
In principle, I just want to identify these specific spline items. I get an unknown document, loop through the items and analyze them. These items that are not “normal” should be listed.
The reason is that they are treated differently when exported to a tagged PDF.
So, I'm still coming away with the impression that this is more intellectual curiosity/tech puzzle than anything relevant to a real-world need. Yes, I understand the mania obsession regulatory-pressured focus on accessibility, and there are lots of grimy cracks and broken corners in PDF export with respect to that... but, simple question:
Does this difference actually result in any variation of accessiblity in an otherwise conforming PDF? Or, is it ever likely to?
Not saying it's not worth pursuing and possibly "fixing" even if it's benign, but there is a difference between need and... curiosity. Or so I think.
Copy link to clipboard
Copied
This (I'll call it) bug is certainly a rare case and apparently only occurs with documents that previously contained an XML structure.
But there is also a practical relevance. If this is not dealt with, a check (in this case PAC) results in an error: "Alternative text missing for 'Figure' structure element"
But of course, curiosity also plays a role here.
Copy link to clipboard
Copied
Hi @Roland Dreger, I couldn't find a single thing that differentiated these two frames, based on doing diff between the two dumps in the ExtendScript debugger. Maybe the exported XML is different?
I don't know your use case, but I wondered if the following code might be safe to use:
var doc = app.activeDocument,
item1 = doc.rectangles[0],
item2 = doc.rectangles[1];
resetGraphicRectangle(item1);
resetGraphicRectangle(item2);
function resetGraphicRectangle(item) {
if (
ContentType.GRAPHIC_TYPE !== item.contentType
|| 0 === item.graphics.length
)
return;
item.contentType = ContentType.UNASSIGNED;
item.contentType = ContentType.GRAPHIC_TYPE;
};
Edit: fixed typo.
- Mark
Copy link to clipboard
Copied
Good idea @m1b
Just wonder if the core issue is addressed - rather than resetting.
Maybe some Metadata or Hidden Attributes could be added to the frame. While the obvious properties are identical, this would mean a hidden attributes or metadata (perhaps a label, taggedPDFData, or custom object metadata) that might be accessible by ExtendScript.
I'd try with testing export Tags, since Roland mentioned differences in PDF tagging, maybe a script could compare export tag settings (perhaps tagged PDF Data or other related properties).
Could a check for Custom Label where untagging elements could leave residual label data or other flags? Perhaps there's a way for a script to loop through all objects and differentiate label properties.
Copy link to clipboard
Copied
Hi Mark, hi Eugene,
thank you for your investigation. My use case: Before the PDF export, it should be checked whether a tag (tagged PDF) is exported for an object. I would prefer not to change anything in the document during this check, otherwise it could potentially irritate the users.
But for an action to correct these issues, this is a good idea. Possibly also check whether an XML element is still associated with the object.
Roland
Copy link to clipboard
Copied
Alas, as you can guess, I'm out of my depth here. I hope someone more knowledgeable about this area of scripting can help. Eugene, I'm not sure I follow your idea, but if you have time, perhaps you could pursue it with Roland's sample file? It sounds intriguing.
Copy link to clipboard
Copied
I can give it a go - I'm not the best scripter but I don't really know the end goal here or what the purpose of it is.
If there was more info to give that would be great.
Copy link to clipboard
Copied
Here are some screenshots But don't do too much work. It's a special case. And I'd just be interested to know how you can identify these special items.
Copy link to clipboard
Copied
Here are some screenshots But don't do too much work. It's a special case. And I'd just be interested to know how you can identify these special items.
By Roland Dreger
Can you share some INDD document(s)?
I could run them through my ID-Tasker tool.
Copy link to clipboard
Copied
@Robert at ID-Tasker, there is a document attached to Roland's first post.
Copy link to clipboard
Copied
Yes @Eugene Tyson, "don't do too much work" is good advice. I believe Roland has more scripting experience than either of us and probably has probably experimented copiously before posting the question here. If we don't know a fix by our prior experience, looking for a solution now will probably double-up work that Roland has already done. (But I don't want to put you off if you want the learning experience, which is usually time well spent.)

