0
굵은 글씨를 pdf 파일의 대문자로 pdfbox 라이브러리를 사용하여 텍스트 파일로 내보내려고합니다. 나는 굵게 표시된 단어 뒤에 빈 줄 하나를 만들고 싶다. PDF 파일 (Dictionary.pdf)에서 볼 수 있듯이 15 페이지부터 시작하여 정의가있는 사전입니다. 단어는 굵게 표시되며 정의에는 일반 글꼴이 사용됩니다.
"사전 출처 :
ΑΒΑθΗΣ
ΑΒΑθΗΣ
ΑΒΑθΕΣ
ΕΠΙΘ : όταν κάτι είναι αβαθές, δεν έχει μεγάλο βάθος (= ρηχός 여기pdf에서 굵은 단어를 추출하십시오.
내가 같이 내 텍스트 파일로 할 방법입니다 , άβαθος ≠ βαθύς). Τα παιδιά μαθαίνουν κολύμπι στα αβαθή νερά .... "여기
이 내 코드 만 해제 다행스럽게도 일반 글꼴과 굵은 글꼴을 구분할 수 없습니다. 코드를 디버깅 한 후에도 대담한 문자가 있더라도 text.getFont(). getFontDescriptor(). isForceBold() false이고 text.getFont(). getFontDescriptor(). getFontWeight() = 0. (이 상황에서) 굵은 텍스트의 글꼴 이름이 그래서 당신을 굵게 단어를 포함하고 있기 때문에 당신은완벽하게 작동
if (text.getFont().getName().contains("Bold") &&wasBold)
을 가진 경우 문
if (text.getFont().getFontDescriptor().isForceBold() ||
text.getFont().getFontDescriptor().getFontWeight() > 680 &&wasBold)
을 대체
public class PDFBoldParser extends PDFTextStripper {
PrintWriter writer;
boolean wasBold=false;
public PDFBoldParser(String filepath) throws IOException{
writer=new PrintWriter(filepath,"UTF-8");
writer.println("Dictionary Source:");
}
@Override
protected void processTextPosition(TextPosition text){
if(text.getFont().getFontDescriptor()!=null){
if (text.getFont().getFontDescriptor().isForceBold() ||
text.getFont().getFontDescriptor().getFontWeight() > 680 &&wasBold) {
writer.print(text.toString().toUpperCase());
wasBold=true;
}
else if(text.getFont().getFontDescriptor().isForceBold() ||
text.getFont().getFontDescriptor().getFontWeight() > 680 &&!wasBold){
writer.println();
writer.print(text.toString().toUpperCase());
wasBold=true;
}
else{
writer.print(text.toString());
wasBold=false;
}
}
}
public void closeParser(){
writer.close();
}
}
글꼴 이름을 볼 수도 있습니다. 때로는 대담한 글꼴에 "굵은 글꼴"이있는 경우가 있습니다 (항상 그런 것은 아닙니다). –
저에게 도움이 된 고마워요 !!! –
코드에 직접 질문에 답하십시오. 나는 오늘 너무 게으르다 :-) –