Java/PDF RTF/New Page — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 06:00, 1 июня 2010
Содержание
Adding: NewPage, Chunk.NEXTPAGE
import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class NewPageChunkNEXTPAGEPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NewPageChunkNEXTPAGEPDF.pdf"));
document.open();
document.add(new Paragraph("A"));
document.newPage();
document.add(new Paragraph("B"));
document.newPage();
document.add(Chunk.NEXTPAGE);
document.add(new Paragraph("C"));
} catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}
Creating a New Page for PDF document
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class CreatingANewPagePDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("CreatingANewPagePDF.pdf"));
document.open();
document.add(new Paragraph("First Page."));
document.setPageSize(PageSize.A3);
document.newPage();
document.add(new Paragraph("This PageSize is A3."));
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}
New Empty Page
import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class NewPagePageEmptyPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("NewPagePageEmptyPDF.pdf"));
document.open();
document.add(new Paragraph("A"));
document.newPage();
document.add(new Paragraph("B"));
document.newPage();
document.add(Chunk.NEWLINE);
document.newPage();
document.newPage();
document.add(new Paragraph("C"));
} catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}
Starting a new Page
import java.io.FileOutputStream;
import com.lowagie.text.Chunk;
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class NewPageToStartANewPagePDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("NewPageToStartANewPagePDF.pdf"));
document.open();
document.add(new Paragraph("A"));
document.newPage();
document.add(new Paragraph("B"));
document.newPage();
document.newPage();
document.newPage();
document.add(new Paragraph("C"));
} catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}