【JSP开源代码栏目提醒】:网学会员在JSP开源代码频道为大家收集整理了EX13-9.jsp提供大家参考,希望对大家有所帮助!
<%@page import="java.io.*,
com.lowagie.text.*,
com.lowagie.text.pdf.*"
%><%
response.setContentType( "application/pdf" );
Document document = new Document(PageSize.A5, 36, 72, 108, 180);
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
PdfWriter.getInstance( document, buffer );
document.open();
document.add(new Paragraph("The left margin of this document is 36pt (0.5 inch); the right margin 72pt (1 inch); the top margin 108pt (1.5 inch); the bottom margin 180pt (2.5 inch). "));
Paragraph paragraph = new Paragraph();
paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
for (int i = 0; i < 20; i++) {
paragraph.add("Hello World, Hello Sun, Hello Moon, Hello Stars, Hello Sea, Hello Land, Hello People. ");
}
document.add(paragraph);
document.setMargins(180, 108, 72, 36);
document.add(new Paragraph("Now we change the margins. You will see the effect on the next page."));
document.add(paragraph);
document.setMarginMirroring(true);
document.add(new Paragraph("Starting on the next page, the margins will be mirrored."));
document.add(paragraph);
document.close();
DataOutput output = new DataOutputStream( response.getOutputStream() );
byte[] bytes = buffer.toByteArray();
response.setContentLength(bytes.length);
for( int i = 0; i < bytes.length; i++ ) { output.writeByte( bytes[i] ); }
%>
上一篇:
EX13-8.jsp
下一篇:
哈弗F7 VS名爵HS,谁更懂得年轻人的心?