如果行数很多 要考虑分页。 如果是一行想让页面横着看 look 没时间摘了import java.io.FileOutputStream; import java.io.IOException; import com.lowagie.text.*; import com.lowagie.text.pdf.PdfWriter; import com.lowagie.text.html.HtmlWriter;public class Chap0107 { public static void main(String[] args) { System.out.println("Chapter 1 example 7: newPage()"); Document document = new Document(); try { PdfWriter.getInstance(document, new FileOutputStream("Chap0107.pdf")); try { Water water = new Water(Image.getInstance("water.jpg"), 200, 420); document.add(water); } catch(Exception e) { System.err.println("Are you sure you have the file 'water.jpg' in the right path?"); } HeaderFooter header = new HeaderFooter(new Phrase("This is a header"), false); document.setHeader(header); document.open(); document.setPageSize(PageSize.A4.rotate()); try { Water water = new Water(Image.getInstance("water.jpg"), 320, 200); document.add(water); } catch(Exception e) { System.err.println("Are you sure you have the file 'water.jpg' in the right path?"); } HeaderFooter footer = new HeaderFooter(new Phrase("This is page: "), true); document.setFooter(footer);
其次是不是列的宽度不够,一行只能显示一个字,导致竖排。
最后如果以上两个都不是,则请将问题说得再具体一些。:)
如果是一行想让页面横着看 look
没时间摘了import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
import com.lowagie.text.html.HtmlWriter;public class Chap0107 {
public static void main(String[] args) {
System.out.println("Chapter 1 example 7: newPage()");
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("Chap0107.pdf"));
try {
Water water = new Water(Image.getInstance("water.jpg"), 200, 420);
document.add(water);
}
catch(Exception e) {
System.err.println("Are you sure you have the file 'water.jpg' in the right path?");
}
HeaderFooter header = new HeaderFooter(new Phrase("This is a header"), false);
document.setHeader(header);
document.open();
document.setPageSize(PageSize.A4.rotate());
try {
Water water = new Water(Image.getInstance("water.jpg"), 320, 200);
document.add(water);
}
catch(Exception e) {
System.err.println("Are you sure you have the file 'water.jpg' in the right path?");
}
HeaderFooter footer = new HeaderFooter(new Phrase("This is page: "), true);
document.setFooter(footer);
document.add(new Paragraph("Hello World"));
document.newPage();
document.add(new Paragraph("Hello Earth"));
document.resetHeader();
document.newPage();
document.add(new Paragraph("Hello Sun"));
document.add(new Paragraph("Re: the header has vanished!"));
document.resetPageCount();
document.newPage();
document.add(new Paragraph("Hello Moon"));
document.add(new Paragraph("Re: the pagenumber has been reset!"));
}
catch(DocumentException de) {
System.err.println(de.getMessage());
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}
TMD出差结果放下了暂时
我试了 是横向显示
应该是表格宽度的问题
如何搞呢 》
我又开了新贴了
http://expert.csdn.net/Expert/topic/2379/2379266.xml?temp=.9596979
谢谢了 !