jsreport / jsreport-dotnet

jsreport .NET sdk home repository
https://jsreport.net
MIT License
63 stars 10 forks source link

Exception Thrown consistantly when trying simple example in video. #42

Closed shawty closed 4 years ago

shawty commented 4 years ago

Trying to get started with JsReport.NET and can't even get the firt example working. All I get when running the code is the following exception:

jsreport.Local.JsReportBinaryException: 'Error rendering report: looking for previously daemonized 
instance in: C:\Users\shawty\AppData\Local\Temp\jsreport\cli\sock\workerSock cwd: 
J:\Programming Projects\Test Stuff\JsReportConsole\JsReportConsole\bin\Debug\netcoreapp3.1
\jsreportA critical error occurred while trying to execute the render command (2). connect 
ETIMEDOUT 127.0.0.1:5488 (1). caused by error (2):{    at onCriticalError (D:\snapshot\jsreport
\node_modules\jsreport-cli\lib\commands\render.js:302:19)    at exports.handler (D:\snapshot
\jsreport\node_modules\jsreport-cli\lib\commands\render.js:198:14)    at process._tickCallback 
(internal/process/next_tick.js:68:7)caused by error (1):-> meta = 
{"errno":"ETIMEDOUT","code":"ETIMEDOUT","syscall":"connect","address":"127.0.0.1","port":5488}-> 
stackError:    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)'

Here's what I see in visual Studio: image

The code I'm testing is exactly the same as is in the intro video on the .NET sdk web page:

using jsreport.Binary;
using jsreport.Local;
using jsreport.Types;
using System;
using System.IO;
using System.Threading.Tasks;

namespace JsReportConsole
{
  class Program
  {
    static async Task Main(string[] args)
    {
      Console.WriteLine("Hello World!");

      var rs = new LocalReporting()
          .UseBinary(JsReportBinary.GetBinary())
          .AsUtility()
          .Create();

      var report = await rs.RenderAsync(new RenderRequest
      {
        Template = new Template

        {
          Recipe = Recipe.PhantomPdf,
          Engine = Engine.None,
          Content = "<style>h1 { color: red }</style><h1>Hello World</h1>"
        }
      });

      using(var fs = File.Create("out.pdf"))
      {
        report.Content.CopyTo(fs);
      }

    }
  }
}

I have installed the latest JsReport NuGet packages:

image

and am targeting Dot Net Core 3.1: image

Which automatically activates the C#8 compiler.

I'm running in Visual Studio 2019 Community Preview

image

My app console outputs: image

My Node and Npm versions are as follows: image

Running on a 24 core Intel Xeon workstation with 20gb of Ram under Windows 10 X64 V1809

pofider commented 4 years ago

The problem is that you use Recipe.PhantomPdf and this recipe isn't part of the jsreport v2. You should use the Recipe.ChromePdf. See the default recipes marked here https://jsreport.net/learn/recipes

I apologize for the meaningless error message. We will check why it is so bad.

Also, I would recommend trying using pre-release binary jsreport.Binary@2.6.2-beta2. There are some important fixes. I am closing this, feel free to comment further if you find other problems.

shawty commented 4 years ago

Hi pofider thanks for that. Can you possibly mention this fact in the video then, as I feel many like me will use that as their first "test" into seeing if the toolkit is of use to them.

It looks like a VERY promising system, and I absolutely want to use it, but this first experience was not a good one :-)

pofider commented 4 years ago

Yes, I wrote it at least to the video description as youtube doesn't allow me to put a text directly to the existing video.

shawty commented 4 years ago

I don't know if you are aware, just for reference :-) It's easy to add subtitles to a video now on YT, and you don't have to edit the video.

You simply provide a text file with lines with a time and the text in EG:

00:30-00:45 - Hello and Welcome to JsReport

And that text will stay on screen over the video for 15 seconds starting at 30 seconds. The sub titles don't have to match what you say in the video, and when you embed the video in a web page, you can actually set (I think) something like &subtitles=1 or similar on the URL to turn them on automatically.

I know this, because I'm deaf, so I've done a lot of research into how it all works.

Thanks again ... I have my test app(s) working now, my next test is to test them on a linux install :-)

shawty commented 4 years ago

Not a problem, but I have one more quick question if I may, I'll open a new issue if you want me too.

When producing the PDF, how do I get the ChromePdf recipe to produce an A4 size document. Currently everything it produces is the USA "Letter Size" equivalent and I need to produce UK/Europe A4 sized documents.

I've been through the docs here: https://jsreport.net/learn/dotnet-local a few times and can't see anything that tells me otherwise.

pofider commented 4 years ago

Hm, it should be by default A4. However you can explicitely set page size here

and use something like

rs.renderAsync(new RenderRequest {
  Template = new Template {
     ....,
    Chrome = new Chrome {
       Format = "A4"
    }
  }

}

Btw I would strongly recommend playing the first just with the full jsreport running with node.js. Play with the studio and get the idea of its capabilities. Just afterward switch to the .net because of integration.

shawty commented 4 years ago

Thanks, yes I have been playing with the studio, but the problem is I have a boss breathing down my neck that wants to see a printed A4 document asap :-) I'm sure you know the score :-D