Junk data getting saved in AppData Folder.



  • There is a concern while generating PDF using jsReport package and C# code. Pdf are getting generated perfectly but i can see some bunch of files getting created on the Server AppData folder. As i was testing this locally i found the files getting created on my local User AppData folder.

    I think its not a good pratice to generate files that we don't need. And also these files are not getting cleared. All i want to know is that is there a way to get rid of files that are getting created on AppData floder.

    Below is my code config and code shot, jsreport theam can you suggest how to clean up the appdata folder?

    Packages details used.

    <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    </PropertyGroup>

    <ItemGroup>
    <PackageReference Include="jsreport.Binary" Version="1.10.0" />
    <PackageReference Include="jsreport.Local" Version="1.1.2" />
    </ItemGroup>

    AppData is getting populated with junk data. See the screen shot below.
    0_1521186886645_AppData Folder.png

    Actual file folder location after running below code

    public static async Task<Tuple<byte[], string, string>> GeneratePDF_Local(string tmplContent, string headerTmpl, string footerTmpl, string content, string fileName, string headerHeight, string footerHeight)
    {
    try
    {
    var rs = new LocalReporting()
    .KillRunningJsReportProcesses()
    .UseBinary(JsReportBinary.GetBinary()).AsUtility().Create();
    var report = await rs.RenderAsync(new RenderRequest()
    {
    Template = new Template()
    {
    Recipe = Recipe.PhantomPdf,
    Engine = Engine.Handlebars,
    Content = tmplContent,
    Phantom = new Phantom
    {
    Header = headerTmpl,
    Footer = footerTmpl,
    Orientation = PhantomOrientation.Portrait,
    Format = PhantomFormat.A4,
    BlockJavaScript = false,
    HeaderHeight = headerHeight,
    FooterHeight = footerHeight
    }
    },
    Data = content
    });
    using (var ms = new MemoryStream())
    {
    await report.Content.CopyToAsync(ms);
    var base64OutputFile = ms.ToArray();

                    using (FileStream file = new FileStream("E:\\" + fileName + ".pdf", FileMode.Create, FileAccess.Write))
                    {
                        //byte[] bytes = new byte[file.Length];
                        await file.WriteAsync(base64OutputFile, 0, base64OutputFile.Length);
                    }
    
                    await rs.KillAsync();
                    return new Tuple<byte[], string, string>(base64OutputFile, fileName, FileFormats.ApplicationPdf);
                }
            }
            catch { throw; }
        }
    

    Folder on which actual file getting saved see below sceeen

    0_1521187624759_Actual Folder.png



  • These files are cleaned automatically. After 3 minutes or after the next jsreport run.



  • Absolutley @jan_blaha. I truly appreciate your patience and effort. But in real time i don't want any Temp files getting created on the server. What I expected that on the go it will do the required HTML to PDF file conversion and save them on desired locations.
    I'm using .net core 2.0 web app and trying to generate PDF based on the templates saved on the dbase.



  • After 3 minutes of report creation, still the reports are not getting cleared. You can verify below is the image. These were generated at 12:57 PM and now its way too late. I'm concerned about the server space issue.

    The process of creating files on AppData folder and deleting them after 3 mins or after next jsreport run, can't be bypassed?

    0_1521198548947_upload-55eca598-3327-4914-b553-fa4fe4bf54c3



  • If the jsreport daemon runs, it should clear temp files. However if you close the application. It is closed as well and doesn't clean.
    The next application start (render invoked) the temp files should be cleaned.

    We evaluated multiple ways how to work without temp files.
    However the pest performing strategy to send html to the pdf renderer, in this case phantomjs, is using temporary files.



  • This post is deleted!

Log in to reply
 

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.