Skip to content

Commit

Permalink
#413 - add images to existing PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
Swati4star committed Nov 29, 2018
1 parent a875745 commit 077f35b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ public void parse() {
hideKeyboard(mActivity);
if (mOperation.equals(ADD_IMAGES)) {
getFileName();
return;
}
}

Expand All @@ -199,7 +198,6 @@ private void getFileName() {
final String filename = input.toString();
FileUtils utils = new FileUtils(mActivity);
if (!utils.isFileExist(filename + getString(R.string.pdf_ext))) {
// mPdfOptions.setOutFileName(filename);
this.addImagesToPdf(filename);
} else {
MaterialDialog.Builder builder2 = createOverwriteDialog(mActivity);
Expand All @@ -211,6 +209,10 @@ private void getFileName() {
}).show();
}

/**
* Adds images to existing PDF
* @param output - path of output PDF
*/
private void addImagesToPdf(String output) {
int index = mPath.lastIndexOf("/");
String outputPath = mPath.replace(mPath.substring(index + 1),
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/java/swati4star/createpdf/util/PDFUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,13 @@ protected void onPostExecute(String s) {
}
}


/**
* Main function to add images to PDF
* @param inputPath - path of input PDF
* @param output - path of output PDF
* @param imagesUri - list of images to add
* @return true, if succeeded, otherwise false
*/
public boolean addImagesToPdf(String inputPath, String output, ArrayList<String> imagesUri) {
try {
PdfReader reader = new PdfReader(inputPath);
Expand Down Expand Up @@ -629,6 +635,10 @@ public void afterTextChanged(Editable input) {
});
mDialog.show();
}

/**
* Shows the dialog to allow users to add images
*/
public void setImages() {
new MaterialDialog.Builder(mContext)
.title(R.string.add_images)
Expand Down

0 comments on commit 077f35b

Please sign in to comment.