자바에서 itext API를 사용하여 PDF 문서의 동적 내용을 작성하고 인쇄하고 있습니다.여분의 빈 줄을 제거하십시오
다음은 PDF 문서에 추가해야하는 동적 콘텐츠입니다. 상기 나타낸 샘플 텍스트
This is first line.
This is second line.
This is third printed line.
This is fourth printed line.
#ACC004342-123
More information:
This is fifth printed line.
#ACC004342-123
This is Sixth printed line.
Some information goes here.
는 # ACC004342-123과 추가 정보 사이의 갭들이있다 : 나 제거해야 라인.
public static File createInformationPdf(final List<MyDocumentType> content) throws AccServiceException
{
Document document = null;
FileOutputStream fos = null;
try
{
final String prefix = "letter";
final File myPDF = File.createTempFile(prefix, ".pdf");
document = new Document(PageSize.LETTER);
fos = new FileOutputStream(temporaryPDF);
PdfWriter.getInstance(document, fos);
document.open();
Font font = new Font(Font.FontFamily.COURIER,10);
for (final MyDocumentType myDocument : content)
{
if (myDocument.getDocumentines() != null)
{
final DocumentLinesType documentLines = myDocument.getDocumentLines();
for (final String line : documentLines.getDocumentLine())
{
document.add(new Paragraph(line,font));
}
}
}
document.close();
return temporaryPDF;
}
catch (Exception e)
{
//log the exception
}
}
추신 : 라인과 단지 그들 사이에 하나 개의 빈 줄을 제공 : 위는 난 그냥 빈 # ACC004342-123 및 상세 정보 사이에 존재하는 라인의 많은 수를 제거 하려는, 내 자바 코드입니다. 웹 서비스 호출에서 그 내용을 얻는 동안 내 Java 코드를 처리해야합니다. 희망은 지금 분명하다. 감사.
이것은 이전 질문보다 더 나은 설명입니다. 수여 : 당신은 이제 더러운 코더라고 인정하지만 적어도 지금 당신을 도울 수 있고 당신이 잘못한 것을 설명 할 수 있습니다. 우리는 이제 불필요한 공백을 일으키는 원인을 이해합니다. –