-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'a078564d53495e78687d2089e54569ae4106c3cd'
- Loading branch information
Showing
5 changed files
with
75 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import java.io.File | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.api.tasks.InputFile | ||
|
||
import org.apache.tika.metadata.Metadata | ||
import org.apache.tika.parser.ParseContext | ||
import org.apache.tika.parser.pdf.PDFParser | ||
import org.apache.tika.sax.BodyContentHandler | ||
|
||
/** | ||
* PDF 文書のメタデータを確認するユーティリティタスク | ||
* | ||
*/ | ||
abstract class PdfInfoTask extends DefaultTask { | ||
/** | ||
* PDF 文書 | ||
*/ | ||
@InputFile | ||
File pdfFile | ||
|
||
/** | ||
* Gradle タスクエントリーポイント | ||
*/ | ||
@TaskAction | ||
def checkPdfInfo() { | ||
BodyContentHandler handler = new BodyContentHandler() | ||
Metadata metadata = new Metadata() | ||
FileInputStream input = new FileInputStream(pdfFile) | ||
ParseContext context = new ParseContext() | ||
|
||
PDFParser pdf = new PDFParser() | ||
pdf.parse(input, handler, metadata, context) | ||
|
||
metadata.names().sort().each { name -> | ||
println "${name}: ${metadata.get(name)}" | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -124,3 +124,4 @@ abstract class SyncImageTask extends DefaultTask { | |
} | ||
} | ||
} | ||
|