Article View: adobe.scripting.indesign
Article #20039Re: Fiiting Image in Rectangle
From: Hans van Leeuwen
Date: Tue, 05 Nov 2002 14:44
Date: Tue, 05 Nov 2002 14:44
115 lines
5982 bytes
5982 bytes
Hello Roberto,
First of all thanks for helping me. I did what I learned on Juniorschool; take the two pictures, find differences and color the images ;)
But the only difference I can find is in the first script I am using a counter for looping and in the second one I am using the amount of files in a directory for looping.
Is the way of calculating the filename the problem. I can not use the second script because the random order of filenames is not in order with the sequence of the drawing names (like in the first script)
I hope this brings us closer to the solution.
In this script is the Fitting of the Image NOT WORKING:
Private Sub Command1_Click()
Dim myInDesign
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set myDocument = myInDesign.Documents.Add
Rem define directory with imagefiles
myMaptekst = "C:\Kiggen\kiggen"
Rem make textframe for textfile
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
myTextFrame.GeometricBounds = Array("0mm", "0mm", "297mm", "210mm")
Rem read textfile wich contains filenames & drawingnames
myFile = "C:\kiggen\index.txt"
Set myData = myTextFrame.Place(myFile)
Rem put data in table (is not InDesigntabel !!)
Set myTable = myTextFrame.ParentStory.Texts.Item(1).Tables.Add
Rem copy nr. of Rows
myRows = myTable.RowCount
Rem copy nrof columns
myColumn = myTable.ColumnCount
Rem msgbox is used for breakpoint
MsgBox "textfile is ingelezen"
Rem voor de gehele tabel
For myCounter = 1 To myRows
Rem copy filename in myCell1 and drawingname in myCell2
Set myCell1 = myTable.Rows.Item(myCounter).Cells.Item(1)
Set myCell2 = myTable.Rows.Item(myCounter).Cells.Item(2)
Rem add page
myPage = myDocument.Pages.Add
Rem point with myPaginanr to new page
myPaginanr = myCounter + 1
Rem create textframe(1) bottomside page
Set myTextFrame1 = myInDesign.ActiveDocument.Pages.Item(myPaginanr).TextFrames.Add
Rem add correct place and size
myTextFrame1.GeometricBounds = Array("293mm", "155mm", "297mm", "179mm")
Rem put filename in it
myTextFrame1.TextContents = "File: " + myCell1.TextContents
Rem create textframe(2) bottomside page
Set myTextFrame2 = myInDesign.ActiveDocument.Pages.Item(myPaginanr).TextFrames.Add
Rem add correct place and size
myTextFrame2.GeometricBounds = Array("293mm", "180mm", "297mm", "210mm")
Rem put drawingname in it
myTextFrame2.TextContents = "Tekening: " + myCell2.TextContents
Rem add Rectangl for placing image
Set myRectangle = myInDesign.ActiveDocument.Pages.Item(myPaginanr).Rectangles.Add
Rem give it de size of a landscape A4
myRectangle.GeometricBounds = Array("43.5mm", "-43.5mm", "253.5mm", "253.5mm")
Rem calculate the full path&filename
myFileName = myMaptekst + "\" + myCell1.TextContents
Rem put file in Rectangle
Set myImage = myRectangle.Place(myFileName)
Rem myRectangle.SendToBack
Rem Fit the file contents in the Rectangle
myRectangle.Fit idProportionally
Rem rotate landscape to portrait
myRectangle.RotationAngle = 90
Rem msgbox is used as control point
MsgBox "Drawing processed"
Next
End Sub
and in this one is the Fitting of the Image WORKING:
Private Sub Command1_Click()
Dim myInDesign
Set myInDesign = CreateObject("InDesign.Application.2.0")
Rem Create a new publication and assign it to the variable "myDocument"
Set myDocument = myInDesign.Documents.Add
Set myFileSystemObject = CreateObject("Scripting.FileSystemObject")
Set myFolder = myFileSystemObject.GetFolder("C:\kiggen\kiggen")
myCounter = 1
For Each File In myFolder.Files
Rem add page
myPage = myDocument.Pages.Add
Rem start with textframe 1 at the bottom of the page
Set myTextFrame1 = myInDesign.ActiveDocument.Pages.Item(myCounter).TextFrames.Add
myTextFrame1.GeometricBounds = Array("293mm", "140mm", "297mm", "169mm")
Rem start with textframe 2 at the bottom of the page
Set myTextFrame2 = myInDesign.ActiveDocument.Pages.Item(myCounter).TextFrames.Add
myTextFrame2.GeometricBounds = Array("293mm", "170mm", "297mm", "210mm")
Rem insert text
myText = "filenaam:"
myTextFrame1.TextContents = myText
Rem add Rectangle
Set myRectangle = myInDesign.ActiveDocument.Pages.Item(myCounter).Rectangles.Add
Rem sizes of a landscape A4
myRectangle.GeometricBounds = Array("43.5mm", "-43.5mm", "253.5mm", "253.5mm")
Rem name of the file to be imported
myFileName = File.Path
Rem put filenaam in the textframe
myTextFrame2.TextContents = myFileName
Rem put the filecontents in the Rectangle
Set myImage = myRectangle.Place(myFileName)
Rem Fit image proportionally in to rectangle
myRectangle.Fit idProportionally
Rem rotate to the portrait position
myRectangle.RotationAngle = 90
myCounter = myCounter + 1
Next
End Sub
As a Bonus; can you explain why InDesign except uncompresed TIF-files and does not except CCITT4 compressed TIF-files when I use the importfacility??
See You
Hans
Technical Details
Message-ID:
<1de6718c.3@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!isdnet!nntp.abs.net!news.algonet.se!algonet!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<1de6718c.-1@WebX.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,86a2a3e708b3fb7a X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-11-05 07:18:02 PST From: "Hans van Leeuwen" <info@vlas.info> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!isdnet!nntp.abs.net!news.algonet.se!algonet!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Fiiting Image in Rectangle Message-ID: <1de6718c.3@WebX.la2eafNXanI> Date: Tue, 5 Nov 2002 06:44:30 -0800 References: <1de6718c.-1@WebX.la2eafNXanI> Lines: 134 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit