Code Monkey home page Code Monkey logo

docraptor-csharp's People

Contributors

davidronk avatar esquivalient avatar jamespaden avatar jason-o-matic avatar jqr avatar mediocretes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

docraptor-csharp's Issues

Readme example requires some tweaks

The README example does not work gracefully in an interactive session. I propose two small changes:

Change the configuration line to

Configuration.Default.Username = "YOUR_API_KEY_HERE"; // this key works for test documents

Add File.WriteAllBytes("test.pdf", create_response); after the call to CreateDoc, to demonstrate an actual PDF being written to an actual file.

documentContent is required, but it shouldn't be

I have to include a blank documentContent line, or an error is thrown :( it should be optional if I use documentUrl

using DocRaptor.Client;
using DocRaptor.Model;
using DocRaptor.Api;
using System;
using System.IO;

class Example
{
    static void Main(string[] args)
    {
        DocApi docraptor = new DocApi();
        // this key works in test mode!
        docraptor.Configuration.Username = "YOUR_API_KEY_HERE";

        try
        {
            Doc doc = new Doc(
                name: "invoice",
                test: true, // test documents are free but watermarked
                documentType: Doc.DocumentTypeEnum.Pdf,
                documentContent: "", // the .NET agent requires documentContent be set
                documentUrl: "https://docraptor.com/samples/invoice.html" 
                // javascript: false, 
            );

            byte[] pdf = docraptor.CreateDoc(doc);
            File.WriteAllBytes("invoice.pdf", pdf);
            Console.WriteLine("Successfully created invoice.pdf!");
        } catch (DocRaptor.Client.ApiException error) {
            Console.Write(error.ErrorContent);
        }
    }
}

Out of date

Any chance this will be updated to dotnet core?

Readme example does not work

Docraptor.Client.Configuration.Username cannot be accessed directly.

Also, what if we changed the example to be a repl example rather than a compile example? It does not match the most common use case, but it is faster to get up and running and play with.

C# Model.Doc Pipeline Property

In version 1.1.0 we are unable to set the Pipeline property in the Model.Doc class. Doesn't appear to be an option when creating a new Model.Doc class.

public Doc(string Name = null, DocumentTypeEnum? DocumentType = default(DocumentTypeEnum?), string DocumentContent = null, string DocumentUrl = null, bool? Test = default(bool?), StrictEnum? Strict = default(StrictEnum?), bool? IgnoreResourceErrors = default(bool?), string Tag = null, bool? Help = default(bool?), bool? Javascript = default(bool?), string Referrer = null, string CallbackUrl = null, PrinceOptions PrinceOptions = null);

ignore_console_messages is included on every request

ignore_console_messages, which defaults to true as of Pipeline 7, is included on every C# agent request as false. This causes console messages to unexpectedly fail documents. My expectation would be that ignore_console_messages isn't included in the request unless explicitly defined.

As a workaround, ignore_console_messages can simply be set to true.

Why is the project depending on a version of RestSharp.dll without a publicKeyToken?

When docraptor is the only dependency in a project that uses RestSharp every works fine.

However if you happen have another dependency that also depends on RestSharp or if you wan to depend on a different version of Resharp a file load exception is thrown:

Inner Exception: FileLoadException

Inner Exception Message: Could not load file or assembly 'RestSharp, Version=105.2.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)


StackTrace:

   at DocRaptor.Client.Configuration.set_BasePath(String value)
   at DocRaptor.Client.Configuration..ctor()
   at DocRaptor.Client.Configuration..cctor()

From looking at DocRaptor.dll in dot peek I can see that the .DLL has a reference to RestSharp, Version=105.2.3, Culture=neutral, PublicKeyToken=null.

The problem is the PublicKeyToken=null part.

It should be PublicKeyToken=598062e77f915f75.

Build script version mismatch

Due to a version mismatch on RestSharp between the package config file and the build script, a fresh copy of the repo will fail to build properly.

Add binary corruption test

It's easy for generated clients to return accidentally utf8 encoded data, which ends up corrupting PDF/XLS/XLSX files. Let's add a test to ensure this can never happen.

Any objections to modernising the project files?

I'd be happy to work on a pull request that would:

  • Upgrade the .csproj file to the new ".NET SDK format"
  • The point above would simplify packaging the project for nuget
  • Use the dotnet cli instead of mono
  • target .net standard 2.0
  • While at it use the latest version of RestSharp, Newtonsoft JSON and JsonSubTypes

Any thoughts or objections?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.