static void Main(string[] args)
    {
        try {
            DocApi docraptor = new DocApi();
            docraptor.Configuration.Username = "******";

            Doc doc = new Doc(
                test: true,                                               // test documents are free but watermarked
                documentContent: "<html><body>Hello World</body></html>", // supply content directly
                // documentUrl: "http://docraptor.com/examples/invoice.html",  // or use a url
                name: "docraptor-csharp.pdf",                             // help you find a document later
                documentType: Doc.DocumentTypeEnum.Pdf                    // pdf or xls or xlsx
                // javascript: true,                                           // enable JavaScript processing
                // princeOptions: new PrinceOptions(
                //   media: "screen",                                          // use screen styles instead of print styles
                //   baseurl: "http://hello.com"                               // pretend URL when using document_content
                // )
                );

            DocStatus statusResponse = docraptor.CreateHostedDoc(doc);
            Console.WriteLine("Hosted Async Download URL: " + statusResponse.DownloadUrl);
        } catch (DocRaptor.Client.ApiException error) {
            Console.WriteLine(error);
        }
    }
Beispiel #2
0
    static void Main(string[] args)
    {
        DocApi docraptor = new DocApi();

        docraptor.Configuration.Username = "******";
        // docraptor.Configuration.Debug = true; // Not supported in Csharp

        Doc doc = new Doc(
            name: "csharp-hosted-sync.pdf",
            test: true,
            documentContent: "<html><body>Hello from C#</body></html>",
            documentType: Doc.DocumentTypeEnum.Pdf
            );

        DocStatus statusResponse = docraptor.CreateHostedDoc(doc);
        WebClient webClient      = new WebClient();

        webClient.DownloadFile(statusResponse.DownloadUrl, @"/tmp/the-file-name.pdf");


        string line = File.ReadLines("/tmp/the-file-name.pdf").First();

        if (!line.Contains("%PDF-1.5"))
        {
            Console.WriteLine("unexpected file header: " + line);
            Environment.Exit(1);
        }
    }