pdf/src/main/java/se/idsec/signservice/integration/document/pdf/signpage/PdfSignPage.java
private byte[] appendDoc(final byte[] tbsDocbytes) throws IOException {
    PDDocument tbsDoc = null;
    PDDocument signPage = null;
    try {
      tbsDoc = PDDocument.load(tbsDocbytes);
      signPage = this.getSignPageDocument();
      tbsDoc.addPage(signPage.getPage(0));
      final ByteArrayOutputStream bos = new ByteArrayOutputStream();
      tbsDoc.save(bos);
      return bos.toByteArray();
    }
    finally {
      if (tbsDoc != null) {
        tbsDoc.close();
      }
      if (signPage != null) {
        signPage.close();
      }
    }
  }
/**
   * Appends the sign page to the document to be signed
   *
   * @param tbsDocbytes
   *          the bytes of the document to be signed
   * @return a new document to be signed with an appended sign page
   * @throws IOException
   *           on invalid input
   */
Appends the sign page to the document to be signed
@param tbsDocbytes
the bytes of the document to be signed
@return a new document to be signed with an appended sign page
@throws IOException
on invalid input
Appends the sign page to the document to be signed @param tbsDocbytes the bytes of the document to be signed @return a new document to be signed with an appended sign page @throws IOException on invalid input
private byte[] appendDoc(final byte[] tbsDocbytes) throws IOException {
    PDDocument tbsDoc = null;
    PDDocument signPage = null;
    try {
      tbsDoc = PDDocument.load(tbsDocbytes);
      signPage = this.getSignPageDocument();
      tbsDoc.addPage(signPage.getPage(0));
      final ByteArrayOutputStream bos = new ByteArrayOutputStream();
      tbsDoc.save(bos);
      return bos.toByteArray();
    }
    finally {
      if (tbsDoc != null) {
        tbsDoc.close();
      }
      if (signPage != null) {
        signPage.close();
      }
    }
  }
private byte [ ] appendDoc ( final byte [ ] tbsDocbytes ) throws IOException { PDDocument tbsDoc = null ; PDDocument signPage = null ; try { tbsDoc = PDDocument . load ( tbsDocbytes ) ; signPage = this . getSignPageDocument ( ) ; tbsDoc . addPage ( signPage . getPage ( 0 ) ) ; final ByteArrayOutputStream bos = new ByteArrayOutputStream ( ) ; tbsDoc . save ( bos ) ; return bos . toByteArray ( ) ; } finally { if ( tbsDoc != null ) { tbsDoc . close ( ) ; } if ( signPage != null ) { signPage . close ( ) ; } } }
Appends the sign page to the document to be signed
 @param tbsDocbytes
          the bytes of the document to be signed
 @return a new document to be signed with an appended sign page
 @throws IOException
           on invalid input
Appends the sign page to the document to be signed @param tbsDocbytes the bytes of the document to be signed @return a new document to be signed with an appended sign page @throws IOException on invalid input