Seite 1 von 1

Help with scripting text layer

Verfasst: Mo 14 Feb 2022 19:31
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

Re: Help with scripting text layer

Verfasst: Di 15 Feb 2022 11:36
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.

Re: Help with scripting text layer

Verfasst: Di 15 Feb 2022 17:54
von PhilM
Thanks a lot Gerhard

Phil