I make the PDF by helping of ITextRenderer
The code is
StringBuffer buf = new StringBuffer("content for showing in PDF");
javax.xml.parsers.DocumentBuilder builder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder();
org.w3c.dom.Document doc = builder.parse(new java.io.StringBufferInputStream(buf.toString()));
response.setContentType("application/pdf");
response.setHeader("Content-Disposition", "attachment; filename=\"" + (type.equals("0") ? "sales_list" : "lettings_list") + ".pdf\"");
java.io.OutputStream os = response.getOutputStream();
org.xhtmlrenderer.pdf.ITextRenderer renderer = new org.xhtmlrenderer.pdf.ITextRenderer();
renderer.setDocument(doc, null);
renderer.layout();
renderer.createPDF(os);
os.close();
So here in the content I have several records to show in the PDF.
Now I want that these individual records are shown in the same page, meaning I do not want to show the related content to appear on two pages.
If there is not enough space on current page then whole content is transfer to next page, not split in two pages.