Wrong number of pages after adding the table

Hi !
I wanted to know the number of pages after adding a table to the page. The otuput that I expect is greater than one, because the table is distributed over several pages. Is there a way to update the document? The “doc.updatePages ();” method, throws an exception, “Null Pointer Exception”

  		Document doc = new Document();
	doc.setPageLayout(PageMode.UseNone);
	Page page = doc.getPages().add();

	Table tab = new Table();
	tab.setRepeatingRowsCount(1);
	tab.setDefaultCellPadding(new MarginInfo(2, 2, 2, 2));

	Row row = tab.getRows().add();
	row.getDefaultCellTextState().setFontStyle(FontStyle.CourierBold);
	row.getCells().add("HELLO");

	for (int j = 0; j < 100; j++) {
			row = tab.getRows().add();
			row.getCells().add("50");
		}

	page.getParagraphs().add(tab);
	System.out.println(doc.getPages().size());
	doc.save("report.pdf");

	page.getParagraphs().add(tab);
	System.out.println(doc.getPages().size());
	doc.save("report.pdf");

@Blegork

Please try to use Document.ProcessParagraphs() method in order to get the document object updated before saving it and getting the total count of pages. Please let us know in case you still face any issue.