當前位置: 首頁>>代碼示例>>Java>>正文


Java Document類代碼示例

本文整理匯總了Java中rst.pdfbox.layout.elements.Document的典型用法代碼示例。如果您正苦於以下問題:Java Document類的具體用法?Java Document怎麽用?Java Document使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Document類屬於rst.pdfbox.layout.elements包,在下文中一共展示了Document類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: render

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
@Override
public void render(Document target, int indent, CertificateStyle style) throws IOException {
    
    int offset = indent * style.getListIndent();
    for (Element item : items) {
        if (item instanceof ElementList) {
            ((ElementList)item).render(target, indent+1, style);
        } else if (item instanceof ElementText) {
            Paragraph paragraph = new Paragraph();
            paragraph.add(new Indent(getListItemIndicator(indent), offset, SpaceUnit.pt, style.getTextSize(),
                                     getListItemIndicatorFont(style).getPlainFont(), Alignment.Right));
            paragraph.addMarkup(((ElementText)item).getText(), style.getTextSize(), style.getTextFont());
            target.add(paragraph);
        } else {
            throw new IllegalStateException("Unsupported element");
        }
    }
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:19,代碼來源:ElementList.java

示例2: save

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
/**
 * Renders the document into the given output stream
 * 
 * @param stream
 * @throws IOException 
 */
public void save(OutputStream stream) throws IOException {
    
    // Render
    Document document = new Document(style.gethMargin(), style.gethMargin(), style.getvMargin(), style.getvMargin());
    for (Element element : this.elements) {
        element.render(document, 0, this.style);
    }
    
    // Save to temp file
    File tmp = File.createTempFile("arx", "certificate");
    document.save(tmp);
    
    // Load and watermark
    PDDocument pdDocument = PDDocument.load(tmp);
    Watermark watermark = new Watermark(pdDocument);
    watermark.mark(pdDocument);
    
    // Save
    pdDocument.save(stream);
    pdDocument.close();
    tmp.delete();
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:29,代碼來源:ARXCertificate.java

示例3: main

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
Document document = new Document(40, 60, 40, 60);

Paragraph paragraph = new Paragraph();
paragraph.addText("Hello Document", 20,
	PDType1Font.HELVETICA);
document.add(paragraph);

final OutputStream outputStream = new FileOutputStream("hellodoc.pdf");
document.save(outputStream);

   }
 
開發者ID:ralfstuckert,項目名稱:pdfbox-layout,代碼行數:13,代碼來源:HelloDoc.java

示例4: render

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
@Override
public void render(Document target, int indent, CertificateStyle style) throws IOException {
    Paragraph paragraph = new Paragraph() {
        @Override public float getHeight() throws IOException {
            return super.getHeight() * 2f;
        }
    };
    paragraph.setAlignment(style.getTitleAlignment());
    paragraph.addText(text, style.getTitleSize(), style.getTitleFont().getBoldFont());
    target.add(paragraph, VerticalLayoutHint.LEFT);
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:12,代碼來源:ElementTitle.java

示例5: TitleBlockWriter

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
public TitleBlockWriter(TitleBlockData pData) {
    data = pData;
    document = new Document(PAGE_MARGIN_LEFT, PAGE_MARGIN_RIGHT, PAGE_MARGIN_TOP, PAGE_MARGIN_BOTTOM);
    loadIconFont();
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:6,代碼來源:TitleBlockWriter.java

示例6: documentToByteArray

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
private byte[] documentToByteArray(Document document) throws IOException {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    document.save(out);
    return out.toByteArray();
}
 
開發者ID:polarsys,項目名稱:eplmp,代碼行數:6,代碼來源:TitleBlockWriter.java

示例7: main

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
String text1 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
	+ "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna "
	+ "aliquyam erat, _sed diam_ voluptua. At vero eos et *accusam et justo* "
	+ "duo dolores et ea rebum.\n\nStet clita kasd gubergren, no sea takimata "
	+ "sanctus est *Lorem ipsum _dolor* sit_ amet. Lorem ipsum dolor sit amet, "
	+ "consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt "
	+ "ut labore et dolore magna aliquyam erat, *sed diam voluptua.\n\n"
	+ "At vero eos et accusam* et justo duo dolores et ea rebum. Stet clita kasd "
	+ "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n\n";

String text2 = "At *vero eos et accusam* et justo duo dolores et ea rebum."
	+ "Stet clita kasd gubergren, no sea takimata\n\n"
	+ "sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, "
	+ "_consetetur sadipscing elitr_, sed diam nonumy eirmod tempor invidunt "
	+ "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero "
	+ "eos et _accusam et *justo* duo dolores_ et ea rebum. Stet clita kasd "
	+ "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n";

Document document = new Document(40, 60, 40, 60);

Paragraph paragraph1 = new Paragraph();
paragraph1.addMarkup(text1, 11, BaseFont.Times);
document.add(paragraph1);

Paragraph paragraph2 = new Paragraph();
paragraph2.addMarkup(text2, 12, BaseFont.Helvetica);
document.add(paragraph2);

Paragraph paragraph3 = new Paragraph();
paragraph3.addMarkup(text1, 8, BaseFont.Courier);
document.add(paragraph3);

document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph1);
document.add(paragraph2);
document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph2);
document.add(paragraph1);
document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph2);
document.add(paragraph2);
document.add(paragraph3);
document.add(paragraph1);
document.add(paragraph1);
document.add(paragraph2);
document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph2);
document.add(paragraph3);
document.add(paragraph1);
document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph2);
document.add(paragraph2);

