Article View: adobe.scripting.indesign
Article #14686Re: [VB]Image on wrong page.
From: Roel_G
Date: Wed, 21 Jan 2004 14:22
Date: Wed, 21 Jan 2004 14:22
231 lines
8326 bytes
8326 bytes
Hi again.
Maybe I should post my full sourcecode here.
* ************** Source Code starts here ******************* 'everything is commented in dutch.
Private Sub create_Click()
'Declareer een indesign applicatie object
Dim myIndesign As InDesign.Application
'Declareer een indesign document object
Dim myDocument As InDesign.Document
'declareer een pagina object
Dim myPage As InDesign.Page
'Declareer een textframe object
Dim myText As InDesign.TextFrame
'Declareer een Rechthoek object
Dim myImg As InDesign.Rectangle
'Declareer een teller.
Dim i As Integer
'Maak een my indesign applicatie object aan en start indesign.)
Set myIndesign = CreateObject("Indesign.Application.2.0")
'Maak een nieuw document aan in indesign
Set myDocument = myIndesign.Documents.Add
'myDocument.ViewPrefences.HorzMeasurementUnits = idMSMillimeters
'myDocument.ViewPreference.VertMeasurementUnits = idMSMillimeters
'Zet de RulerOrigin op PageOrigin zodat iedere page zijn eigen coordinaten heeft.
myDocument.ViewPreferences.RulerOrigin = idPageOrigin
Dim myColors As InDesign.Colors
Set myColors = myDocument.Colors
Dim myColor As InDesign.Color
Set myColor = myColors.Add
myColor.Space = idCMYKcolor
myColor.ColorValue = Array(100, 69, 0, 11)
myColor.Name = "AA"
'zet de teller op 1
'i = 1
'maak de voorpagina
Call Front_page
'Connectie naar mysql toe
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;User ID=root;Data Source=mysql_test"
'open de connectie
con.Open
'creatie van een recordset
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
'selecteer alles uit de databanks tabel prod
sqlstring = "select * from prod"
'Voer de sqlstring uit met de geopende connectie en steek het resultaat in de recordset.
rs.Open sqlstring, con
'start een lus tot er geen rijen meer in de recodset zijn.
While Not rs.EOF
'Voeg een pagina toe.
myDocument.DocumentPreferences.NumberOfPages = myDocument.DocumentPreferences.NumberOfPages + 1 = myDocument.DocumentPreferences.NumberOfPages
'Ga naar pagina nummer i (de net aangemaakte pagina)
Set myPage = myDocument.Pages.Item(i)
'maak een textframe aan op deze pagina
Set myText = myPage.TextFrames.Add
'maak een rechthoek aan op deze pagina
Set myImg = myPage.Rectangles.Add
'pWidht bevat de breedte van de pagina.
pWidth = myDocument.DocumentPreferences.PageWidth
'pHeight bevat de hoogte van een pagina
pHeight = myDocument.DocumentPreferences.PageHeight
'mleft is de linker marge
mleft = myPage.MarginPreferences.MarginLeft
'mright is van aan de linkermarge en 25 picas verder.
mright = mleft + 25
'mtop is de bovenmarge
mtop = myPage.MarginPreferences.MarginTop
'mbottom is de bovenmarge + 25 picas
mbottom = mtop + 25
'Zo ontstaan er met mleft, mtop, mbottom en mright de coordinaten om een vierkant
' van 25 picas op 25 ta maken dat gepositioneerd is net binnen de marges links bovenaan.
'maak van de myImg rechthoek een vierkant van 25 op 25 picas.
'en zorgt ervoor dat het net binnen de marges links bovenaan blijft.
myImg.GeometricBounds = Array(mtop, mleft, mbottom, mright)
'maak een pat naar een figuur.
myFile = "C:\MABPictures\" & rs.Fields("foto")
'plaatst het figuur in myImg.
myImg.Place myFile
'zorg er voor dat de figuur zijn verhoudingen behoud als het in dit vierkant
'geplakt word dat kleiner is als de figuur zelf.
myImg.Fit idProportionally
'Centreer de figuur binnen het vierkant.
myImg.Fit idCenterContent
'Zorgt ervoor dat de textframe 3 picas onder de figuur komt te staan
myText.GeometricBounds = Array(mtop + mbottom + 3, mleft, mbottom, mright)
'haal text uit de databank.
artikelcode = rs.Fields("artikelcode")
'Zet deze tekst in de textframe
myText.Contents = artikelcode
Call Footer(i)
'ga naar volgend record in Database
rs.MoveNext
'herstart de loop.
Wend
'sluit de connectie met de databank.
con.Close
End Sub
Private Sub Form_Load()
'Zet standaard Nederlands aan.
NL.Value = True
End Sub
Private Sub Front_page()
'Deze functie zal de frontpagina opmaken.
'Declareer een indesign applicatie object
Dim myIndesign As InDesign.Application
'Declareer een indesign document object
Dim myDocument As InDesign.Document
'declareer een pagina object
Dim myPage As InDesign.Page
'Declareer een textframe object
Dim myText As InDesign.TextFrame
'Declareer een Rechthoek object
Dim myImg As InDesign.Rectangle
'Maak een my indesign applicatie object aan en start indesign.)
Set myIndesign = CreateObject("Indesign.Application.2.0")
'Laat het programma weten dat je op het actieve document wil werken.
Set myDocument = myIndesign.ActiveDocument
'Zet de RulerOrigin op PageOrigin zodat iedere page zijn eigen coordinaten heeft.
myDocument.ViewPreferences.RulerOrigin = idPageOrigin
Set myPage = myDocument.Pages.Item(1)
'pWidth bevat de breedte van de pagina.
pWidth = myDocument.DocumentPreferences.PageWidth
'pHeight bevat de hoogte van een pagina
pHeight = myDocument.DocumentPreferences.PageHeight
'mleft is de linker marge
mleft = myPage.MarginPreferences.MarginLeft
'uiterst rechts van het vierkant.
mright = mleft + 25
'mtop is de bovenmarge
mtop = myPage.MarginPreferences.MarginTop
'uiterst onder van het vierkant
mbottom = mtop + 5
Set myImg = myPage.Rectangles.Add
myImg.GeometricBounds = Array(mtop, mleft, mbottom, mright)
myFile = App.Path & "\LOGO\" & "GHW.tif"
myImg.Place myFile
myImg.Fit idProportionally
Call Footer(1)
End Sub
Private Sub Footer(pagina As Integer)
'Deze functie zal een footer maken op de meegegeven pagina.
Dim myIndesign As InDesign.Application
Dim myDocument As InDesign.Document
Dim myPage As InDesign.Page
Dim myText As InDesign.TextFrame
Dim myImg As InDesign.Rectangle
Dim myline As InDesign.Line
Set myIndesign = CreateObject("Indesign.Application.2.0")
Set myDocument = myIndesign.ActiveDocument
Dim myColors As InDesign.Colors
Set myColors = myDocument.Colors
myDocument.ViewPreferences.RulerOrigin = idPageOrigin
Set myPage = myDocument.Pages.Item(pagina)
pWidth = myDocument.DocumentPreferences.PageWidth
pHeight = myDocument.DocumentPreferences.PageHeight
mleft = myPage.MarginPreferences.MarginLeft
mbottom = pHeight - myPage.MarginPreferences.MarginBottom
mright = mleft + 20
mtop = mbottom - 4
Set myImg = myPage.Rectangles.Add
myImg.GeometricBounds = Array(mtop, mleft, mbottom, mright)
myFile = App.Path & "\LOGO\" & "AAG.tif"
myImg.Place myFile
myImg.Fit idProportionally
myImg.Fit idCenterContent
mright = pWidth - myPage.MarginPreferences.MarginRight
mleft = mright - 10
mbottom = pHeight - myPage.MarginPreferences.MarginBottom
mtop = mbottom - 4
Set myImg = myPage.Rectangles.Add
myImg.GeometricBounds = Array(mtop, mleft, mbottom, mright)
myFile = App.Path & "\LOGO\" & "AA.tif"
myImg.Place myFile
myImg.Fit idProportionally
myImg.Fit idCenterContent
mright = pWidth - myPage.MarginPreferences.MarginRight
mleft = myPage.MarginPreferences.MarginLeft
mbottom = pHeight - myPage.MarginPreferences.MarginBottom - 4
mtop = mbottom
Set myline = myPage.Lines.Add
myline.GeometricBounds = Array(mtop, mleft, mbottom, mright)
myline.StrokeColor = myColors.Item("AA")
myline.StrokeWeight = 2
End Sub
* ***************** end source code *****************************
I also have the same problem with the line.
the line is also only printed on the left page and never on right page.
Tank you for your time
Roel G
Technical Details
Message-ID:
<2ccf7c40.0@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webxReferences:
<2ccf7c40.-1@webx.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit X-Google-Thread: f939a,3663529df6bffd0d X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2004-01-21 06:37:49 PST From: Roel_G@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!sn-xit-08!supernews.com!38.144.126.70.MISMATCH!feed3.newsreader.com!newsreader.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: Re: [VB]Image on wrong page. Message-ID: <2ccf7c40.0@webx.la2eafNXanI> Date: Wed, 21 Jan 2004 06:22:25 -0800 References: <2ccf7c40.-1@webx.la2eafNXanI> Lines: 242 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit