-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from metanorma/image_extract
Image extract
- Loading branch information
Showing
9 changed files
with
35,111 additions
and
18,018 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.metanorma.fop; | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Comparator; | ||
import java.util.UUID; | ||
|
||
public class PDFResult { | ||
|
||
private static PDFResult PDFResultSingleInstance = null; | ||
|
||
private String outFolder; | ||
|
||
private Path outTmpImagesPath; | ||
|
||
private PDFResult() { | ||
} | ||
|
||
private PDFResult(File pdfFile) { | ||
String parentFolder = pdfFile.getParent(); | ||
if (parentFolder == null) { | ||
parentFolder = pdfFile.getAbsoluteFile().getParent(); | ||
} else { | ||
parentFolder = new File(parentFolder).getAbsolutePath(); | ||
} | ||
outTmpImagesPath = Paths.get(parentFolder, "_tmp_images_" + UUID.randomUUID().toString()); | ||
outFolder = parentFolder; | ||
} | ||
|
||
public static PDFResult PDFResult(File pdfFile) | ||
{ | ||
if (PDFResultSingleInstance == null) { | ||
PDFResultSingleInstance = new PDFResult(pdfFile); | ||
} | ||
return PDFResultSingleInstance; | ||
} | ||
|
||
public String getOutFolder() { | ||
return outFolder; | ||
} | ||
|
||
public Path getOutTmpImagesPath() { | ||
return outTmpImagesPath; | ||
} | ||
|
||
|
||
public void flushOutTmpImagesFolder () { | ||
if (Files.exists(outTmpImagesPath)) { | ||
try { | ||
Files.walk(outTmpImagesPath) | ||
.sorted(Comparator.reverseOrder()) | ||
.map(Path::toFile) | ||
.forEach(File::delete); | ||
Files.deleteIfExists(outTmpImagesPath); | ||
} catch (Exception ex) { | ||
ex.printStackTrace(); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.