final OutputStream outputStream = new FileOutputStream(
	"multiplepages.pdf");
document.save(outputStream);

   }
 
開發者ID:ralfstuckert,項目名稱:pdfbox-layout,代碼行數:65,代碼來源:MultiplePages.java

示例8: main

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
String text1 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
	+ "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna "
	+ "aliquyam erat, _sed diam_ voluptua. At vero eos et *accusam et justo* "
	+ "duo dolores et ea rebum.\n\nStet clita kasd gubergren, no sea takimata "
	+ "sanctus est *Lorem ipsum _dolor* sit_ amet. Lorem ipsum dolor sit amet, "
	+ "consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt "
	+ "ut labore et dolore magna aliquyam erat, *sed diam voluptua.\n\n"
	+ "At vero eos et accusam* et justo duo dolores et ea rebum. Stet clita kasd "
	+ "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n\n";

String text2 = "At *vero eos et accusam* et justo duo dolores et ea rebum."
	+ "Stet clita kasd gubergren, no sea takimata\n\n"
	+ "sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, "
	+ "_consetetur sadipscing elitr_, sed diam nonumy eirmod tempor invidunt "
	+ "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero "
	+ "eos et _accusam et *justo* duo dolores_ et ea rebum. Stet clita kasd "
	+ "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n";

Document document = new Document(40, 60, 40, 60);
SectionRenderer sectionRenderer = new SectionRenderer();
document.addRenderer(sectionRenderer);
document.addRenderListener(sectionRenderer);

Paragraph paragraph = new Paragraph();
paragraph.addMarkup(text1, 11, BaseFont.Times);
paragraph.addMarkup(text2, 12, BaseFont.Helvetica);
paragraph.addMarkup(text1, 8, BaseFont.Courier);

document.add(new Section(1));
document.add(paragraph);
document.add(paragraph);
document.add(paragraph);
document.add(new Section(2));
document.add(paragraph);
document.add(paragraph);
document.add(paragraph);
document.add(new Section(3));
document.add(paragraph);
document.add(paragraph);

final OutputStream outputStream = new FileOutputStream("customrenderer.pdf");
document.save(outputStream);

   }
 
開發者ID:ralfstuckert,項目名稱:pdfbox-layout,代碼行數:46,代碼來源:CustomRenderer.java

