-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
220 additions
and
143 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
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
80 changes: 80 additions & 0 deletions
80
pdf-text-api/src/main/java/io/xpdf/api/pdftext/util/PdfTextUtils.java
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,80 @@ | ||
/* | ||
* PdfText API - An API for accessing a native pdftotext library. | ||
* Copyright © 2024 xpdf.io (info@xpdf.io) | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package io.xpdf.api.pdftext.util; | ||
|
||
import io.xpdf.api.common.XpdfTool; | ||
import io.xpdf.api.common.util.XpdfUtils; | ||
|
||
import java.nio.file.Path; | ||
|
||
/** | ||
* Helpers for a {@link XpdfTool}. | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
public class PdfTextUtils { | ||
|
||
/** | ||
* Gets the resource name of the <em>pdftotext</em> executable native to this system. | ||
* | ||
* @return executable resource name | ||
* @since 1.0.0 | ||
*/ | ||
public static String getPdfTextExecutableResourceName() { | ||
return String.format("xpdf/%s/%s", XpdfUtils.getTargetSystem(), getPdfTextExecutableName()); | ||
} | ||
|
||
/** | ||
* Gets the path where the native <em>pdftotext</em> executable should be copied so that it can be accessed by OS. | ||
* | ||
* @return executable path | ||
* @since 1.0.0 | ||
*/ | ||
public static Path getPdfTextExecutablePath() { | ||
return XpdfUtils.getXpdfTempPath().resolve("pdf-text").resolve("bin").resolve(getPdfTextExecutableName()); | ||
} | ||
|
||
/** | ||
* Gets the temporary directory where the <em>pdftotext</em> executable should write output. | ||
* | ||
* @return temporary directory | ||
* @since 1.0.0 | ||
*/ | ||
public static Path getPdfTextTempOutputPath() { | ||
return XpdfUtils.getXpdfTempPath().resolve("pdf-text").resolve("out"); | ||
} | ||
|
||
/** | ||
* Gets the maximum amount of time in seconds allotted to the <em>pdftotext</em> process before timing out. | ||
* | ||
* @return timeout length in seconds for process | ||
* @since 1.0.0 | ||
*/ | ||
public static Integer getPdfTextTimeoutSeconds() { | ||
return 30; | ||
} | ||
|
||
/** | ||
* Gets the name of the native <em>pdftotext</em> executable. | ||
* | ||
* @return executable name | ||
*/ | ||
protected static String getPdfTextExecutableName() { | ||
return String.format("pdftotext%s", XpdfUtils.getTargetSystem().contains("windows") ? ".exe" : ""); | ||
} | ||
|
||
} |
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.