Read pixel data from placed pdf

New Here ,
Feb 19, 2021 Feb 19, 2021

Copy link to clipboard

Copied

I use inDesign to create cue books for synchronizing supertitles with musical performances. My task is to place a snippet (2 text boxes and 2 vertical lines) onto a page of musical score like this:
Screen Shot 2021-02-19 at 2.43.12 AM.pngAt the moment, I open the snippet and click to place it on the image. Then I have to move it into precise position, then select the bottoms of the lines and adjust them to the bottom of the staff. I paste or type in the text, then select the end of the text box to size it to fit.

I would like to create a script that can analyze the placed .pdf image to determine where the top and bottom lines of the staff are, to place the snippet and size the lines appropriately. 

My question is how to get the pixel data from the .pdf on the page. Is that even possible? My ideal work flow would be this:

  1. Run the script, which would load the snippet.
  2. Click above the point where the cue lines should appear.
  3. Have the script calculate the offset from there to the top-left of the snippet and place it there.
  4. Have the script analyze the image to find the bottom of the staff in question and set the lines to end there.
  5. Enter text from the clipboard into the text field, and size the field to fit.

I have been doing this process manually dozens of times for a short song, up to a thousand times or more for a major opera, so any automation would be a big improvement. I believe I can handle the logic and coding if I can learn how to access the .pdf pixel data.

TOPICS
How to, Scripting

Views

85

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 20, 2021 Feb 20, 2021

Copy link to clipboard

Copied

Hi @JayReeve 
interessting idea, I don't know if this analyzing is possible (I don't think so). 

But are the notes always in the same position?

I would assume so, then you can place your snippet with Option/Alt + Click and it will restore it at the same position at which it was originally created. You can change that to the default behaviour in the preference (File handling -> Snippet import)

If you have multiple, e.g. four "lines" of notes on one page you could save your snippet with the maximum amount per page and delete if necessary.

And this workflow you can probably script, so that your script places the snippet on every page at the original position and then your only manual step would be to delete where you have fewer "lines".
 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

Edit>Preferences navigate to File Handling

  • Choose Original Location from the Position At menu to preserve objects’ original locations in snippets.
  • Choose Cursor Location from the Position At menu to place snippets according to where you click a page.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

Could you provide one of the pdfs? 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 21, 2021 Feb 21, 2021

Copy link to clipboard

Copied

I've attached a short example of the kind of .pdf I work with. Each .pdf page is placed (linked) on a document page in InDesign. It may or may not (often not) be placed at 100%, but I can deal with that if there is a way to get to the pixel values.
Thanks to those suggesting ways to simplify without the pixel analysis, but I believe I've already optimized that as much as possible:

  1. <Cmd-D> takes me to the folder where the snippet is stored.
  2. It's at the top of the list, so a <down-arrow> selects it.
  3. <Return> loads it to the cursor.
  4. I <click> where I think the top-left corner will be.
  5. Sometimes I hit it right, but the fact that the cue lines and bottom of text field are offset from the corner of the snippet means I often have to adjust the position both vertically and horizontally with the <arrowkeys>.
  6. <cmd-click-drag> selects the bottom of the cue lines.
  7. <shift-arrowkey> quickly positions the bottom of the lines near the bottom of staff.
  8. <arrowkey> adjusts them to their precise position.
  9. <click> in the text box readies it for text (typed or pasted).
  10. <cmd-click-drag> selects the right edge of the text box for resizing with arrow keys if needed.

There are additional steps needed if the text field goes off the side of the page, or if two cues are too close together, but that's irrelevant to this.

I've done this enough thousands of times that it's a pretty smooth flow, but obviously getting a script to do any significant part of it would help immensely. I would enjoy the challenge of coding it, but have nowhere to start unless there is a way to access the .pdf image pixels. Maybe accessing screen pixels would be adequate, but probably not because one score can span the whole page, top to bottom, outside what is visible on screen.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines