The Content Service is responsible for document transformation. This page describes how to interact with the service through its RESTful API. You can also interact with the service through WCF via a C# rule.

Basic structure

You can create a call the Content service via an HTTP POST request. The URL template for this service is:

{server}/Content.WebService/ContentServiceRest.svc/executesync/{domain}?t={token}

Look at the JavaScript example below for how to build this dynamically.

You need to submit a JSON in the parameters with the request to give the service instructions. Below is an example of the structure of the JSON block.

{
	"type" : "Burn",
	"args" : [{
			"type" : "StorageContent",
			"args" : ["cms:///myDocument.tiff"]
		}
	]
}

Supported Commands

The JSON block you send in with the POST request can have the following "type". 

StorageContent

Retrieves the file content of the specified CMS location. The JSON needs to be like this:

{
	"type" : "StorageContent",
	"args" : ["cms:///myDocument.tiff"]
}

Input: The argument is the URI of the CMS file.

Output: file's content

Convert

Converts a document into a supported format. The JSON looks like this:

{
	"type" : "Convert",
	"args" : [
		{
			"type" : "StorageContent",
			"args" : ["cms:///myDocument.doc"]
		},
		"image/tiff"
	]
}

Input: The first argument is the target document and the second is the expected content type.

Output: The resulting file's content.

The following formats are supported:

FromTo
 TIFFJPGPNGBMPDOCDOCXXLSXLSXRTFTXTHTMLPDFDMS
TIFFYesYesYesYes       Yes 
JPGYesYesYesYes         
PNGYesYesYesYes         
BMPYesYesYesYes         
DOCYes   Yes      Yes 
DOCXYes    Yes     Yes 
XLSYes     Yes    Yes 
XLSXYes      Yes   Yes 
RTFYes       Yes  Yes 
TXTYes        Yes Yes 
HTMLYes         YesYes 
PDFYes          Yes 
DMSYes           Yes
Merge

Merges the specified files into one file and returns the content of the file. All the specified files must be of the same file type. The JSON looks like this:

{
	"type" : "Merge",
	"args" : [{
			"type" : "StorageContent",
			"args" : ["cms:///myDocument1.pdf"]
		}, {
			"type" : "StorageContent",
			"args" : ["cms:///myDocument2.pdf"]
		}, {
			"type" : "Convert",
			"args" : [{
					"type" : "StorageContent",
					"args" : ["cms:///myDocument3.doc"]
				},
				"application/pdf"
			]
		}
	]
}

Input: Each argument in this command is a file's content which you can get by specifying the StorageContent or another command that returns back a content of a file. The example above merges two files directly from CMS and one that is in DOC format that is going to get converted to PDF before it is merged.

Output: The resulting file's content.

The following formats can be merged:

TIFFJPGPNGBMPDOCDOCXXLSXLSXRTFTXTHTMLPDFDMS
Yes    Yes     Yes 
Extract

Extracts pages from a document and returns the resulting file content. The JSON looks like this:

{
	"type" : "Extract",
	"args" : [{
			"type" : "StorageContent",
			"args" : ["cms:///myDocument.tiff"]
		},
		"1|2|3"
	]
}

Input: The first command is the file content and the second command are the pages you want to extract. 

Output: The resulting file's content.

The following formats support pages to be extracted:

TIFFJPGPNGBMPDOCDOCXXLSXLSXRTFTXTHTMLPDFDMS
Yes          Yes 
Burn

Burn Atalasoft annotations into the input TIFF file. The annotations that were added to a TIFF using either the Web or Desktop Viewer are layered on top of the document and are removable. Executing this command burns the annotations onto the TIFF file and they become part of the image and irremovable. The JSON looks like this:

{
	"type" : "Burn",
	"args" : [
		{
			"type" : "StorageContent",
			"args" : ["cms:///myDocument.tiff"]
		}
	]
}

The following formats support burning:

TIFFJPGPNGBMPDOCDOCXXLSXLSXRTFTXTHTMLPDFDMS
Yes            
Save

