Skip to content

Commit

Permalink
Resolved a few small conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan McMinn committed Mar 21, 2016
2 parents 9ddb148 + b52649c commit ff955c5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ solr/solr_home
Users/*
Users

pdf-toolkit-repo/bin
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,25 @@ else if (keyType.equalsIgnoreCase(KEY_TYPE_PKCS12))
ContentReader pdfReader = getReader(targetNodeRef);
PdfReader reader = new PdfReader(pdfReader.getContentInputStream());

// If the page number is 0 because it couldn't be parsed or for
// some other reason, set it to the first page, which is 1.
// If the page number is negative, assume the intent is to "wrap".
// For example, -1 would always be the last page.
int numPages = reader.getNumberOfPages();
if (pageNumber < 1 && pageNumber == 0) {
pageNumber = 1; // use the first page
} else {
// page number is negative
pageNumber = numPages + 1 + pageNumber;
if (pageNumber <= 0) pageNumber = 1;
}

// if the page number specified is more than the num of pages,
// use the last page
if (pageNumber > numPages) {
pageNumber = numPages;
}

// create temp dir to store file
File alfTempDir = TempFileProvider.getTempDir();
tempDir = new File(alfTempDir.getPath() + File.separatorChar + targetNodeRef.getId());
Expand All @@ -486,7 +505,7 @@ else if (keyType.equalsIgnoreCase(KEY_TYPE_PKCS12))
// set reason for signature and location of signer
sap.setReason(reason);
sap.setLocation(location);

if (visibility.equalsIgnoreCase(VISIBILITY_VISIBLE))
{
//create the signature rectangle using either the provided position or
Expand Down

0 comments on commit ff955c5

Please sign in to comment.