Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't render Empty Page conditionally #2993

Open
Vlasakh opened this issue Dec 3, 2024 · 1 comment
Open

Doesn't render Empty Page conditionally #2993

Vlasakh opened this issue Dec 3, 2024 · 1 comment

Comments

@Vlasakh
Copy link

Vlasakh commented Dec 3, 2024

I want to render an empty page conditionally by pageNumber or totalPages. It means that I have to use the render method on the component with break prop:

<View render={({ pageNumber }) =>
	pageNumber % 2 !== 0 && (
		<View break>
			<Text>I'm only visible in even pages!</Text>
		</View>
	)}
/>;

but break does not work in the render method. Why? How can I do it?

It needs to double side printing document. I have an array of elements to print, but each element(can span more than one page) have to placed on new odd page.

Also I tried to use Page in condition rendering, but then the page numbering is broken. Like this:

<View render={({ pageNumber, totalPages }) => {
	const isBreak = pageNumber % 2 !== 0 && pageNumber !== totalPages;

	return isBreak ? (
		<Page>
			<Text>{pageNumber}</Text>
		</Page>
	) : null;
}} />;

Perhaps you have another solution for this?

React-PDF version: 4.0.0

@PeterLaudel
Copy link

First take care of this #2969 (comment)

But I don't know how to solve your problem in a different way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants