Help with scripting text layer

PhilM
Mitglied
Posts: 187
Joined: Thu 28 May 2015 18:00
Location: Belgium

Help with scripting text layer

Post by PhilM »

I would like to add tabulations in the paragraphs generated by the following script :
Note : The text is contained in the "txt" variable

Set layer = doc.ActiveLayer

Set fontDict = CreateObject("PhotoLine.Dictionary")
fontDict.Add "FamilyName", "Arial", "Size", 72

Set paragraphDict = CreateObject("PhotoLine.Dictionary")
paragraphDict.Add "Alignment", 0

Set textLayer = CreateObject("PhotoLine.Text")
textLayer.Text = txt
textLayer.Origin = Array(500, 500)
textLayer.Size = Array(4000, 2500)
textLayer.SetAttribute range, "Font", fontDict
textLayer.SetAttribute range, "Paragraph", paragraphDict
textLayer.SetAttribute range, "Color", Array(128, 0, 0)

layer.Parent.Insert textLayer, layer

How should I declare two left aligned tabs ?

Thanks

Phil
User avatar
Gerhard Huber
Entwickler
Entwickler
Posts: 4179
Joined: Mon 18 Nov 2002 15:30
Location: Bad Gögging

Re: Help with scripting text layer

Post by Gerhard Huber »

The following script adds two left aligned tabs at 100 and 200.

Code: Select all

Dim pl
Dim doc

Set pl = CreateObject("PhotoLine.Application")
Set doc = pl.ActiveDocument
If (Not doc is Nothing) Then
	Dim	range(1)

	range(0) = 0
	range(1) = 1
	Set layer = doc.ActiveLayer

	Set fontDict = CreateObject("PhotoLine.Dictionary")
	fontDict.Add "FamilyName", "Arial", "Size", 72

	Set paragraphDict = CreateObject("PhotoLine.Dictionary")
	paragraphDict.Add "Alignment", 0
'Create a basic Tab with just a position. Note: The position
'has to be a float.
'Other possible keys are "Type", ... (see ScriptingVBScript.pdf)
	Set tab1 = CreateObject("PhotoLine.Dictionary")
	tab1.Add "Position", 100.0
	Set tab2 = CreateObject("PhotoLine.Dictionary")
	tab2.Add "Position", 200.0
	paragraphDict.Add "Tabs", Array(tab1, tab2)

	Set textLayer = CreateObject("PhotoLine.Text")
	textLayer.Text = "A"
	textLayer.Origin = Array(500, 500)
	textLayer.Size = Array(4000, 2500)
	textLayer.SetAttribute range, "Font", fontDict
	textLayer.SetAttribute range, "Paragraph", paragraphDict
	textLayer.SetAttribute range, "Color", Array(128, 0, 0)

	layer.Parent.Insert textLayer, layer

End If
Please note, that you have to move the text cursor once to really see the tabs.
PhilM
Mitglied
Posts: 187
Joined: Thu 28 May 2015 18:00
Location: Belgium

Re: Help with scripting text layer

Post by PhilM »

Thanks a lot Gerhard

Phil