Help with scripting text layer

PhilM
Mitglied
Beiträge: 171
Registriert: Do 28 Mai 2015 18:00
Wohnort: Belgium

Help with scripting text layer

Beitrag von 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
Benutzeravatar
Gerhard Huber
Entwickler
Entwickler
Beiträge: 4143
Registriert: Mo 18 Nov 2002 15:30
Wohnort: Bad Gögging

Re: Help with scripting text layer

Beitrag von Gerhard Huber »

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

Code: Alles auswählen

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
Beiträge: 171
Registriert: Do 28 Mai 2015 18:00
Wohnort: Belgium

Re: Help with scripting text layer

Beitrag von PhilM »

Thanks a lot Gerhard

Phil