GithubHelp home page GithubHelp logo

Comments (10)

erwindamsma avatar erwindamsma commented on August 28, 2024 2

I had a similar problem a while ago.

You're not using the the converter you added as singleton in Startup.cs. You're creating a new SynchronizedConverter and PdfTools every time your class instantiates. I think this causes issues because you're ending up creating multiple instances of PdfTools without disposing them. (PdfTools implements IDisposable).

I would change your constructor to retrieve the converter from the services by dependency injection instead.

Perhaps something like this:

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

from dinktopdf.

matheusavi avatar matheusavi commented on August 28, 2024 1

We changed to a java API with jasper.

from dinktopdf.

gabrielcapanogyp avatar gabrielcapanogyp commented on August 28, 2024 1

Well, it seems to be problem with the DinkToPdf...

I guess that is something about making a singleton instance receive a IDisposable class (PdfTools)

I just made this code and worked like a charm:

      using(var tools  = new PdfTools())
            {
                var _pdfConverter = new SynchronizedConverter(tools);


                if(!_pdfConverter.Tools.IsLoaded){
                    _pdfConverter.Error += (object sender, ErrorArgs e) => logger.LogError(e.Message);
                    _pdfConverter.Finished += (object sender, FinishedArgs e) => logger.LogInformation(e.Success.ToString());
                    _pdfConverter.Warning += (object sender, WarningArgs e) => logger.LogWarning(e.Message);
                    _pdfConverter.ProgressChanged += (object sender, ProgressChangedArgs e) => logger.LogInformation(e.Description);
                    _pdfConverter.PhaseChanged += (object sender, PhaseChangedArgs e) => logger.LogInformation(e.Description);
                
                }
                
                var doc = new HtmlToPdfDocument()
                {
                    Objects =
                    {

                        new ObjectSettings
                        {
                            HtmlContent = html,

                        }
                    }
                };
                byte[] pdfBytes = _pdfConverter.Convert(doc); 
            }

from dinktopdf.

matheusavi avatar matheusavi commented on August 28, 2024

I did what you said.
It worked for 30 minutes.
Then I had the same effect, including with the test project (DinkToPdf.TestWebServer).

from dinktopdf.

matheusavi avatar matheusavi commented on August 28, 2024

Interestingly, it works on IIS.
The client has been using it for some time and I have done several tests on my machine.

from dinktopdf.

lkolodziey avatar lkolodziey commented on August 28, 2024

As erwindamsma said, I put as Singleton and works fine.

from dinktopdf.

matheusavi avatar matheusavi commented on August 28, 2024

It seems to be a problem with https://github.com/wkhtmltopdf/wkhtmltopdf , because it ocours in other librarys that use wkhtmltopdf.

from dinktopdf.

psychos4 avatar psychos4 commented on August 28, 2024

My Problem is, the first time it works perfectly. If I start the second document to convert, it will never end. Any Solutions?

dotnet core version: 2.1.3

from dinktopdf.

lkolodziey avatar lkolodziey commented on August 28, 2024

@psychos4
For example I created a web application using dotnet core 2.1, take a look because when generate pdf I can push button many times and many PDFs are created.
https://github.com/lkolodziey/UsingDinkToPdf_Example

from dinktopdf.

 avatar commented on August 28, 2024

Hi, @lkolodziey
Have you solved your problem? I am facing the same problem with Dotnet Core SDK 3.0.100-preview5-011568.

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.