Is there a way to print only the first appearance of a subreport in Jasper-Report?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm fixing a Jasper-Report not being able to print the first page when a given parameter $P{} in a subreport is too big to fit into the page.
The report is pretty simple. A single template page with a title, pageheader, pagenumber, a subreport with just a few textFields( username, date, category...), and a datatable. This template is being repeated for every printed page until all table rows are printed. The only exception is the subreport which is printed only on the first page. This was done by printWhenExpression set to "$V{PAGE_NUMBER}==1", which seems to be the accepted solution everywhere I look.
This is the subreport definition:
<subreport>
<reportElement
positionType="Float"
stretchType="RelativeToTallestObject" x="5" y="67" width="160" height="13" isPrintInFirstWholeBand="true"
isPrintWhenDetailOverflows="true"
uuid="33028395-a759-4029-83de-17fb8465fc3b">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>
</reportElement>
<subreportParameter name="username">
<subreportParameterExpression><![CDATA[$P{username}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="startdate">
<subreportParameterExpression><![CDATA[$P{startdate}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="enddate">
<subreportParameterExpression><![CDATA[$P{enddate}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="category">
<subreportParameterExpression><![CDATA[$P{category}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="selectedareas">
<subreportParameterExpression><![CDATA[$P{selectedareas}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="contract">
<subreportParameterExpression><![CDATA[$P{contract}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "userdata.jasper"]]></subreportExpression>
</subreport>
The problem is, when subreport parameter $P{selectedAreas} is too big to fit in one page, Jasper just renders a full blank first page. With nothing in it, none, not page headers, nothing.
Second page and beyond appear just right.
If we remove $V{PAGE_NUMBER}==1 then this error is thrown:
net.sf.jasperreports.engine.JRRuntimeException: Infinite loop creating new page due to page header overflow.
This is due the subreport using 2 pages, which aparrently makes the use of printWhenExpression as discriminator useless. Is there another way to print the subreport only for the first appearance?
java xml jasper-reports overflow
add a comment |
I'm fixing a Jasper-Report not being able to print the first page when a given parameter $P{} in a subreport is too big to fit into the page.
The report is pretty simple. A single template page with a title, pageheader, pagenumber, a subreport with just a few textFields( username, date, category...), and a datatable. This template is being repeated for every printed page until all table rows are printed. The only exception is the subreport which is printed only on the first page. This was done by printWhenExpression set to "$V{PAGE_NUMBER}==1", which seems to be the accepted solution everywhere I look.
This is the subreport definition:
<subreport>
<reportElement
positionType="Float"
stretchType="RelativeToTallestObject" x="5" y="67" width="160" height="13" isPrintInFirstWholeBand="true"
isPrintWhenDetailOverflows="true"
uuid="33028395-a759-4029-83de-17fb8465fc3b">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>
</reportElement>
<subreportParameter name="username">
<subreportParameterExpression><![CDATA[$P{username}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="startdate">
<subreportParameterExpression><![CDATA[$P{startdate}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="enddate">
<subreportParameterExpression><![CDATA[$P{enddate}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="category">
<subreportParameterExpression><![CDATA[$P{category}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="selectedareas">
<subreportParameterExpression><![CDATA[$P{selectedareas}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="contract">
<subreportParameterExpression><![CDATA[$P{contract}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "userdata.jasper"]]></subreportExpression>
</subreport>
The problem is, when subreport parameter $P{selectedAreas} is too big to fit in one page, Jasper just renders a full blank first page. With nothing in it, none, not page headers, nothing.
Second page and beyond appear just right.
If we remove $V{PAGE_NUMBER}==1 then this error is thrown:
net.sf.jasperreports.engine.JRRuntimeException: Infinite loop creating new page due to page header overflow.
This is due the subreport using 2 pages, which aparrently makes the use of printWhenExpression as discriminator useless. Is there another way to print the subreport only for the first appearance?
java xml jasper-reports overflow
I can't really understand, this subreport has dynamic height and is in a page header?. You probably need to do a Minimal, Complete, and Verifiable example, do it minimal!, including both main report and subreport jrxml. As question is, at least for me it's impossible to give you advice on report design.
– Petter Friberg
Jan 3 at 12:35
Yes, subreport has a dynamic height and is in a page header (in-between two always-repeating elements). I guess it wasn't meant to be long at all, but years have passed and now this happens. I will do an example as soon as I can. But I can smell that the solution will be to cut the pageheader into slices and make each one of them repeatable except for the subreport one.
– p4x
Jan 3 at 12:59
Rather use a groupHeader, pageHeader have fixed size you can't have dynamic (overflowing height) content in it
– Petter Friberg
Jan 3 at 13:02
add a comment |
I'm fixing a Jasper-Report not being able to print the first page when a given parameter $P{} in a subreport is too big to fit into the page.
The report is pretty simple. A single template page with a title, pageheader, pagenumber, a subreport with just a few textFields( username, date, category...), and a datatable. This template is being repeated for every printed page until all table rows are printed. The only exception is the subreport which is printed only on the first page. This was done by printWhenExpression set to "$V{PAGE_NUMBER}==1", which seems to be the accepted solution everywhere I look.
This is the subreport definition:
<subreport>
<reportElement
positionType="Float"
stretchType="RelativeToTallestObject" x="5" y="67" width="160" height="13" isPrintInFirstWholeBand="true"
isPrintWhenDetailOverflows="true"
uuid="33028395-a759-4029-83de-17fb8465fc3b">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>
</reportElement>
<subreportParameter name="username">
<subreportParameterExpression><![CDATA[$P{username}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="startdate">
<subreportParameterExpression><![CDATA[$P{startdate}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="enddate">
<subreportParameterExpression><![CDATA[$P{enddate}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="category">
<subreportParameterExpression><![CDATA[$P{category}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="selectedareas">
<subreportParameterExpression><![CDATA[$P{selectedareas}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="contract">
<subreportParameterExpression><![CDATA[$P{contract}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "userdata.jasper"]]></subreportExpression>
</subreport>
The problem is, when subreport parameter $P{selectedAreas} is too big to fit in one page, Jasper just renders a full blank first page. With nothing in it, none, not page headers, nothing.
Second page and beyond appear just right.
If we remove $V{PAGE_NUMBER}==1 then this error is thrown:
net.sf.jasperreports.engine.JRRuntimeException: Infinite loop creating new page due to page header overflow.
This is due the subreport using 2 pages, which aparrently makes the use of printWhenExpression as discriminator useless. Is there another way to print the subreport only for the first appearance?
java xml jasper-reports overflow
I'm fixing a Jasper-Report not being able to print the first page when a given parameter $P{} in a subreport is too big to fit into the page.
The report is pretty simple. A single template page with a title, pageheader, pagenumber, a subreport with just a few textFields( username, date, category...), and a datatable. This template is being repeated for every printed page until all table rows are printed. The only exception is the subreport which is printed only on the first page. This was done by printWhenExpression set to "$V{PAGE_NUMBER}==1", which seems to be the accepted solution everywhere I look.
This is the subreport definition:
<subreport>
<reportElement
positionType="Float"
stretchType="RelativeToTallestObject" x="5" y="67" width="160" height="13" isPrintInFirstWholeBand="true"
isPrintWhenDetailOverflows="true"
uuid="33028395-a759-4029-83de-17fb8465fc3b">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>
</reportElement>
<subreportParameter name="username">
<subreportParameterExpression><![CDATA[$P{username}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="startdate">
<subreportParameterExpression><![CDATA[$P{startdate}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="enddate">
<subreportParameterExpression><![CDATA[$P{enddate}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="category">
<subreportParameterExpression><![CDATA[$P{category}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="selectedareas">
<subreportParameterExpression><![CDATA[$P{selectedareas}]]></subreportParameterExpression>
</subreportParameter>
<subreportParameter name="contract">
<subreportParameterExpression><![CDATA[$P{contract}]]></subreportParameterExpression>
</subreportParameter>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "userdata.jasper"]]></subreportExpression>
</subreport>
The problem is, when subreport parameter $P{selectedAreas} is too big to fit in one page, Jasper just renders a full blank first page. With nothing in it, none, not page headers, nothing.
Second page and beyond appear just right.
If we remove $V{PAGE_NUMBER}==1 then this error is thrown:
net.sf.jasperreports.engine.JRRuntimeException: Infinite loop creating new page due to page header overflow.
This is due the subreport using 2 pages, which aparrently makes the use of printWhenExpression as discriminator useless. Is there another way to print the subreport only for the first appearance?
java xml jasper-reports overflow
java xml jasper-reports overflow
asked Jan 3 at 12:26
p4xp4x
104212
104212
I can't really understand, this subreport has dynamic height and is in a page header?. You probably need to do a Minimal, Complete, and Verifiable example, do it minimal!, including both main report and subreport jrxml. As question is, at least for me it's impossible to give you advice on report design.
– Petter Friberg
Jan 3 at 12:35
Yes, subreport has a dynamic height and is in a page header (in-between two always-repeating elements). I guess it wasn't meant to be long at all, but years have passed and now this happens. I will do an example as soon as I can. But I can smell that the solution will be to cut the pageheader into slices and make each one of them repeatable except for the subreport one.
– p4x
Jan 3 at 12:59
Rather use a groupHeader, pageHeader have fixed size you can't have dynamic (overflowing height) content in it
– Petter Friberg
Jan 3 at 13:02
add a comment |
I can't really understand, this subreport has dynamic height and is in a page header?. You probably need to do a Minimal, Complete, and Verifiable example, do it minimal!, including both main report and subreport jrxml. As question is, at least for me it's impossible to give you advice on report design.
– Petter Friberg
Jan 3 at 12:35
Yes, subreport has a dynamic height and is in a page header (in-between two always-repeating elements). I guess it wasn't meant to be long at all, but years have passed and now this happens. I will do an example as soon as I can. But I can smell that the solution will be to cut the pageheader into slices and make each one of them repeatable except for the subreport one.
– p4x
Jan 3 at 12:59
Rather use a groupHeader, pageHeader have fixed size you can't have dynamic (overflowing height) content in it
– Petter Friberg
Jan 3 at 13:02
I can't really understand, this subreport has dynamic height and is in a page header?. You probably need to do a Minimal, Complete, and Verifiable example, do it minimal!, including both main report and subreport jrxml. As question is, at least for me it's impossible to give you advice on report design.
– Petter Friberg
Jan 3 at 12:35
I can't really understand, this subreport has dynamic height and is in a page header?. You probably need to do a Minimal, Complete, and Verifiable example, do it minimal!, including both main report and subreport jrxml. As question is, at least for me it's impossible to give you advice on report design.
– Petter Friberg
Jan 3 at 12:35
Yes, subreport has a dynamic height and is in a page header (in-between two always-repeating elements). I guess it wasn't meant to be long at all, but years have passed and now this happens. I will do an example as soon as I can. But I can smell that the solution will be to cut the pageheader into slices and make each one of them repeatable except for the subreport one.
– p4x
Jan 3 at 12:59
Yes, subreport has a dynamic height and is in a page header (in-between two always-repeating elements). I guess it wasn't meant to be long at all, but years have passed and now this happens. I will do an example as soon as I can. But I can smell that the solution will be to cut the pageheader into slices and make each one of them repeatable except for the subreport one.
– p4x
Jan 3 at 12:59
Rather use a groupHeader, pageHeader have fixed size you can't have dynamic (overflowing height) content in it
– Petter Friberg
Jan 3 at 13:02
Rather use a groupHeader, pageHeader have fixed size you can't have dynamic (overflowing height) content in it
– Petter Friberg
Jan 3 at 13:02
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54022287%2fis-there-a-way-to-print-only-the-first-appearance-of-a-subreport-in-jasper-repor%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54022287%2fis-there-a-way-to-print-only-the-first-appearance-of-a-subreport-in-jasper-repor%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown

I can't really understand, this subreport has dynamic height and is in a page header?. You probably need to do a Minimal, Complete, and Verifiable example, do it minimal!, including both main report and subreport jrxml. As question is, at least for me it's impossible to give you advice on report design.
– Petter Friberg
Jan 3 at 12:35
Yes, subreport has a dynamic height and is in a page header (in-between two always-repeating elements). I guess it wasn't meant to be long at all, but years have passed and now this happens. I will do an example as soon as I can. But I can smell that the solution will be to cut the pageheader into slices and make each one of them repeatable except for the subreport one.
– p4x
Jan 3 at 12:59
Rather use a groupHeader, pageHeader have fixed size you can't have dynamic (overflowing height) content in it
– Petter Friberg
Jan 3 at 13:02