Save the input file content in the CMS. The JSON looks like this:

{
	"type" : "Save",
	"args" : [{
			"type" : "Convert",
			"args" : [{
					"type" : "StorageContent",
					"args" : ["cms:///myDocument.docx"]
				},
				"image/tiff"
			]
		},
		"cms:///myConvertedDocument.tiff"]
}

The above example takes the converted file and saves it in the CMS with the name myConvertedDocument.tiff.

Input: The first argument is the target file content and the second is the CMS URI where you want the file content to be saved. 

Output: CMS URI of the new file.

Download

Text

OCR

Does OCR on the input file and returns the resulting text. The JSON looks like this:

{
	"type" : "OCR",
	"args" : [{
			"type" : "StorageContent",
			"args" : ["cms:///myDocument.tif"]
		},
		"text/plain"
	]
}

Input: The first argument is the target file content and the second is the output format.

Output: The resulting file's content.

The following formats support OCR:

TIFFJPGPNGBMPDOCDOCXXLSXLSXRTFTXTHTMLPDFDMS
Yes            
Generate

Generates a document . The JSON looks like this:

{
	"type" : "Generate",
	"args" : [{
			"type" : "StorageContent",
			"args" : ["cms:///myWelcomeLetter.docx"]
		}, {
			"firstName" : "John",
			"lastName" : "Smith"
		}
	]
}

Combining Commands

In many cases you can nest commands. One of the most useful command for nesting is Save. The example below converts a Word document into a PDF, merges it with two other PDFs, converts the resulting merged PDF into a TIFF and saves it in the CMS.

 

{
	"type" : "Save",
	"args" : [{
			"type" : "Convert",
			"args" : [{
					"type" : "Merge",
					"args" : [{
							"type" : "StorageContent",
							"args" : ["cms:///myDocument1.pdf"]
						}, {
							"type" : "StorageContent",
							"args" : ["cms:///myDocument2.pdf"]
						}, {
							"type" : "Convert",
							"args" : [{
									"type" : "StorageContent",
									"args" : ["cms:///myDocument3.doc"]
								},
								"application/pdf"
							]
						}
					]
				},
				"image/tiff"
			]
		},
		"cms:///myMergedDocument.tiff"]
}

For cases when the input of the command requires file content, then you can either use StorageContent to reference a file in the CMS or another command's result whose output it a file's content. A few more popular JSON combinations:

This example converts a Word document to a TIFF and merges it with another TIFF:

{
	"type" : "Merge",
	"args" : [{
			"type" : "Convert",
			"args" : [{
					"type" : "StorageContent",
					"args" : ["cms:///myDocument.doc"]
				}, "image/tiff"]
		}, {
			"type" : "StorageContent",
			"args" : ["cms:///myOtherDocument.tiff"]
		}
	]
}

This example converts a Word document to a TIFF, extracts pages 1,3 and 5 into one TIFF, and then converts that TIFF into a PDF:

{
	"type" : "Convert",
	"args" : [{
			"type" : "Extract",
			"args" : [{
					"type" : "Convert",
					"args" : [{
							"type" : "StorageContent",
							"args" : ["cms:///myDocument.docx"]
						}, "image/tiff"]
				}, "1|3|5"]
		}, "application/pdf"]
}

Using this service

The most common way to use this service is from a page by making an AJAX request. You can also call this service from a rule using WCF. 

JavaScript Example

Text

CURL Example
d:\bak\curl\curl.exe
-d "{'type': 'Save', 'args': [  
{'type': 'Convert', 'args': [ { 'type': 'StorageContent', 'args':
['cms:///myDocument.docx'] }, 'image/tiff' ]   },
'cms:///docxToTiff.tif' ]}" https://my.appbase.com/Content.WebService/ContentServiceRest.svc/executesync/MySolution_Production.myTenant?t=DfHAKrztreXmi%2bc7R0vaCzJgS0Wrzi6bzO7SSvLT8YBfE4fRJQyMgQUu1b9StKxt
WCF Example

Text

  • No labels