.txt
파일 에서 일부 텍스트를 읽고 pdf 파일에 쓰는 중이지만 PDF에서는 텍스트가 더 큰 글꼴로 표시됩니다. .txt
파일 의 글꼴 크기 를 더 크거나 너무 작게 변경했지만 pdf의 글꼴은 동일합니다.
텍스트 파일로 쓰기를 읽는 내 코드의 일부
Document document = new Document(PageSize.A4.rotate(), 36, 36, 80, 160);
........
.........
document.newPage();
//Writing in a default page from the txt file
document.add(new com.lowagie.text.Paragraph("\n"));
iStream = new FileInputStream(path1); //path1 is location of .txt file
in = new DataInputStream(iStream);
is = new InputStreamReader(in);
br = new BufferedReader(is);
String strLine;
while ((strLine = br.readLine()) != null)
{
Paragraph para = new com.lowagie.text.Paragraph(strLine + "\n");
para.setAlignment(Element.ALIGN_JUSTIFIED);
document.add(new com.lowagie.text.Paragraph(strLine + "\n"));
}
br.close();
is.close();
in.close();
iStream.close();
document.close();
writer.close();
현재 Windchill에 타사 라이브러리를 추가 할 수 없기 때문에 itext의 하위 버전을 사용하고 있습니다.이 버전의 itext는 이미 Windchill에 포함되어 있습니다.
PDF 파일에 쓸 때 글꼴 크기를 설정하는 방법.? 어떤 도움이 정말 도움이 될 것입니다.
아주 간단합니다 : D
주먹, 나는 한 가지를 바꿀 것입니다.
while ((strLine = br.readLine()) != null) {
Paragraph para = new com.lowagie.text.Paragraph(strLine + "\n");
para.setAlignment(Element.ALIGN_JUSTIFIED);
document.add(para);
}
이렇게하면 문서에서 단락이 양쪽 정렬됩니다. 당신이 한 방식으로 하나의 paragaph-object의 텍스트 정렬을 변경 한 다음 완전히 다른 새로운 것을 PDF에 추가했습니다.
이제 문제 에 대해 : 다음과 같이 각 단락의 생성자를
지정할 수 있습니다 Font
.
Paragraph para = new com.lowagie.text.Paragraph(strLine + "\n", FontFactory.getFont("Arial", 14f /*This is the size, but as a float!*/);
lowagie API의 전체 문서는 여기 에서 찾을 수 있습니다 .
친애하는
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다