Document
The Document class provides some helper/factory methods for opening a document from file or stream and obtaining the correct ICpDocument class.
NameSpace: StarMicronics.CloudPrnt
Syntax
public static class Document
Methods
Convert(Byte[], String, Stream, String, ConversionOptions)
Declaration
public static void Convert(byte[] inputBuffer, string inputType, Stream outputStream, string outputType, ConversionOptions options)
Parameters
Type |
ame |
Description |
---|---|---|
System.Byte[] |
inputBuffer |
Input data buffer. |
System.String |
inputType |
Type of data to be loaded from the input stream, specified as an IANA/MIME style media type. |
System.IO.Stream |
outputStream |
Stream to write the converted output data. |
System.String |
outputType |
Format of the output data, specified as an IANA/MIME style media type. |
options |
Conversion options to specify conversion parameters and output results. |
Convert(Stream, String, Stream, String, ConversionOptions)
Declaration
public static void Convert(Stream inputStream, string inputType, Stream outputStream, string outputType, ConversionOptions options)
Parameters
Type |
ame |
Description |
---|---|---|
System.IO.Stream |
inputStream |
Input data stream. |
System.String |
inputType |
Type of data to be loaded from the input stream, specified as an IANA/MIME style media type. |
System.IO.Stream |
outputStream |
Stream to write the converted output data. |
System.String |
outputType |
Format of the output data, specified as an IANA/MIME style media type. |
options |
Conversion options to specify conversion parameters and output results. |
ConvertFile(String, Stream, String, ConversionOptions)
Declaration
public static void ConvertFile(string fileName, Stream outputStream, string outputType, ConversionOptions options)
Parameters
Type |
ame |
Description |
---|---|---|
System.String |
fileName |
Input file name. |
System.IO.Stream |
outputStream |
Stream to write the converted output data. |
System.String |
outputType |
Format of the output data, specified as an IANA/MIME style media type. |
options |
Conversion options to specify conversion parameters and output results. |
ConvertFile(String, String, Stream, String, ConversionOptions)
Declaration
public static void ConvertFile(string fileName, string inputType, Stream outputStream, string outputType, ConversionOptions options)
Parameters
Type |
ame |
Description |
---|---|---|
System.String |
fileName |
Input file name. |
System.String |
inputType |
Type of data to be loaded from the input stream, specified as an IANA/MIME style media type. |
System.IO.Stream |
outputStream |
Stream to write the converted output data. |
System.String |
outputType |
Format of the output data, specified as an IANA/MIME style media type. |
options |
Conversion options to specify conversion parameters and output results. |
GetDocument(Byte[], String)
Supported media types are:
Media Type String |
File Format |
---|---|
image/bmp |
BMP compatible image data. Will cause a ImageDoc to be returned. |
image/png |
PNG compatible image data. Will cause a ImageDoc to be returned. |
image/jpeg |
Jpeg compatible image data. Will cause a ImageDoc to be returned. |
image/gif |
Gif compatible image data. Will cause a ImageDoc to be returned. |
text/plain |
Plain UTF8/Ascii text data. Will cause a TextDoc to be returned. |
text/vnd.star.markup |
UTF8 encoded text data containing Star Document Markup commands. Will cause a MarkupDoc to be returned. |
Input will be from the inputData read posiion until the end of the decodable input data (where that can be determined), or until the end of the Stream.
Declaration
public static ICpDocument GetDocument(byte[] inputData, string mediaType)
Parameters
Type |
ame |
Description |
---|---|---|
System.Byte[] |
inputData |
Data to be decoded into an ICpDocument. |
System.String |
mediaType |
Format of the input file as an IANA/MIME style media type. |
Returns
Type |
Description |
---|---|
An object implementing ICpDocument, which can be used to prepare the input file for printing via CloudPRNT, including conversion as needed. |
StringBuilder job = new StringBuilder();
job.Append("Hello World!\n");
job.Append("[barcode: type code39; data 12345; height 10mm]\n");
job.Append("[cut]");
byte[] data = Encoding.UTF8.GetBytes(job.ToString());
ICpDocument doc = Document.GetDocument(data, "text/vnd.star.markup");
GetDocument(Stream, String)
Supported media types are:
Media Type String |
File Format |
---|---|
image/bmp |
BMP compatible image data. Will cause a ImageDoc to be returned. |
image/png |
PNG compatible image data. Will cause a ImageDoc to be returned. |
image/jpeg |
Jpeg compatible image data. Will cause a ImageDoc to be returned. |
image/gif |
Gif compatible image data. Will cause a ImageDoc to be returned. |
text/plain |
Plain UTF8/Ascii text data. Will cause a TextDoc to be returned. |
text/vnd.star.markup |
UTF8 encoded text data containing Star Document Markup commands. Will cause a MarkupDoc to be returned. |
Input will be from the inputStream read posiion until the end of the decodable input data (where that can be determined), or until the end of the Stream.
Declaration
public static ICpDocument GetDocument(Stream inputStream, string mediaType)
Parameters
Type |
ame |
Description |
---|---|---|
System.IO.Stream |
inputStream |
Readable stream. |
System.String |
mediaType |
Format of the input file as an IANA/MIME style media type. |
Returns
Type |
Description |
---|---|
An object implementing ICpDocument, which can be used to prepare the input file for printing via CloudPRNT, including conversion as needed. |
GetDocumentFromFile(String)
Recognised filename extensions are:
Media Type String |
File Format |
---|---|
.bmp |
A BMP compatible image file. Will cause a ImageDoc to be returned. |
.png |
A PNG compatible image file. Will cause a ImageDoc to be returned. |
.jpg |
A Jpeg compatible image file. Will cause a ImageDoc to be returned. |
.jpeg |
A Jpeg compatible image file. Will cause a ImageDoc to be returned. |
.gif |
A Gif compatible image file. Will cause a ImageDoc to be returned. |
.txt |
A plain text data file, with UTF8 encoding. Will cause a TextDoc to be returned. |
.stm |
A UTF8 encoded text file containing Star Document Markup commands. Will cause a MarkupDoc to be returned. |
Input will be from the inputStream read posiion until the end of the decodable input data (where that can be determined), or until the end of the Stream.
Declaration
public static ICpDocument GetDocumentFromFile(string filename)
Parameters
Type |
ame |
Description |
---|---|---|
System.String |
filename |
有効な拡張子付きの入力ファイル名 |
Returns
Type |
Description |
---|---|
An object implementing ICpDocument, which can be used to prepare the input file for printing via CloudPRNT, including conversion as needed. |
ICpDocument doc = Document.GetDocumentFromFile("source.jpg");
GetDocumentFromFile(String, String)
Supported media types are:
Media Type String |
File Format |
---|---|
.bmp |
A BMP compatible image file. Will cause a ImageDoc to be returned. |
.png |
A PNG compatible image file. Will cause a ImageDoc to be returned. |
.jpg |
A Jpeg compatible image file. Will cause a ImageDoc to be returned. |
.jpeg |
A Jpeg compatible image file. Will cause a ImageDoc to be returned. |
.gif |
A Gif compatible image file. Will cause a ImageDoc to be returned. |
.txt |
A plain text data file, with UTF8 encoding. Will cause a TextDoc to be returned. |
.stm |
A UTF8 encoded text file containing Star Document Markup commands. Will cause a MarkupDoc to be returned. |
Input will be from the inputStream read posiion until the end of the decodable input data (where that can be determined), or until the end of the Stream.
Declaration
public static ICpDocument GetDocumentFromFile(string filename, string mediaType)
Parameters
Type |
ame |
Description |
---|---|---|
System.String |
filename |
Input file name. |
System.String |
mediaType |
Format of the input file as an IANA/MIME style media type. |
Returns
Type |
Description |
---|---|
An object implementing ICpDocument, which can be used to prepare the input file for printing via CloudPRNT, including conversion as needed. |
ICpDocument doc = Document.GetDocumentFromFile("source.jpg");
GetOutputTypesFromFileName(String)
Declaration
public static string[] GetOutputTypesFromFileName(string fileName)
Parameters
Type |
ame |
Description |
---|---|---|
System.String |
fileName |
Input file name. |
Returns
Type |
Description |
---|---|
System.String[] |
A list of output media formats as IANA/MIME media types. |
CpMessage.PollResponse response = new CpMessage.PollResponse();
response.jobReady = true;
response.mediaTypes = new List<string>();
response.mediaTypes.AddRange(Document.GetOutputTypesFromFieName("test.png"));
GetOutputTypesFromType(String)
Declaration
public static string[] GetOutputTypesFromType(string sourceMediaType)
Parameters
Type |
ame |
Description |
---|---|---|
System.String |
sourceMediaType |
The source media type in IANA/MIME form. |
Returns
Type |
Description |
---|---|
System.String[] |
A list of output media formats as IANA/MIME media types. |
CpMessage.PollResponse response = new CpMessage.PollResponse();
response.jobReady = true;
response.mediaTypes = new List<string>();
response.mediaTypes.AddRange(Document.GetOutputTypesFromType("text/vnd.star.markup"));