Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (48 loc) · 1.63 KB
/
Copy pathProgram.cs
File metadata and controls
57 lines (48 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using GoogleCloudPrintApi;
using GoogleCloudPrintApi.Models;
using GoogleCloudPrintApi.Models.Application;
using GoogleCloudPrintApi.Models.Printer;
using Newtonsoft.Json;
using System.Threading.Tasks;
namespace GoogleCloudPrint.NET_Example
{
class Program
{
static async Task Main(string[] args)
{
var clientId = "#printClientId#";
var clientSecret = "#printClientSecret#";
var printerId = "#printer-id#";
var credPath = $"cerd.json";
var provider = new GoogleCloudPrintOAuth2Provider(clientId, clientSecret);
var jsonString = System.IO.File.ReadAllText(credPath);
Token token = JsonConvert.DeserializeObject<Token>(jsonString);
var client = new GoogleCloudPrintClient(provider, token);
client.OnTokenUpdated += (sender, e) =>
{
string json = JsonConvert.SerializeObject(e);
System.IO.File.WriteAllText(credPath, json);
};
var ticket = new CloudJobTicket
{
Print = new PrintTicketSection
{
Color = new ColorTicketItem { Type = Color.Type.STANDARD_MONOCHROME },
//Duplex = new DuplexTicketItem { Type = Duplex.Type.LONG_EDGE },
PageOrientation = new PageOrientationTicketItem { Type = PageOrientation.Type.LANDSCAPE },
Copies = new CopiesTicketItem { Copies = 1 }
}
};
// Create a request for file submission, you can either submit a url with SubmitFileLink class, or a local file with SubmitFileStream class
var request = new SubmitRequest
{
PrinterId = printerId,
Title = "Ebay-Printer",
Ticket = ticket,
Content = new SubmitFileLink("URL HERE")
};
// Submit request
var response = await client.SubmitJobAsync(request);
}
}
}