DinkToPdf icon indicating copy to clipboard operation
DinkToPdf copied to clipboard

NuGet pack native libs, VS2017 project format

Open ajryan opened this issue 6 years ago • 18 comments

ajryan avatar Dec 28 '17 19:12 ajryan

Are you guys going to merge this and make a release or is this still a work in progress?

Harha avatar Feb 16 '18 13:02 Harha

Hello, would be possible to move with this? I'm using DinkToPdf in dockerized app so I have to download native libs using wget during build of the container... which works but it would be far more elegant if nuget package could handle this itself.

Looks like more people are waiting for this so if you need some help just let us know ;)

dorny avatar Apr 05 '18 06:04 dorny

Guys, any plans on actually merging this PR? I think you'll simplify your lib a lot

ovovchak avatar May 19 '18 21:05 ovovchak

Hey @ajryan , sorry to bother, but apparently this PR is approved. Can you merge it? Or is just the owner of the repo who can merge?

Cheers

rafamerlin avatar Jun 13 '18 12:06 rafamerlin

Hi @Merurino I wish I could! But I don't maintain this repo, just submitted the PR.

At this point I'm thinking about forking...

aidanjryan avatar Jun 13 '18 12:06 aidanjryan

This really needs merging, building and making its way into the NuGet repo

bill-richards avatar Nov 01 '18 14:11 bill-richards

+1 I agree we've been having lots of issues getting the dll's to load and adding custom assembly is not ideal if it can be managed through nuget.

LiamDotPro avatar Nov 01 '18 15:11 LiamDotPro

Does this commit fix the path issues in docker, any news on this being merged if so?

kgrosvenor avatar Nov 20 '18 16:11 kgrosvenor

Does this commit fix the path issues in docker, any news on this being merged if so?

Not sure what you mean by "path issues" - what's the symptom?

aidanjryan avatar Nov 20 '18 16:11 aidanjryan

The issue is (I think) that when running inside a docker container, invoking the PDF conversion on html content, images and stylesheets are not rendered, and rather one has to make a GET request to a service which will return the rendered html page instead

I spent a bit of time fighting this issue but in the end we just stood up a service with a POST endpoint for picking up the request for a PDF which either cached the input data locally, temporarily (not the end solution), or converted the input data to a URL encoded string to pass as a query param in a GET call to the service which applied the data to dynamic html (Razor template) and returned a properly rendered HTML page, which was then passed in as the HTML to the PDF generator -I so hope that makes sense.

// End user endpoint
[HttpPost("{templateName}")]
public IActionResult GeneratePdfDoc(string templateName, [FromBody]JObject json)
{
   var url =$"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/create-document/{templateName}/{UrlEncoder.Create().Encode(json.ToString())}";
    var output = _pdfConverter.Convert(new HtmlToPdfDocument()
   {
            GlobalSettings =
            {
               ColorMode = ColorMode.Color,
               Orientation = Orientation.Portrait,
               PaperSize = PaperKind.A4
             },

            Objects = { new ObjectSettings {Page = url} }
    });
    return new FileStreamResult(new MemoryStream(output), System.Net.Mime.MediaTypeNames.Application.Pdf);
}
 // Endpoint for applying a template to data and rendering Html
 [HttpGet("{templateName}/{jsonString}")]
      public async Task<IActionResult> ApplyTemplateToUrlEncodedJsonData(string templateName, string jsonString)
      {
         return await Task.Factory.StartNew(() => 
         {
            var json = JsonConvert.DeserializeObject<JObject>(WebUtility.UrlDecode(jsonString));
            var dictionary = _jsonConverter.GetDictionaryFromJson(json);
            var model = _modelFatory.CreateModelFromDictionary(dictionary);
            var viewToLoad = $"~/Views/Templates/{templateName}.cshtml";
            var result = View(viewToLoad, model);
            return result;
         });
      }

bill-richards avatar Nov 20 '18 22:11 bill-richards

Does this commit fix the path issues in docker, any news on this being merged if so?

Not sure what you mean by "path issues" - what's the symptom?

In the end i just has to update my dockerfile with some dependencies to be able to run the included file for linux

kgrosvenor avatar Nov 22 '18 21:11 kgrosvenor

@rdvojmoc Any update?

ssougnez avatar Jan 18 '19 22:01 ssougnez

@ajryan @rdvojmoc it would be great with more people that have write access, otherwise we have been thinking about creating a new nuget package with these issues solved, since we are also using dinktopdf. It would be better to continue with the original package though.

JimWolff avatar Mar 08 '19 20:03 JimWolff

I think it's time to fork guys. plus we can give it a better name that will have a higher "Dev manager acceptance factor"

On Fri, Mar 8, 2019, 3:34 PM Jim Wolff [email protected] wrote:

@ajryan https://github.com/ajryan @rdvojmoc https://github.com/rdvojmoc it would be great with more people that have write access, otherwise we have been thinking about creating a new nuget package with these issues solved, since we are also using dinktopdf. It would be better to continue with the original package though.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/rdvojmoc/DinkToPdf/pull/18#issuecomment-471067455, or mute the thread https://github.com/notifications/unsubscribe-auth/AAsJ2pBj5vdutm7YToXmFAt3LVmhHNakks5vUslDgaJpZM4ROkqR .

ajryan avatar Mar 09 '19 21:03 ajryan

@ajryan If it's useful for anyone, I published a nuget package of my last PR https://github.com/rdvojmoc/DinkToPdf/pull/72 including your updates, a bugfix and an upgrade to .NET standard 2.0 and wkhtml2pdf 0.12.5 at https://www.nuget.org/packages/RndUsr0.DinkToPdf/

It's only been tested on Windows, but any feedback gratefully received...

rndusr0 avatar Mar 11 '19 10:03 rndusr0

@rndusr0 awesome! All, Chris Bryden's (rndusr0) fork looks solid to me. I plan to adopt his NuGet package and file issues against his repo instead of here. (If that's OK with you, Chris.)

ajryan avatar Mar 11 '19 13:03 ajryan

@ajryan Thanks - Yes that's great with me, I'll aim to get it set up on my Linux and MacOS machines so I can test there. We are using this package in commercial projects on Windows, so I'd appreciate any bug reports or suggestions for improvement and will aim to get them turned round in a reasonable amount of time!

rndusr0 avatar Mar 11 '19 14:03 rndusr0

My repo (https://github.com/hakanl/DinkToPdf) is also on NuGet and it includes all native binaries, is docker-compatible (and tested).

HakanL avatar May 16 '19 19:05 HakanL