Subscribe to this thread
Home - General / All posts - Some code some may find useful - exporting all layouts, as well as adding elements
djmcbell10 post(s)
#14-Sep-18 06:34

I've just had to export a load of layouts (140+) into pdf. Originally it was export them, fine. I can just right-click and do that.

Then it was add a graticule. Bit of a pain but I can do that without much issue.

Then it was add the company logo. That one is a pain, or at least was at the time, as the map was slow as anything. So I wrote a script, taking liberally from other scripts on here (which I'm now having trouble finding). The only issue is that, at least in Manifold 8, you couldn't alter the x/y coordinates and size of the image (the company logo), so I had to create a separate graphic which was the logo placed in the right place on a transparent surface, which was the same size as the page, to get around Manifold sizing the image to the page. Bit of a pain, especially when some of the layouts are landscape and some portrait.

If anyone finds it useful, feel free to steal it (it's basically what I did).

Sub Main

 Set exporter = Document.NewExport("PDF")

 Set components = Application.ActiveDocument.ComponentSet

 exportPath = "C:\your\destination\path\"

 'allows you to set limits on the amount of files generated - useful for testing

 'CurrentCount - current amount produced, CountMe - limit

 CurrentCount = 0

 CountMe = 9999

 For i = 0 to components.Count-1

 Set theComponent = components(i)

 If theComponent.typeName = "Layout" Then

 if(CurrentCount < CountMe) Then

 'set the graticule - in this case we just wanted coordinates, and no grid

 with theComponent.EntrySet.Item(0)

 .Graticule = LayoutStateOff

 .Border = LayoutBorderCoordinatesGraticule

 .BorderRounding = -2

 end with

 'choose the correct logo image and apply it

 if(theComponent.EntrySet.Item(0).X>theComponent.EntrySet.Item(0).Y) then

 theComponent.EntrySet.AddComponent(components("Logo Landscape bg"))

 end if

 if(theComponent.EntrySet.Item(0).Y>theComponent.EntrySet.Item(0).X) then

 theComponent.EntrySet.AddComponent(components("Logo Portrait bg"))

 end if


 'export as pdf

 exporter.Export theComponent, exportPath & theComponent.Name + ".pdf", PromptNone

 'increase our count

 CurrentCount = CurrentCount + 1

 End If

 End If


 application.messagebox "Complete"

End Sub

Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.