일부 이미지 (.jpg)와 소스 파일의 텍스트를 읽고 단일 PDF로 어셈블하는 프로그램에서 작업하고 있습니다. 프로세싱을하는 것이 아마도 최선의 언어는 아니지만 처리 방법을 알고있는 유일한 방법입니다. 어쨌든 처리 과정에서 두 번 호출되는 문제가 있습니다. 이 문제는 size()가 셋업의 첫 번째 라인 일 때 해결되는 것을 보았습니다.하지만 모든 데이터를 읽고 저장해야하며, 가장 넓은 이미지의 너비를 찾은 다음 그럴 수 없습니다. 창문이 얼마나 넓고 높이가 나는지 결정하기 전에 텍스트가 하나 이상인 이미지를 두 개 이상 넣을 수있을 정도로 키가 큰 지 확인하십시오. 두 번 설정을 호출하지 않고 모든 정보를 얻을 수 있도록 코드를 구조화 할 수있는 방법에 대한 제안을 찾고 있는데, 이는 내 PDF에 모든 데이터의 두 복사본이 포함되어 있기 때문입니다. 누군가에게 도움이된다면 설치 프로그램을 포함 시켰습니다. 감사!void setup()을 두 번 호출하고 처리해야합니다.
void setup(){
font = loadFont("TimesNewRomanPSMT-20.vlw");
File clientsFolder = new File("C:/Users/[my name]/Documents/Processing/ExerciseProgram/Clients");
clients = clientsFolder.listFiles();
for(File x : clients){
println(x.getName());
}
//test files to see if they end in .txt, and have a matching .pdf extension that is newer
String nextClient = needPdf();
File nextClientData = new File("C:/Users/[my name]/Documents/Processing/ExerciseProgram/Clients/" + nextClient);
//println(nextClientData.getName());
//open the file for reading
//setup can't throw the exception, and it needs it, so this should take care of it
try{
Scanner scan = new Scanner(nextClientData);
while(scan.hasNextLine()){
exercises.add(scan.nextLine());
}
//println(exercises.toString());
printedData = new Exercise[exercises.size()];
println(exercises.size());
for(int i = 0; i < exercises.size(); i++){
printedData[i] = new Exercise((String)exercises.get(i));
}
//count the width and height
int w = 0, h = 0;
for(Exercise e: printedData){
if(e.getWidest() > w){
w = e.getWidest();
}
if(e.getTallest() > h){
h = e.getHeight();
}
}
//and finally we can create the freaking window
// this cuts the .txt off
size(w, h, PDF, "C:/Users/[my name]/Desktop/" + nextClient.substring(0, nextClient.length() - 4) + ".pdf");
}catch (FileNotFoundException e){
println("Unknown error in PApplet.setup(). Exiting.");
println(e.getMessage());
exit();
}
}
사용중인 언어로 질문에 태그를 답장하십시오. – Chris
나는 그 태그를 처리했다. – user2309865