title: splitting a pdf in different pdf pages
body: <p>I am trying to use the following library import com.itextpdf in order to |:
  from one pdf document create a new pdf document per page. </p>
  
  <p>For example for a.pdf which is 3 pages I am creating a1.pdf a2.pdf and a3.pdf which a1 being the first page of a etc... </p>
  
  <p>For some reasons the output created is incorrect. If a.pdf is one page the new page created as a different hash... any help is appreciated </p>
  
  <pre><code>public static void onePage(int num, String to, PdfReader reader) throws DocumentException,IOException {
      Document document = new Document(PageSize.A4);
  
      PdfWriter writer = PdfWriter.getInstance(document,new FileOutputStream(to));
      document.open();
  
      PdfImportedPage page;
      page = writer.getImportedPage(reader, num);
      Image instance = Image.getInstance(page);
  
      instance.setAbsolutePosition(0, 30);
  
      document.add(instance);
  
      document.close();
  
  }
  public static void makePages(String name) throws IOException, DocumentException{
  
      PdfReader reader = new PdfReader(name+".pdf");
      int n = reader.getNumberOfPages();
      for(int i=1; i&lt;=n;i++){
          onePage(i,  name+i+".pdf", reader);
      }
  }
  </code></pre>