JSONDatabase.EmbeddedData Property

ClosedDescription

Sets and returns the raw JSON text.

ClosedSyntax

JSONDatabase.EmbeddedData = rawJSONText

Where rawJSONText is a string containing the raw JSON text representing the JSON database.

ClosedRequirements

Version

BarTender 11.2 or higher

Edition

Automation, Enterprise

ClosedRemarks

The JSONDatabase.EmbeddedData property is an alternative to the JSONDatabase.FileName property. The two properties are mutually exclusive and setting one will clear the other. You cannot set a file using the FileName property and then read back its contents using the EmbeddedData property.

ClosedVB.NET Example

'Connection to already running instance of BarTender

Dim btApp As BarTender.Application = GetObject(, "BarTender.Application")

'Alternatively uncomment the following to create a new instance instead.

'Dim btApp As BarTender.Application = CreateObject("BarTender.Application")

'Open a BarTender document

Dim btFormat As BarTender.Format = btApp.Formats.Open("d:\tests\airplanesJson.btw", False, "")

'Retrieve the first database (We're assuming it's a JSON database connection)

Dim btDb As BarTender.Database = btFormat.Databases.GetDatabase(1)

Dim btdbJson As BarTender.JSONDatabase = btDb.JSONDatabase

'Substitute alternative JSON database data

btdbJson.EmbeddedData =

"{

""database"":""Airplanes"",

""Version"":3.0,

""Airplanes"":

[

{""Model"":""172"",""Manufacturer"":""Cessna"", ""Years"":[1956, 2019]},

{""Model"":""StaggerWing"",""Manufacturer"":""Beechcraft"", ""Years"":[1932, 1949]},

{""Model"":""King Air"",""Manufacturer"":""Beechcraft"", ""Years"":[1964, 2019]},

{""Model"":""180"",""Manufacturer"":""Cessna"",""Years"":[1953, 1981]}

]

}"

'Print labels using this database

Dim btMessages As BarTender.Messages = Nothing

Dim btPrintRtn As BarTender.BtPrintResult = btFormat.Print("My Print Job", WaitForSpoolJobToComplete:=True, TimeoutMs:=-1, btMessages)

'Check to see if there are any errors

Dim msg As BarTender.Message

If (btPrintRtn <> BarTender.BtPrintResult.btSuccess) Then

For Each msg In btMessages

Console.WriteLine(msg.Message)

Next msg

End If

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)

ClosedC# Example

BarTender.Application btApp;

BarTender.Format btFormat;

BarTender.Database btDb;

// Create a new instance of BarTender

btApp = new BarTender.Application();

// Set the BarTender application visible

btApp.Visible = true;

// Open a BarTender document

btFormat = btApp.Formats.Open("c:\\tests\\airplanesJson.btw", false, "");

// Send raw JSON text directly to the provider and print

BarTender.Database btDb = btFormat.Databases.GetDatabase(1);

BarTender.JSONDatabase btJson btJson = btDb.JSONDatabase;

btJson.EmbeddedData =

"{" +

"\"database\":\"Airplanes\"," +

"\"Version\":3.0," +

"\"Airplanes\":" +

"[" +

"{\"Model\":\"172\",\"Manufacturer\":\"Cessna\", \"Years\":[1956, 2019]}," +

"{\"Model\":\"StaggerWing\",\"Manufacturer\":\"Beechcraft\", \"Years\":[1932, 1949]}," +

"{\"Model\":\"King Air\",\"Manufacturer\":\"Beechcraft\", \"Years\":[1964, 2019]}," +

"{\"Model\":\"180\",\"Manufacturer\":\"Cessna\",\"Years\":[1953, 1981]}" +

"]" +

"}";

BarTender.Messages messages;

btFormat.Print("NewJob", false, -1, out messages);

// End the BarTender process

btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);

Related Topics