$ 0 0 It could be XY problem, maybe you shouldn't include pdf footers from empty pages into string or include footers just once?