Giter Site home page Giter Site logo

Comments (6)

teocomi avatar teocomi commented on May 14, 2024 1

A part from declaring the singleton in Startup.cs as indicated in the README, I had to add this to my controller:

       private readonly IConverter _converter;

       public MyController(IConverter converter)
       {
           _converter = converter;
       }

       private byte[] GeneratePdf(string html)
        {
           
            var doc = new HtmlToPdfDocument()
            {
              ...
            };
            var pdf = _converter.Convert(doc);
            return pdf;
        }

from dinktopdf.

timfisher avatar timfisher commented on May 14, 2024

The only way I could get this to work was by using the singleton, without the singleton it fails. Hope this helps someone

from dinktopdf.

rdvojmoc avatar rdvojmoc commented on May 14, 2024

You are correct. This detail is also written in README

from dinktopdf.

timfisher avatar timfisher commented on May 14, 2024

In the README you say this first:

Synchronised converter

Use this converter in multi threaded applications and web servers. Conversion tasks are saved to blocking collection and executed on a single thread.

var converter = new SynchronizedConverter(new PdfTools());

Then you mention DI, and there is no mention it is mandatory. Also the basic converter does not work at all in this way.

from dinktopdf.

rdvojmoc avatar rdvojmoc commented on May 14, 2024

Changed README to be more clear on how converter should be registered in DI.

from dinktopdf.

sundarSDI avatar sundarSDI commented on May 14, 2024

Facing the same Issue, Find my DI in Startup.cs

// In Start Up Class
services.AddSingleton(typeof(IConverter), new SynchronizedConverter(new PdfTools()));

It works for the first request, from next it hangs and no response.

Thanks in Advance.

from dinktopdf.

Related Issues (20)

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.