title: pdfbox generate multi page
body: <p>When I generate second page, I get a blank page. I have two functions. One generates a table with text, and another generates a PDF. When end place in first page, I add another page and I want write in new page. When I open generated PDF file, the second page is blank:</p>
  
  <pre><code>    //global variables
  PDPage nowa=null;
  PDPageContentStream contentStream1 = null;
  
  //function to generate table
  private void print_sumActionPerformed(java.awt.event.ActionEvent evt){
          try {
              PDDocument doc = null;
              PDPage page = null;
              int max_row=55;
              int suma=0;
              int pozycja=0;
              final int starty=760;
              final int startx=30;
          try{
                  doc = new PDDocument();
                  page = new PDPage(PDPage.PAGE_SIZE_A4);
                  doc.addPage(page);
                  PDFont font = PDType1Font.HELVETICA;
                  PDPageContentStream content = new PDPageContentStream(doc, page,true,true);
                  //some code to generate table
                  drawTable(page, content, starty, startx, content1,doc);
                  content.close();
                  doc.save("path");
                  doc.close();
                  Thread.sleep(500);
              } catch (Exception e){
                  System.out.println(e);
              }
          } catch (IOException ex) {
              Logger.getLogger(Okno.class.getName()).log(Level.SEVERE, null, ex);
          } catch (PrinterException ex) {
              Logger.getLogger(Okno.class.getName()).log(Level.SEVERE, null, ex);
      } 
  }                                      
  </code></pre>
  
  <p>function to generate table in pdf</p>
  
  <pre><code>private void drawTable(PDPage page, PDPageContentStream contentStream,float y, float margin, String[][] content,PDDocument doc) throws IOException, InterruptedException {
          final int rows = content.length;
          final int cols = content[0].length;
          final float rowHeight = 13f;
          final float marginCell=5;
          final float startx=30;
          final int tableWidth3=200;
          final int tableWidth5=250;
          boolean new_kol;
          if (margin&lt;230){
              new_kol=false;
          }else {
              new_kol=true;
          }
          float textx;
          final float odst=20;
          final float starty = y;
          float texty=starty-rowHeight+3;
          //width table
          int tableWidth;
          if(cols==5)tableWidth=tableWidth5;
          else tableWidth=tableWidth3;
          //start print table in pdf
          if(!new_kol){
              contentStream.drawLine(startx,starty,tableWidth+startx+marginCell,starty);
              textx=startx+marginCell;
          }else {
              contentStream.drawLine(startx+tableWidth5+odst, starty, 2*tableWidth5+(startx)+odst+marginCell,starty);
              textx=startx+marginCell+tableWidth+odst;
          }
           for(int i = 0; i &lt; content.length; i++){
              for(int j = 0 ; j &lt; content[i].length; j++){
                  //linia pionowa
                  contentStream.drawLine(textx-marginCell,texty-3,textx-marginCell,texty-3+rowHeight);
                  String text=content[i][j];
                   if(text.contains("AB")){
                      contentStream.setFont(PDType1Font.HELVETICA_BOLD,10);
                  }else contentStream.setFont(PDType1Font.HELVETICA,8);
                  contentStream.beginText();
                  contentStream.moveTextPositionByAmount(textx,texty);
                  contentStream.drawString(text);
                  contentStream.endText();
                  switch(j){
                      case 0: textx+=30;
                          break;
                      case 1:
                          if (cols==5) textx += 120;
                          else textx+=150;
                          break;
                      case 2: textx+=15;
                          if(cols==3 ) contentStream.drawLine(textx+marginCell,texty-3,textx+marginCell,texty-3+rowHeight);
                          break;
                      case 3: textx+=40;
                          break;
                      case 4: textx+=40;
                      contentStream.drawLine(textx+marginCell,texty-3,textx+marginCell,texty-3+rowHeight);
                          break;
                  }
              }
              if(new_kol){
                  textx=tableWidth+startx+odst+marginCell;
                  contentStream.drawLine(textx-marginCell,texty-3,textx+tableWidth,texty-3);
              }
              else {
                  textx=startx+marginCell;
                  contentStream.drawLine(textx-marginCell,texty-3,textx+tableWidth,texty-3);
              }
              if((texty-=rowHeight)&lt;50){
                  if(!new_kol){
                      new_kol=true;
                      contentStream.drawLine(startx,texty+10,startx+tableWidth+marginCell,texty+10);
                      texty=760-10;
                      textx=tableWidth+startx+odst+marginCell;
                      contentStream.drawLine(textx-marginCell,texty+10,textx+tableWidth,texty+10);
                  }else{
                      new_kol=false;
                      contentStream.drawLine(startx+tableWidth5+odst,texty+10,startx+2*tableWidth,texty+10);
                      texty=760-10;
                      textx=startx+marginCell;
                      //here i add new page when end page height
                      //i get blank page
                      contentStream.close();
                      page=null;
                      contentStream=null;
                      nowa=new PDPage(PDPage.PAGE_SIZE_A4);
                      page=null;
                      page=nowa;
                      doc.addPage(nowa);
                      PDFont font = PDType1Font.HELVETICA;
                      contentStream1 = new PDPageContentStream(doc, nowa,false,true);
                      contentStream=contentStream1;
                      contentStream1=null;
                      contentStream.drawLine(textx,texty+10,textx+tableWidth,texty+10);
                  }
              }
           }
      }
  </code></pre>