Java/PDF RTF/Paragraph Attributes — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 05:58, 1 июня 2010
Содержание
Paragraph Align Justified
import java.io.FileOutputStream;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class ParagraphAlignJustifiedPDF {
public static void main(String[] args) {
Document document = new Document(PageSize.A4, 50, 350, 50, 50);
try {
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("ParagraphAlignJustifiedPDF.pdf"));
document.open();
String text = "This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.";
Paragraph p = new Paragraph(text);
p.setAlignment(Element.ALIGN_JUSTIFIED);
//p.setAlignment(Element.ALIGN_RIGHT);
//p.setAlignment(Element.ALIGN_MIDDLE);
document.add(p);
document.newPage();
document.add(p);
} catch (Exception de) {
de.printStackTrace();
}
document.close();
}
}
Paragraph Attributes Indent Left Right
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class ParagraphAttributesIndentLeftRightPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("ParagraphAttributesIndentLeftRightPDF.pdf"));
document.open();
Paragraph p = new Paragraph("This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. ");
p.setIndentationLeft(15f);
p.setIndentationRight(5 * 15f);
document.add(p);
} catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}
Paragraph Attributes: SpaceAfter
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class ParagraphAttributesSpaceAfterPDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("ParagraphAttributesSpaceAfterPDF.pdf"));
document.open();
Paragraph p = new Paragraph("This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. ");
p.setSpacingAfter(15f);
document.add(p);
document.add(p);
} catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}
Paragraph Attributes: SpaceBefore
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.Document;
import com.lowagie.text.DocumentException;
import com.lowagie.text.Element;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
public class ParagraphAttributesSpaceBeforePDF {
public static void main(String[] args) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream("ParagraphAttributesSpaceBeforePDF.pdf"));
document.open();
Paragraph p = new Paragraph("This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. ");
p.setSpacingBefore(15f);
document.add(p);
document.add(p);
} catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
}
}