We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Performance difference on repeat

Thread ID:

Created:

Updated:

Platform:

Replies:

140958 Nov 15,2018 09:19 PM UTC Nov 16,2018 09:08 AM UTC ASP.NET MVC - EJ 2 1
loading
Tags: PDF
Pieter van Kampen
Asked On November 15, 2018 09:19 PM UTC

Hi,
I am noticing an enormous performance difference between the first and a subsequent conversion of a PDF document. After a while of rest, it gets to the low performance again. I am using the sample DocIO_AspNetWebApi_ServiceApplication to convert word documents created in Asp.Net Core to PDF via this service in Asp.Net MVC.

To find out what is going on, I inserted some timing.

This is the conversion code:

       [AcceptVerbs("Post")]
        public HttpResponseMessage ConvertToPdf()
        {
            var timer = Stopwatch.StartNew();
            HttpResponseMessage httpResponseMessage;
            using (Stream stream = Request.Content.ReadAsStreamAsync().Result)
            {
                
                try
                {
                    //Loads the Word document from stream
                    using (WordDocument wordDocument = new WordDocument(stream))
                    {
                        Logger.Trace("PDF Stream read in {0}ms", timer.ElapsedMilliseconds);

                        //Initializes the ChartToImageConverter for converting charts during Word to PDF conversion
                        wordDocument.ChartToImageConverter = new ChartToImageConverter
                        {
                            ScalingMode = Syncfusion.OfficeChart.ScalingMode.Normal
                        };
                        //Creates an instance of the DocToPDFConverter
                        var docToPdfConverter = new DocToPDFConverter();
                        //Converts Word document into PDF document
                        PdfDocument pdfDocument = docToPdfConverter.ConvertToPDF(wordDocument);
                        Logger.Trace("PDF converted in {0}ms", timer.ElapsedMilliseconds);

                        //Saves the PDF document to response stream
                        var memoryStream = new MemoryStream();
                        pdfDocument.Save(memoryStream);
                        Logger.Trace("PDF saved in {0}ms", timer.ElapsedMilliseconds);

                        memoryStream.Position = 0;
                        httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK)
                        {
                            Content = new StreamContent(memoryStream)
                        };
                        pdfDocument.Dispose();
                    }
                }
                catch(Exception)
                {
                    httpResponseMessage = new HttpResponseMessage(HttpStatusCode.ExpectationFailed);
                }
            }

            Logger.Trace("PDF Convert finished in {0}ms", timer.ElapsedMilliseconds);
            return httpResponseMessage;
        }

The timing collected (and I have seen worse) is
First time taking 9s:

2018-11-15 22:00:18.7342|TRACE|1.0.0.0|wordtopdf|PDF Converted in 2114ms|
2018-11-15 22:03:39.4332|RACE|1.0.0.0|wordtopdf|PDF Stream read in 3779ms|
2018-11-15 22:03:44.5702|TRACE|1.0.0.0|wordtopdf|PDF converted in 8918ms|
2018-11-15 22:03:44.9372|TRACE|1.0.0.0|wordtopdf|PDF saved in 9285ms|

The second time, same document:
2018-11-15 22:03:51.6282|TRACE|1.0.0.0|wordtopdf|PDF Stream read in 55ms|
2018-11-15 22:03:53.2232|TRACE|1.0.0.0|wordtopdf|PDF converted in 1650ms|
2018-11-15 22:03:53.3942|TRACE|1.0.0.0|wordtopdf|PDF saved in 1820ms|
2018-11-15 22:03:53.4352|TRACE|1.0.0.0|wordtopdf|PDF Convert finished in 1861ms|

This difference is not random (maybe the server busy), it repeats itself after a few minutes: 

2018-11-15 22:14:57.2182|TRACE|1.0.0.0|wordtopdf|PDF Stream read in 4020ms|
2018-11-15 22:15:03.1012|TRACE|1.0.0.0|wordtopdf|PDF converted in 9904ms|
2018-11-15 22:15:03.4912|TRACE|1.0.0.0|wordtopdf|PDF saved in 10294ms|
2018-11-15 22:15:03.6272|TRACE|1.0.0.0|wordtopdf|PDF Convert finished in 10430ms|

2018-11-15 22:15:56.6192|TRACE|1.0.0.0|wordtopdf|PDF Stream read in 57ms|
2018-11-15 22:15:58.3902|TRACE|1.0.0.0|wordtopdf|PDF converted in 1827ms|
2018-11-15 22:15:58.5942|TRACE|1.0.0.0|wordtopdf|PDF saved in 2031ms|
2018-11-15 22:15:58.6252|TRACE|1.0.0.0|wordtopdf|PDF Convert finished in 2062ms|

Any idea what this can be?


Prakash Kumar D [Syncfusion]
Replied On November 16, 2018 09:08 AM UTC

 
Hi Pieter, 
 
Thank you for contacting Syncfusion support. 
 
From the given details, it is usual occurrences of time delay in seconds when converting Word document into PDF using service. We suspect that the issue might be due to the server busy, it occurs inconsistently. If you face too much of time delay (minute differences) when converting Word document into PDF, then kindly share us the input Word document which will helpful for us to provide you the prompt solution.  
 
Regards, 
Prakash Kumar 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;