示例9: main

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
String text1 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
	+ "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna "
	+ "aliquyam erat, _sed diam_ voluptua. At vero eos et *accusam et justo* "
	+ "duo dolores et ea rebum.\n\nStet clita kasd gubergren, no sea takimata "
	+ "sanctus est *Lorem ipsum _dolor* sit_ amet. Lorem ipsum dolor sit amet, "
	+ "consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt "
	+ "ut labore et dolore magna aliquyam erat, *sed diam voluptua.\n\n"
	+ "At vero eos et accusam* et justo duo dolores et ea rebum. Stet clita kasd "
	+ "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n\n";

String text2 = "At *vero {link[#hello]}eos{link} et accusam* et justo duo dolores et ea rebum."
	+ "Stet clita kasd gubergren, no sea takimata\n\n"
	+ "sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, "
	+ "_consetetur sadipscing elitr_, sed diam nonumy eirmod tempor invidunt "
	+ "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero "
	+ "eos et _accusam et *justo* duo dolores_ et ea rebum. Stet clita kasd "
	+ "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n";

Document document = new Document(40, 60, 40, 60);


Paragraph paragraph0 = new Paragraph();
paragraph0.addMarkup("This is a link to {link[https://github.com/ralfstuckert/pdfbox-layout]}PDFBox-Layout{link}.\n\n", 11, BaseFont.Times);
paragraph0.addMarkup("Now the same link with color instead of underline {color:#ff5000}{link:none[https://github.com/ralfstuckert/pdfbox-layout]}PDFBox-Layout{link}{color:#000000}.\n\n", 11, BaseFont.Times);
paragraph0.addMarkup("And here comes a link to an internal anchor name {color:#ff5000}{link[#hello]}hello{link}{color:#000000}.\n\n", 11, BaseFont.Times);
document.add(paragraph0);

Paragraph paragraph1 = new Paragraph();
paragraph1.addMarkup(text1, 11, BaseFont.Times);
document.add(paragraph1);

Paragraph paragraph2 = new Paragraph();
paragraph2.addMarkup(text2, 12, BaseFont.Helvetica);
document.add(paragraph2);

Paragraph paragraph3 = new Paragraph();
paragraph3.addMarkup(text1, 8, BaseFont.Courier);
document.add(paragraph3);

Paragraph paragraph4 = new Paragraph();
paragraph4.addMarkup("\n\n{anchor:hello}Here{anchor} comes the internal anchor named *hello*\n\n", 15, BaseFont.Courier);

document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph1);
document.add(paragraph2);
document.add(paragraph1);
document.add(paragraph3);

document.add(paragraph4);

document.add(paragraph2);
document.add(paragraph1);
document.add(paragraph1);

final OutputStream outputStream = new FileOutputStream(
	"links.pdf");
document.save(outputStream);

   }
 
開發者ID:ralfstuckert,項目名稱:pdfbox-layout,代碼行數:62,代碼來源:Links.java

示例10: main

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
String text = "*Lorem ipsum* dolor sit amet, consetetur sadipscing elitr, "
	+ "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna "
	+ "aliquyam erat, _sed diam_ voluptua. At vero eos et _accusam et justo_ "
	+ "duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata "
	+ "sanctus est _Lorem ipsum dolor sit_ amet. Lorem ipsum dolor sit amet, "
	+ "consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt "
	+ "ut labore et dolore magna aliquyam erat, sed diam.";

// create document without margins
Document document = new Document();
document.add(new ColumnLayout(2, 5));

Paragraph left = new Paragraph();
// no line spacing for the first line
left.setApplyLineSpacingToFirstLine(false);
// use a bigger line spacing to visualize the effects of line spacing more drastically
left.setLineSpacing(1.5f);
left.setMaxWidth(document.getPageWidth()/2);
left.addMarkup(text, 11, BaseFont.Times);
document.add(left);

document.add(left);
document.add(left);

document.add(ColumnLayout.NEWCOLUMN);

Paragraph right = new Paragraph();
right.setLineSpacing(1.5f);
right.setMaxWidth(document.getPageWidth()/2);
right.addMarkup(text, 11, BaseFont.Times);
document.add(right);

document.add(right);
document.add(right);

final OutputStream outputStream = new FileOutputStream(
	"linespacing.pdf");
document.save(outputStream);

   }
 
開發者ID:ralfstuckert,項目名稱:pdfbox-layout,代碼行數:42,代碼來源:LineSpacing.java

示例11: main

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
String text1 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, "
	+ "sed diam nonumy eirmod tempor invidunt ut labore et dolore magna "
	+ "aliquyam erat, _sed diam_ voluptua. At vero eos et *accusam et justo* "
	+ "duo dolores et ea rebum.\n\nStet clita kasd gubergren, no sea takimata "
	+ "sanctus est *Lorem ipsum _dolor* sit_ amet. Lorem ipsum dolor sit amet, "
	+ "consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt "
	+ "ut labore et dolore magna aliquyam erat, *sed diam voluptua.\n\n"
	+ "At vero eos et accusam* et justo duo dolores et ea rebum. Stet clita kasd "
	+ "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n\n";

String text2 = "At *vero eos et accusam* et justo duo dolores et ea rebum. "
	+ "Stet clita kasd gubergren, no sea takimata\n\n"
	+ "sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, "
	+ "_consetetur sadipscing elitr_, sed diam nonumy eirmod tempor invidunt "
	+ "ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero "
	+ "eos et _accusam et *justo* duo dolores_ et ea rebum. Stet clita kasd "
	+ "gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.\n";

Document document = new Document(40, 50, 40, 60);

Paragraph title = new Paragraph();
title.addMarkup("*This Text is organized in Colums*", 20, BaseFont.Times);
document.add(title, VerticalLayoutHint.CENTER);
document.add(new VerticalSpacer(5));

// use column layout from now on
document.add(new ColumnLayout(2, 10));

Paragraph paragraph1 = new Paragraph();
paragraph1.addMarkup(text1, 11, BaseFont.Times);
document.add(paragraph1);

Paragraph paragraph2 = new Paragraph();
paragraph2.addMarkup(text2, 12, BaseFont.Helvetica);
document.add(paragraph2);

Paragraph paragraph3 = new Paragraph();
paragraph3.addMarkup(text1, 8, BaseFont.Courier);
document.add(paragraph3);

document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph1);
document.add(paragraph2);
document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph2);
document.add(paragraph1);
document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph2);
document.add(paragraph2);
document.add(paragraph3);
document.add(paragraph1);
document.add(paragraph1);
document.add(paragraph2);
document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph2);
document.add(paragraph3);
document.add(paragraph1);
document.add(paragraph1);
document.add(paragraph3);
document.add(paragraph2);
document.add(paragraph2);

final OutputStream outputStream = new FileOutputStream(
	"columns.pdf");
document.save(outputStream);

   }
 
開發者ID:ralfstuckert,項目名稱:pdfbox-layout,代碼行數:73,代碼來源:Columns.java

示例12: getDocument

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
/**
    * @return the document.
    */
   public Document getDocument() {
return document;
   }
 
開發者ID:ralfstuckert,項目名稱:pdfbox-layout,代碼行數:7,代碼來源:RenderContext.java

示例13: render

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
@Override
public void render(Document target, int indent, CertificateStyle style) throws IOException {
    Paragraph paragraph = new Paragraph();
    paragraph.addText(text, style.getSubtitleSize(), style.getSubtitleFont().getBoldFont());
    target.add(paragraph);
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:7,代碼來源:ElementSubtitle.java

示例14: render

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
@Override
public void render(Document target, int indent, CertificateStyle style) throws IOException {
    target.add(ControlElement.NEWPAGE);
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:5,代碼來源:ElementPageBreak.java

示例15: render

import rst.pdfbox.layout.elements.Document; //導入依賴的package包/類
@Override
public void render(Document target, int indent, CertificateStyle style) throws IOException {
    target.add(new VerticalSpacer(space));
}
 
開發者ID:arx-deidentifier,項目名稱:arx,代碼行數:5,代碼來源:ElementVerticalSpace.java


注:本文中的rst.pdfbox.layout.elements.Document類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。