2 Way Printing Jaspersoft Studio

Asked

Viewed 512 times

1

  • I have a Master report that has two "Detail Band", with a defined height, which should not be modified.
  • My Sub-report also has a "Detail Band", with a Jrbeancollectiondatasource, the parameters are being passed without major problems, HOWEVER, paging is not being done as I would like.
  • I need you to stay TWO ways on the same page, as a lefty, when there are few items works, but there are cases where they can have up to 200 items, and they need to be paged, keeping the height fixed.

Uma imagem ilustrativa para melhor explanar o resultado que preciso.

  • At the moment, when there are many items, it simply shows continuously. I tried several combinations with Stretch and No Stretch, Band’s Split Type, I couldn’t really come up with a solution.
  • I was able to do a Minimum Verifiable Example as Stackoverflow recommends... follow the repository link - https://github.com/Sibelly/jasper-subrelatorios
  • And if you determined a Detail band only that I had the size of half sheet A4, since the two are equal automatically it would put two on a sheet

  • So, I remember I tried at the time, but the Tail band didn’t get the truncated height you know.

1 answer

0


I was able to solve this problem by truncating the number of items per page in the code itself. I created a method with the logic responsible for breaking the items. Basically it is the code snippet below:

       while (quantidadeDeItens > 0) {
            if (quantidadeDeItens <= quantidadeDeItensPorPagina) {
                itensPaginados.addAll(produtos.subList(i, produtos.size()));

                // Workaround para deixar o layout sempre do mesmo tamanho
                if (itensPaginados.size() < quantidadeDeItensPorPagina) {
                    while (itensPaginados.size() < quantidadeDeItensPorPagina) {
                        Produto item = new Produto();
                        itensPaginados.add(item);
                    }
                }
            } else {
                itensPaginados.addAll(produtos.subList(i, j));
            }

            paginaCorrente = paginaCorrente + 1;

            JasperPrint printReport = setarParametrosParaImpressao(itensPaginados, cliente, totalPaginas, paginaCorrente);
            listaDeProdutosParaImpressao.add(printReport);

            i = i + quantidadeDeItensPorPagina;
            j = j + quantidadeDeItensPorPagina;
            quantidadeDeItens = quantidadeDeItens - quantidadeDeItensPorPagina;
            itensPaginados = new ArrayList<>();

        }

But I had to modify the way Jasperprint is generated. I will not put here because it would be too long, for those interested just check on this repository.

I forgot to answer before, but I hope you help someone someday. ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.