[
https://issues.apache.org/jira/browse/PDFBOX-2871?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14645730#comment-14645730
]
Roberto Nibali edited comment on PDFBOX-2871 at 7/29/15 8:57 AM:
-----------------------------------------------------------------
Is there any specific reason, PDFBox uses an EOL JDK? I understand that in many
industries people still need to use JDK-1.5 or JDK-1.6, however that shouldn't
be the case for an Open Source project. Anyway, I've fixed my code to really
traverse all directories recursively, and it works very well for me, is much
more legible and a lot faster ;). Here is the code, just for the sake of
documentation in case at one point you guys decide to change it:
{code:title=FindFonts.java|borderStyle=solid}
public static void DirWalkFindFonts() {
String[] directories = {
System.getProperty("user.home") + "/Library/Fonts/",
"/Library/Fonts/",
"/System/Library/Fonts/",
"/Network/Library/Fonts/"};
List<File> files = new ArrayList<>();
HashMap<String, String> allFiles = new HashMap<>();
for (String directory : directories) {
try {
Files.walk(Paths.get(directory)).
filter(Files::isRegularFile).
filter(p ->
p.getFileName().toString().toLowerCase().matches("^.*?(.ttf|.otf|.pfb|.ttc)$")).
forEach(p -> files.add(p.toFile()));
} catch (NoSuchFileException e) {
logmsg("Skipping: " + directory);
} catch (IOException e) {
e.getLocalizedMessage();
}
// this essentially is the FontFileFinder.find() part,
// albeit with additional functionality to later identify the font
specifics.
for (File file : files) {
String key = file.getPath();
allFiles.put(key, key.substring(Math.max(0, key.length() -
3)).toUpperCase());
}
}
System.out.println("Total Fonts: " + allFiles.size());
for (Map.Entry entry : allFiles.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}
}
{code}
was (Author: rnibali):
Is there any specific reason, PDFBox uses an EOL JDK? I understand that in many
industries people still need to use JDK-1.5 or JDK-1.6, however that shouldn't
be the case for an Open Source project. Anyway, I've fixed my code to really
traverse all directories recursively, and it works very well for me, is much
more legible and a lot faster ;). Here is the code, just for the sake of
documentation in case at one point you guys decide to change it:
public static void DirWalkFindFonts() {
String[] directories = {
System.getProperty("user.home") + "/Library/Fonts/",
"/Library/Fonts/",
"/System/Library/Fonts/",
"/Network/Library/Fonts/"};
List<File> files = new ArrayList<>();
HashMap<String, String> allFiles = new HashMap<>();
for (String directory : directories) {
try {
Files.walk(Paths.get(directory)).
filter(Files::isRegularFile).
filter(p ->
p.getFileName().toString().toLowerCase().matches("^.*?(.ttf|.otf|.pfb|.ttc)$")).
forEach(p -> files.add(p.toFile()));
} catch (NoSuchFileException e) {
logmsg("Skipping: " + directory);
} catch (IOException e) {
e.getLocalizedMessage();
}
// this essentially is the FontFileFinder.find() part,
// albeit with additional functionality to later identify the font
specifics.
for (File file : files) {
String key = file.getPath();
allFiles.put(key, key.substring(Math.max(0, key.length() -
3)).toUpperCase());
}
}
System.out.println("Total Fonts: " + allFiles.size());
for (Map.Entry entry : allFiles.entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}
}
> Performance issue when filling the first PDTextField of an AcroForm
> -------------------------------------------------------------------
>
> Key: PDFBOX-2871
> URL: https://issues.apache.org/jira/browse/PDFBOX-2871
> Project: PDFBox
> Issue Type: Bug
> Components: AcroForm
> Affects Versions: 2.0.0
> Reporter: Maruan Sahyoun
> Assignee: John Hewson
> Priority: Critical
> Labels: Appearance
> Fix For: 2.0.0
>
> Attachments: PDTextField.pdf, ProfilingOutput.png
>
>
> When filling the first PDTextField in a form the performance is slow. All
> other PDTextFields in the form are handled quickly.
> This code
> {code}
> PDTextField field = (PDTextField)
> doc.getDocumentCatalog().getAcroForm().getField("Textfield01");
> long start = System.nanoTime();
> field.setValue("ABCD");
> long end = System.nanoTime();
> double difference = (end - start)/1e6;
> System.out.println(difference);
> field = (PDTextField)
> doc.getDocumentCatalog().getAcroForm().getField("Textfield02");
> start = System.nanoTime();
> field.setValue("ABCD");
> end = System.nanoTime();
> difference = (end - start)/1e6;
> System.out.println(difference);
> {code}
> produces the following output
> {noformat}
> 9713.38
> 3.904
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]