GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - lohriialo/indesign-server-python: To demonstrate how to call InDesign Server SOAP from a Python web app. Use cases of InDesign Server are, generating PDF, SVG, JPEG, EPS, XML etc

BranchesTags
Open more actions menu

Latest commit

 

History

27 Commits
27 Commits

Folders and files

NameName
Last commit message
Last commit date
api_reference
api_reference
 
 
images
images
 
 
interop assemblies
interop assemblies
 
 
templates
templates
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
app.py
app.py
 
 
brochure.pdf
brochure.pdf
 
 
export_pdf.jsx
export_pdf.jsx
 
 
template.indt
template.indt
 
 

Repository files navigation

What is Adobe InDesign Server?

Adobe InDesign Server is a scalable engine that let you programmatically create automated documents where the data is pulled from a variety of databases like a CMS/DAM etc. Use cases of InDesign Server are, generating documents to PDF, SVG, JPEG, EPS, XML etc. InDesign Server is used in a variety of content management workflows, print & publishing solutions.

InDesign Server with Python

In this example, we'll demonstrate how you can use InDesign Server to publish with the data being pulled in from a Firebase realtime database.

Architecture

Getting Started

Adobe InDesign Server is required to run this tutorial. InDesign Server has a 90 day trial period, which should be enough to run a POC against your development environment.

Install InDesign Server

  • Download here

Start InDesign Server

  • indesignserver -port 12345

For more details, refer InDesign Server getting started guide at <Install Dir>\Documentation\English\Intro to InDesign CC Server 2019.pdf

Setup

  • pip install flask
  • pip install zeep

Example

# Path to JSX script to do the export
exportScriptPath = "export_pdf.jsx"

# soap client = IDS host client running on a soap port
client = Client('http://localhost:12345?wsdl')

# Create SOAP call params object, based on IDS wsdl
# For details go to http://localhost:12345?wsdl
RunScriptParameters = client.get_type('ns0:RunScriptParameters')
IDSP_ScriptArg = client.get_type('ns0:IDSP-ScriptArg')

# Get editorial contents from database
# this example returns a dictionary{} of editorial data
editorialContents = {'arg1': 'Electric Cars',
		 'arg2': 'An electric car is an automobile that is propelled by one or more electric motors, using energy stored in rechargeable batteries.',
		 'arg3': 'The first practical electric cars were produced in the 1880s'}

# pass the data to RunScript so you can access them from your .jsx file like so: app.scriptArgs.getValue("frontTitle");
params = RunScriptParameters("", "javascript", exportScriptPath, [IDSP_ScriptArg(key, value) for key, value in editorialContents.items()])

result = client.service.RunScript(params)

export_pdf.jsx

function ExportAsPDF(myFile){  
    try{
       	app.documents.item(0).exportFile(ExportFormat.pdfType, myFile, app.pdfExportPresets.item("[High Quality Print]"));
    }catch(e){
    	alert(e);
    };  
}
function LoadDataIntoTemplate(doc){
	// using script label to place data into placeholders
	for (var idx = 0; idx < doc.allPageItems.length; idx++)
	{
		var pageItem = doc.allPageItems[idx];
		// Editorial contents
		if (pageItem.constructor.name == "TextFrame" && pageItem.label == "placeholder1")
		{
		  pageItem.contents = app.scriptArgs.getValue("arg1");
		}
		if (pageItem.constructor.name == "TextFrame" && pageItem.label == "placeholder2")
		{
		  pageItem.contents = app.scriptArgs.getValue("arg2");
		}
		if (pageItem.constructor.name == "TextFrame" && pageItem.label == "placeholder3")
		{
		  pageItem.contents = app.scriptArgs.getValue("arg3");
		}
	}
}
function main(){
	var myTemplateFile = new File("/c/ServerFiles/template.indt");
	var myPDFfile = new File("/c/ServerFiles/brochure.pdf");
	var doc = app.open(myTemplateFile);
	// get scriptArgs and update
	LoadDataIntoTemplate(doc);
	// Export as PDF
	ExportAsPDF(myPDFfile);
	doc.close();
	alert("PDF Exported");
}
main();

Before

After

postman/soapui soap request example

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://ns.adobe.com/InDesign/soap/">
<soapenv:Body>
    <soap:RunScript>
        <runScriptParameters>
            <scriptLanguage>javascript</scriptLanguage>
            <scriptFile>C:\Temp\OpenClose.jsx</scriptFile>
            <scriptArgs>
            <name>myParameter</name>
            <value>305</value>
            </scriptArgs>
        </runScriptParameters>
    </soap:RunScript>
</soapenv:Body>
</soapenv:Envelope>

How to inspect scripting object properties?

There's not a straight forward way, you need to read the documentation to understand what properties/attributes are available for a scripting object, or possibly a COM browser. For example, I've extracted the Python scripting object reference for InDesign Server CC 2018 at api_reference

InDesign Server Resources

  • InDesign Server Developer Forum
  • InDesign Scripting Forum

About

To demonstrate how to call InDesign Server SOAP from a Python web app. Use cases of InDesign Server are, generating PDF, SVG, JPEG, EPS, XML etc

Topics

adobeadobe-indesignindesignindesign-documentindesign-pluginindesign-projectindesign-scriptspython-scriptscriptingscripting-languagescripting-tutorialserver

Resources

Readme
Activity

Stars

23 stars

Watchers

2 watching

Forks

1 fork
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.