IDMLlib Tutorial 4
-
Upload
mariaelena910 -
Category
Documents
-
view
38 -
download
4
description
Transcript of IDMLlib Tutorial 4
extract. process. automate.
For more Information please visit http://idmllib.com
Author: Oliver Häuser <[email protected]>
Lesson 4: Text and Images
• Content
• Lets get some Image and Text Information!
• Targetskills & Prerequisites
• Tutorial #1, #2 and #3
• Need some JAVA coding experience
• Optional: InDesign CS 4 to create Demo Files
• Don‘t worry. Get Demofiles from http://idmllib.com !
• Why ?
• You want to check out the IDMLlib in a few minutes
• You want to see how easy it is to code a QA workflow
2
About ?
What have you learned so far ?
• Export / Create IDML Files
• Access IDML Containers
• Brief overview of the IDML structure
• How to access basic information from IDML docs
3
Goal for this Tutorial
• Load an IDML File
• Get a list of spreads
• get some Information from the images on a spread
• get the content of text page items in the spreads
• Basically we parse spread by spread throughan IDML file and get the information we need!
• After this Tutorial you will be able to code your own Quality Assurance Workflow!
• something like: Are all images accesible
• correct color profiles ?
• spellchecker for text content anyone ?
4
Image: 1 „Page 1 & 2“
Sample InDesign Document
5
The example two pager
• Images
• we got image on the first spread
• and 3 on the second spread
• Text Boxes
• one text box on the first spread, center alligned
• two text boxes on the second spread
• first one is without allignment
• second is right alligned
6
And once more with code
• In the next slides we will access all images
• find out the filename and path
• and where those files are stored
• and when they were placed into the document
• and the actual and the effective PPI of the images
• actual ppi is the resolution of the image coming from the graphics program (e.g. Photoshop). Usually 300 ppi for offset printing. If this is 72 ppi it might be a lowres resolution image you do not want to use and maybe want to exchange!
• effective ppi tells you if an image was placed in Indesign and was then enlarged. What happens is that you now have less pixels of course and the final result probably looks terrible.
• The way to do it is to resize and retouch the image in Photoshop! Not in the layout program. Or get a better quality image !
7
Again just a few lines of code ...
• This is it:
8
Code reviewed
• List<String> spreadIdList = document.getSpreadIdList();
• get a list of all Spreads (see Tutorial #2 for explaination)
• for (String spreadId : spreadIdList)
• now we iterate through all spreads
• Spread theSpread = document.getSpreadById(spreadId);System.out.println("\nSpread: "+ spreadId + " with " + theSpread.getPageCount() + " page(s)");
• and here we access the Spread ID and the number of pages.Remember a spread can have several pages!
• List<Rectangle> rectangles = theSpread.getRectangleList();
• now accessing all rectangles on the spread, rectangles can contain images.
• for (Rectangle rectangle : rectangles)
• and we iterate through those
9
Code reviewed Part 2
• if (rectangle.getImageList().size() > 0)
• checking if there are any images at all
• Image image = rectangle.getImageList().get(0);Link link = image.getLinkList().get(0);
• get the link that hold all kinds of information
• Date linkImportTime = link.getLinkImportTime();System.out.println("Imported Image Time: " + linkImportTime);
• for instance the time the image was imported into the document!
• String linkResourceURI = link.getLinkResourceURI();System.out.println(linkResourceURI);
• or the storage path to the image (local or from a server ?)
• Double effectivePPI = image.getEffectivePpi().get(0);Double actualPPI = image.getActualPpi().get(0);System.out.println("actualPPI: " + actualPPI + " effectivePPI = " + effectivePPI)
• finally the actual and effective PPI - check for lowres images ...
10
Output
• This is your output:
11
Now get the text content
• The next code will ...
• find all text page items on each spread
• read it contents
• and the allignment
• What you can do with it ?
• spell check ?
• check content versus product databases
• extract text content from ID to CMS systems
• ...
12
What have you learned ?
• You know now how to ...• access images and text from the IDMLlib
• you can work with that content now
• probably have by now an idea about how powerful the IDMLlib can be for your workflow
• Next ...
• add a spell checker for central spell checking
• modify and save documents (later in Q1/2010)
• access complex image groups
13
Image: 2 „Code for TextInfo“
Code to access text content
14
TextInfo code explained
15
• List<String> spreadIdList = document.getSpreadIdList();
• first we get a list of all available spread ids
• for (String spreadId : spreadIdList)
• then we iterate through those
• Spread theSpread = document.getSpreadById(spreadIdSystem.out.println("\nSpread: " + spreadId + " with " + theSpread.getPageCount() + " page(s)");
• get the spread id and the info how many pages are there
• List<TextFrame> textFrameList = theSpread.getTextFrameList();
• now we access all the textframes on the spread
• for (TextFrame textFrameId : textFrameList)
• iterate through all text frames on the spread
• String parentStoryId = textFrameId.getParentStory();
• the parent story is the assigned story of the text frame
TextInfo code explained Part 2
• Story story = document.getStoryById(parentStoryId);
• then we get the story by id from the document
• ParagraphStyleRange psr = story.getParagraphStyleRangeList().get(0);
• get the first paragraph style range from the PSR list
• Justification justification = psr.getJustification();
• get the allignment of the paragraph style range
• String content = psr.getCharacterStyleRangeList().get(0).getContent();
• we get the first character style range and access its content
• System.out.println(content);
• print out the content
• System.out.println("The Justification is: " + justification);
• and print out the justification of the paragraph style range
16
• System.out.println(content);
• and print it out
• System.out.println("The Justification is: " + justification);
• and get the justification, like CenterAlligned
17
TextInfo output
18
• And the output ...
• the IDs such as ub9 can be found in the spread folder!
• remember that stories are separated from the text frame. the ParentStory property tells you which story belongs to which text frame.stories have an own folder, the Stories folder.all stories can be found inside this folder.
• If a property is not set, a null value can come back.
Ressources
19
• For more information
• watch the video
• visit http://idmllib.com
• follow us on Twitter http://twitter.com/IDMLlib
• write an email [email protected]
• for dev info contact Mr. Fink instead: [email protected]
• Yes we were not kidding when we claimed the IDMLlibis easy to use !
• Watch the usual channels for a new tutorial / video !
• Please give feedback ! We love to hear from you