PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
pageable.update();
int pageCount = pageable.getNumberOfPages();
if (pageCount>0){
ViewPrintable printable=pageable.getSafePrintable();
ExtendedPageFormat pageFormat=pageable.getSafePageFormat();
double width=pageFormat.getWidth();
double height=pageFormat.getHeight();
float startIncrement=0.1f;
float endIncrement=0.0f;
float progressIncrement = (1.0f-startIncrement-endIncrement)/pageCount;
for (int p=0;p< pageCount;p++) {
setProgress(startIncrement+p*progressIncrement);