🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #19988

Re: fit to content ?

#19988
From: Peter Truskier
Date: Mon, 11 Nov 2002 05:40
30 lines
2160 bytes
I just ran into this problem in VB myself, and found this discussion in my search for an answer. 

It appears that the text frame does not implement the .fit method of page items, but a rectangle does. Here is a snippet that depnds on defining the object as a rectangle with content type of text. Note that the initial vertical dimension must be large enough so there is no overflow, otherwise the call to .fit will throw an exception. i.e., it will only shrink the frame, not extend it. 

-- Peter 

------------------------------------------------------------------------------ 
Private Sub Command1_Click() 
Dim oID As InDesign.Application 
Dim oDoc As InDesign.Document 
Dim oPage As InDesign.Page 
Dim oTF As InDesign.Rectangle 
Dim s As String 

Set oID = CreateObject("InDesign.Application.2.0") 
    oID.Activate 
    Set oDoc = oID.Documents.Add 
    Set oPage = oDoc.Pages(1) 
    Set oTF = oPage.Rectangles.Add 
    oTF.ContentType = idText 

	'It is important that the height of the rectangle be larger than required 
	'otherwise, the call to oTF.fit below will throw an exception 
    oTF.GeometricBounds = Array(".5in", ".5in", "11in", "3in") 
    s = "Put whatever text you want to here." 
    oTF.Contents = s 
	'The fit method will work with a rectangle, but not a text frame. 
    oTF.Fit idFrameToContent 
End Sub 
------------------------------------------------------------------------------
Technical Details
Message-ID: <1de637ee.3@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de637ee.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,93fd7f36e2d2c580
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2002-11-10 22:14:04 PST
From: "Peter Truskier" <peter@premediasystems.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-04!supernews.com!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: fit to content ?
Message-ID: <1de637ee.3@WebX.la2eafNXanI>
Date: Sun, 10 Nov 2002 21:40:17 -0800
References: <1de637ee.-1@WebX.la2eafNXanI>
Lines: 39
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit