eDocBuilder API to Manage Templates

eDocBuilder has a web service API, called the templateMgr, that can be used to create and modify templates within your account. Please note that effectively utilizing this web service requires advanced programming skills.

An eDocBuilder subscriber has a master username (sometimes called email but it does not have to be a real email address) and password. Every templateMgr call must include these. Individual eDocBuilder users may have separate username and password, but they cannot be used with the API.


Every template has two GUIDs known as the docCode (sometimes docID) and docPassword. When creating a template for the first time, if you pass null then these will be generated and returned in the call; or if you specify your own, it will attempt using them.

90% of all calls are in set/get pairs: setTemplate/getTemplate, setAsset/sgetAssets, setFields/getFields, etc. The get call retrieves information, while the set call creates/updates/deletes information and returns what is left after the operation.

Three exceptions:

  • commitTemplate - prepares the template for final use (it builds some XML fields, saves preview images, etc.) 
  • dupeTemplate - create a copy of an existing template.
  • setTemplateEverything - the same as executing setTemplate, setFields, setAssets and setResponseSets all in one call.

A template must have at least one field. Historically fields were created by reading the Acrobat fields from the master PDF. With templateMgr, it's now possible to use plain PDFs without Acrobat forms, and to create the fields programattically with setFields. If, at the time of commitTemplate, there are no fields set up, commitTemplate will silently create one.

A template consists of:

  • a small set of data (libraryTemplate class)
  • an array of fields (array of eDocLibrary.edocFieldInfo class)
  • an array of assets (array of assetInfo class)
  • an array of response sets (array of eDocLibrary.responseSet class)
Sample VB.NET code to create a template:
 
 
  1. Public Sub TestSetTemplate()
  2.         Dim tpl = templateMgr
  3.         Dim userEmail As String = "(user email or id goes here)"
  4.         Dim userPassword As String = "(password goes here)"
  5.         Dim docCode As String
  6.         Dim docPassword As String
  7.  
  8.         Dim templateInfo = New Global.eDocEngine.libraryTemplate With { _
  9.             .clientType = 1, _
  10.             .docCategory = "Misc", _
  11.             .docDescription = "create template", _
  12.             .docHeight = 792, _
  13.             .docWidth = 612, _
  14.             .docPageCount = 1
  15.         }
  16.  
  17.         Dim result = tpl.setTemplate(userEmail, userPassword, Nothing, Nothing, templateInfo)
  18.  
  19.         docCode = result.docID.ToString()
  20.         docPassword = result.docPassword.ToString()      
  21.     End Sub
Minimal code for creating a template, while uploading assets and fields all in one operation:
 
 
  1. Sub doTest()
  2.         Dim x As ItemplateMgr = New templateMgr
  3.  
  4.         Dim tplInfo As New libraryTemplate With { _
  5.             .docName = "ross test " & Now.ToString("MMdd hh:mm") & " setTemplateEverything", _
  6.             .docDescription = "created " & Now.ToShortTimeString() & " using TemplateMgr.setTemplateEverything",
  7.             .docBleed = 0,
  8.             .clientType = 1,
  9.             .docCategory = "",
  10.             .isActive = True}
  11.  
  12.         Dim assets(5) As assetInfo
  13.         assets(0) = New assetInfo With {.assetName = "aleyantemployee.pdf", .assetType = assetInfo.eAssetType.masterPDF, .assetURL = "http://edocfiles/aleyantemployee.pdf", .delete = False}
  14.         assets(1) = New assetInfo With {.assetName = "Futura-Book.ttf", .assetType = assetInfo.eAssetType.fontfile, .assetURL = "http://edocfiles/Futura-Book.ttf", .delete = False}
  15.         assets(2) = New assetInfo With {.assetName = "MyriadPro-Regular.ttf", .assetType = assetInfo.eAssetType.fontfile, .assetURL = "http://edocfiles/MyriadPro-Regular.ttf", .delete = False}
  16.         assets(3) = New assetInfo With {.assetName = "snapshot.jpg", .assetType = assetInfo.eAssetType.graphicFile, .assetURL = "http://edocfiles/snapshot.jpg", .delete = False}
  17.         assets(4) = New assetInfo With {.assetName = "Navlogo.jpg", .assetType = assetInfo.eAssetType.graphicFile, .assetURL = "http://edocfiles/Navlogo.jpg", .delete = False}
  18.         assets(5) = New assetInfo With {.assetName = "Kwalu-logo.jpg", .assetType = assetInfo.eAssetType.graphicFile, .assetURL = "http://edocfiles/Kwalu-logo.jpg", .delete = False}
  19.     assets(6) = New assetInfo With {.assetName = "template.indd", .assetType = assetInfo.eAssetType.inDesignDocument, .assetURL = "http://edocfiles/template.indd", .delete = False}
  20.  
  21.         Dim fields(2) As eDocLibrary.eDocFieldInfo
  22.         fields(0) = New eDocLibrary.eDocFieldInfo With { _
  23.             .fieldName = "phFieldOne", _
  24.             .pdfRect = "0 0 144 144", _
  25.             .pageNumber = 1, _
  26.             .controlType = eDocLibrary.eDocFieldInfo.enumControlType.textArea, _
  27.             .setup_controlTypeDDValue = eDocLibrary.eDocFieldInfo.enumControlType.textArea.ToString(), _
  28.             .setup_radioDataSource = "user", _
  29.             .repeatType = eDocLibrary.eDocFieldInfo.enumRepeatField.none, _
  30.             .promptNumber = 1, _
  31.             .fieldEntryRequired = True, _
  32.             .promptText = "field one:", _
  33.             .toolTip = "Enter data for field one here. This appears at the bottom left of page 1 and is 2 inches square.", _
  34.             .maxLength = 5000, _
  35.             .defaultValue = "Fourscore and seven years ago ...", _
  36.             .fontName = "Futura Book", _
  37.             .fontSize = 12.5, _
  38.             .fontUnderline = True, _
  39.             .fontLeading = 2, _
  40.             .fontAlignment = eDocLibrary.eDocFieldInfo.enumTextAlignment.middleCenter, _
  41.             .fontColorC = 100, _
  42.             .fontColorM = 0, _
  43.             .fontColorY = 100, _
  44.             .fontColorK = 0, _
  45.             .fontForceFit = False, _
  46.             .preserveSpaces = True}
  47.         fields(1) = New eDocLibrary.eDocFieldInfo With { _
  48.             .fieldName = "phFieldOneOverflow", _
  49.             .pdfRect = "150 0 294 144", _
  50.             .pageNumber = 1, _
  51.             .controlType = eDocLibrary.eDocFieldInfo.enumControlType.textArea, _
  52.             .setup_controlTypeDDValue = eDocLibrary.eDocFieldInfo.enumControlType.textArea.ToString(), _
  53.             .setup_radioDataSource = "overflow", _
  54.             .fieldChainPrev = "phFieldOne", _
  55.             .fontName = "Futura Book", _
  56.             .fontSize = 10, _
  57.             .fontUnderline = False,
  58.             .fontLeading = 0, _
  59.             .fontAlignment = eDocLibrary.eDocFieldInfo.enumTextAlignment.middleCenter, _
  60.             .fontColorC = 100, _
  61.             .fontColorM = 0, _
  62.             .fontColorY = 100, _
  63.             .fontColorK = 0, _
  64.             .fontForceFit = False, _
  65.                         .preserveSpaces = True}
  66.  
  67.         x.setTemplateEverything("user email or id", "password", "", "", tplInfo, fields, assets, Nothing)
  68.  
  69.     End Sub

Note that file transfers are performed as downloads from your server (or some other publicly accessible URL).