Article View: adobe.scripting.indesign
Article #2478Re: Changing script from CS2 to CS4
From: Peter_Bornhall
Date: Wed, 17 Dec 2008 06:36
Date: Wed, 17 Dec 2008 06:36
50 lines
3397 bytes
3397 bytes
What I ended up doing was create roughly enough pages in the document and create linked text frames on all pages, thus letting the table created in the first text frame flow as long as the document has enough pages. In the end processing, I then remove all the pages but the first one, effectively getting one page with one text frame containing all table contents.
This was the only way I could find to get around this problem. No matter what I did, placing content into a table cell that was overflowing a text frame just didn't work.
Here's the part where I create the pages (variable myMaxPages contains your estimated maximum number of pages). Please note in app.documents.add() that it is set to false to NOT open a window (speeds it up very slightly if you have a huge number of pages). You can remove the false and the myDocument.windows.add() statement if you don't want this or for debug purposes.
myDocument = app.documents.add( false ); with(myDocument) {
for( i = 0; i < myMaxPages; i++ ) { myPage = pages.item(i); with(myPage)
{ if( i > 0 ) { myPrevFrame = myTextFrame; }
myTextFrame = textFrames.add();
with( myTextFrame ) {
if( i == 0 ) {
myTable = tables.add();
with( myTable ) {
bodyRowCount = 1;
columnCount = 5;
}
} else {
if( i > 0 ) { previousTextFrame = myPrevFrame; }
}
}
}
if( i < myMaxPages - 1 ) { pages.add(); } } } myDocument.windows.add();
While fiddling with it, I also updated my image placement code a bit:
var myCell = myTable.rows[myTable.bodyRowCount-1].cells[4]; myCell.contents
= "\r";
myCell.paragraphs.item(0).justification = Justification.centerAlign;
var myRect = myCell.insertionPoints[0].textFrames.add();
myRect.contentType = ContentType.unassigned;
myRect.visibleBounds = ["0mm","0mm","38.236mm","38.236mm"];
myRect.geometricBounds = ["0mm","0mm","38.236mm","38.236mm"];
var myFile = File(PICBASE + tmpBild);
if( myFile.exists ) {
var myImage = myRect.place( myFile );
myRect.fit( FitOptions.proportionally );
myRect.fit( FitOptions.frameToContent );
}
Maybe this helps someone, maybe it doesn't. Can't say that I'm happy with the behaviour of getting errors and being unable to place content in table cells that is overflowing out of a text frame, but I needed to solve it, and this is how I did it.
Of course, if anyone else has a better solution to placing images into table cells that may be in the overflowing part of a text frame, go ahead and share with the rest of us, please.
Technical Details
Message-ID:
<59b71fd2.2@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossingReferences:
<59b71fd2.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,7c2c09bf0a6c9354 X-Google-Attributes: gidf939a,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Peter_Bornhall@adobeforums.com Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!newshub.sdsu.edu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Changing script from CS2 to CS4 Message-ID: <59b71fd2.2@webcrossing.la2eafNXanI> Date: Tue, 16 Dec 2008 22:36:21 -0800 References: <59b71fd2.-1@webcrossing.la2eafNXanI> Lines: 68 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit