docraptor / docraptor-csharp Goto Github PK
View Code? Open in Web Editor NEWA native C# client for the DocRaptor document generation service.
License: Other
A native C# client for the DocRaptor document generation service.
License: Other
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.
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);
}
}
}
Any chance this will be updated to dotnet core?
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.
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
, 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
.
Without implementing strong naming (https://msdn.microsoft.com/en-us/library/xwb8f617%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396) we're requiring users to sign the assemblies themselves, creating an inconvenience, as reported by.
The package not working in .NET Standard.
Do you plan to support it ?
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
.
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.
It looks like DLLs are not included in the NuGet package, they should be.
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.
I'd be happy to work on a pull request that would:
dotnet
cli instead of mono.net standard 2.0
Any thoughts or objections?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.