자바가 절대적으로 알려지지 않았습니다.Java 소스에서 .jar 파일을 만들면 작동하지 않습니다.
PHP를 사용하여 특정 영역에서 텍스트를 추출하는 PDFBox라는 도구를 사용하고 싶습니다.
기본 jar에서는 텍스트 추출을 위해 특정 영역을 선택할 수 없으므로 ExtractTextByArea.java를 가져 와서 .jar 파일을 만들어 PHP에서 자체 매개 변수를 입력하여 원하는 텍스트.
이
사이트에서 된 .java입니다 : 이Error: main class not found
나도 몰라 : 나는 그것에서의 .jar을했다하지만 난 그것을 실행할 때 CMD는 말한다
package org.apache.pdfbox.examples.util;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.text.PDFTextStripperByArea;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
/**
* This is an example on how to extract text from a specific area on the PDF document.
*
* @author Ben Litchfield
*/
public final class ExtractTextByArea
{
private ExtractTextByArea()
{
//utility class and should not be constructed.
}
/**
* This will print the documents text in a certain area.
*
* @param args The command line arguments.
*
* @throws IOException If there is an error parsing the document.
*/
public static void main(String[] args) throws IOException
{
if(args.length != 1)
{
usage();
}
else
{
PDDocument document = null;
try
{
document = PDDocument.load(new File(args[0]));
PDFTextStripperByArea stripper = new PDFTextStripperByArea();
stripper.setSortByPosition(true);
Rectangle rect = new Rectangle(10, 280, 275, 60);
stripper.addRegion("class1", rect);
PDPage firstPage = document.getPage(0);
stripper.extractRegions(firstPage);
System.out.println("Text in the area:" + rect);
System.out.println(stripper.getTextForRegion("class1"));
}
finally
{
if(document != null)
{
document.close();
}
}
}
}
/**
* This will print the usage for this document.
*/
private static void usage()
{
System.err.println("Usage: java " + ExtractTextByArea.class.getName() + " <input-pdf>");
}
}
계속가는 법.
어떻게 JAR을 만들었습니까? 먼저 소스 코드를 컴파일해야합니다. JAR에 소스 코드를 넣으면 작동하지 않습니다. Java로 작업하는 방법을 배우려면 [Oracle Java 자습서] (https://docs.oracle.com/javase/tutorial/)를 참조하십시오. 우리는 당신에게 완벽한 절대 초보 자바 튜토리얼을 여기 게시 할 수는 없습니다. – Jesper
jar 파일을 실행하려면 main 메소드가 필요합니다 ... manifest 파일이 main 메소드의 위치를 제공하는지 확인한 다음 jar 파일을 다시 빌드하십시오. – Abhishek
어떻게'jar' 파일을 실행하려고합니까? 그것은'java -cp myjar.jar full.classified.class.name.with.main.method.Class' 또는'java -jar myjar.jar' 중 하나 여야합니다. 두번째 경우에 당신은 메인 클래스를' MANIFEST' 파일을 jar 파일에 저장합니다. – Antoniossss