Pagination numbers are missing when generation in a container



  • Hello,

    I use this template for the footer

    <table style='margin: 30px 70px; text-align:right; width:100%;'>
    <td>Page <span class='pageNumber'></span> | <span class='totalPages'></span></td></table>

    It is working fine in windows, but when I generate the pdf in a container the numbers are missing



  • playground runs in a docker container. Could you please provide the demo there so that we can check? Thanks
    https://playground.jsreport.net/



  • @jan_blaha This is the example https://playground.jsreport.net/w/lamnouar/yV7~9HuI

    This is my c# code

         var rs = new LocalReporting()
            .Configure(config => { return config; })
            .RunInDirectory(Path.Combine(Path.GetTempPath(), "jsreports"))
            .UseBinary(RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                ? JsReportBinary.GetBinary() : jsreport.Binary.Linux.JsReportBinary.GetBinary())
            .AsUtility()
            .Create();
    
        var report = await rs.RenderAsync(new RenderRequest()
        {
            Template = new Template()
            {
                Recipe = Recipe.ChromePdf,
                Engine = Engine.None,
                Content = html,
                Chrome = new Chrome()
                {
                    DisplayHeaderFooter = true,
                    FooterTemplate = GetPdfFooter(),
                    HeaderTemplate = "<span></span>",
                    Landscape = true,
                    MarginLeft = "1in",
                    MarginBottom = "1in",
                    MarginRight = "1in"
                },
            }
        });
    
        using var memoryStream = new MemoryStream();
        await report.Content.CopyToAsync(memoryStream);
    
        return memoryStream.ToArray();
    
       private string GetPdfFooter()
       {
    
    
        return @$"<table style='margin: 30px 70px; 
                            text-align:right; width:100%;'>
                        <td>Page <span class=""pageNumber""></span>&nbsp;|&nbsp;<span class=""totalPages""></span></td></table>";
    }
    

    Part of DockerFile

      FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
      WORKDIR /app
    
      RUN apt update && apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 
      libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 
      libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11- 
      xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 
      libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb- 
      release xdg-utils wget libatk-bridge2.0-0 libgbm-dev
      ENV chrome_launchOptions_args --no-sandbox,--disable-dev-shm-usage
    
      RUN mkdir jsreports
      RUN chmod +rwx ./jsreports
    
      COPY . .
      RUN dotnet restore


  • This problem is mentioned in the docs
    https://jsreport.net/learn/chrome-pdf#native-headers-and-footers
    content has scaling issue and need to set font size css to make it big enough to be visible

    So you need to add explicit font-size CSS o make the footer visible

    <table style='margin: 30px 70px; text-align:right; width:100%;font-size: 20px'>
    


  • @jan_blaha
    Still not working https://playground.jsreport.net/w/lamnouar/yV7~9HuI,
    The same code is working fine locally ( windows),
    It looks like pageNumber and totalPages have some issues on docker.
    Just to mention that I tested locally on ubuntu and it is working fine



  • Now it's getting very confusing. You added the following to the main template content

    <table style='margin: 50px 90px; text-align:right; width:100%;font-size: 80px'>
                            <td style="color:red">Page <span class="pageNumber" style='color:red; margin: 50px 90px; text-align:right; width:100%;font-size: 80px'></span>&nbsp;|&nbsp;<span class="totalPages" style='margin: 50px 90px; text-align:right; width:100%;font-size: 80px'></span></td></table>
    

    However the pageNumber is working only when you put it to the chrome header/footer template configured through template chrome properties.



  • This post is deleted!




  • Great thank you, I am checking on it.



  • Unfortunately, it works as you observe. The chrome bundled in jsreport.Binary.Linnux doesn't inject pageNumber in docker. I haven't found what is the actual reason for this. It could be an internal deps version mismatch, but I couldn't verify it.

    What you can do is use pdf utils to merge footer with page numbers.
    https://jsreport.net/learn/dotnet-client#pdf-utils
    https://playground.jsreport.net/w/admin/kMI4FBmw

    The other option is to boot the whole jsreport in the next docker container and communicate with it with jsreport.Client nuget. This option typically scales the best. Example:
    https://github.com/jsreport/jsreport-dotnet-example-docker-compose


Log in to reply
 

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