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


Java PageSize類代碼示例

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


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

示例1: createDoc

import com.lowagie.text.PageSize; //導入依賴的package包/類
public void createDoc() throws FileNotFoundException{
	 /** 創建Document對象(word文檔)  */
       Rectangle rectPageSize = new Rectangle(PageSize.A4);
       rectPageSize = rectPageSize.rotate();
       // 創建word文檔,並設置紙張的大小
       doc = new Document(PageSize.A4);
       file=new File(path+docFileName);
       fileOutputStream=new FileOutputStream(file);
       /** 建立一個書寫器與document對象關聯,通過書寫器可以將文檔寫入到輸出流中 */
       RtfWriter2.getInstance(doc, fileOutputStream );
       doc.open();
       //設置頁邊距,上、下25.4毫米,即為72f,左、右31.8毫米,即為90f  
       doc.setMargins(90f, 90f, 72f, 72f);
       //設置標題字體樣式,粗體、二號、華文中宋  
       tfont  = DocStyleUtils.setFontStyle("華文中宋", 22f, Font.BOLD);  
       //設置正文內容的字體樣式,常規、三號、仿宋_GB2312  
       bfont = DocStyleUtils.setFontStyle("仿宋_GB2312", 16f, Font.NORMAL);
}
 
開發者ID:wkeyuan,項目名稱:DWSurvey,代碼行數:19,代碼來源:DocExportUtil.java

示例2: export

import com.lowagie.text.PageSize; //導入依賴的package包/類
public void export(OutputStream out) throws Exception {
    int nrCols = getNrColumns();
    iDocument = (iForm.getDispMode()==sDispModeInRowHorizontal || iForm.getDispMode()==sDispModeInRowVertical ?
        new Document(new Rectangle(Math.max(PageSize.LETTER.getWidth(),60.0f+100.0f*nrCols),Math.max(PageSize.LETTER.getHeight(),60.0f+150f*nrCols)).rotate(), 30, 30, 30, 30)
    :
        new Document(new Rectangle(Math.max(PageSize.LETTER.getWidth(),60.0f+100.0f*nrCols),Math.max(PageSize.LETTER.getHeight(),60.0f+150f*nrCols)), 30, 30, 30, 30));

    PdfEventHandler.initFooter(iDocument, out);
    iDocument.open();
    
    printTable();

    printLegend();

    iDocument.close();
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:17,代碼來源:PdfExamGridTable.java

示例3: pdfTableForInstructionalOfferings

import com.lowagie.text.PageSize; //導入依賴的package包/類
public void pdfTableForInstructionalOfferings(
  		OutputStream out,
          ClassAssignmentProxy classAssignment,
          ExamAssignmentProxy examAssignment,
          InstructionalOfferingListForm form, 
          String[] subjectAreaIds, 
          SessionContext context,
          boolean displayHeader,
          boolean allCoursesAreGiven) throws Exception{
  	
  	setVisibleColumns(form);
  	
  	iDocument = new Document(PageSize.A4, 30f, 30f, 30f, 30f); 
iWriter = PdfEventHandler.initFooter(iDocument, out);

  	for (String subjectAreaId: subjectAreaIds) {
      	pdfTableForInstructionalOfferings(out, classAssignment, examAssignment,
      			form.getInstructionalOfferings(Long.valueOf(subjectAreaId)), 
      			Long.valueOf(subjectAreaId),
      			context,
      			displayHeader, allCoursesAreGiven,
      			new ClassCourseComparator(form.getSortBy(), classAssignment, false));
  	}
 	
iDocument.close();
  }
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:27,代碼來源:PdfInstructionalOfferingTableBuilder.java

示例4: open

import com.lowagie.text.PageSize; //導入依賴的package包/類
public void open(OutputStream out, int mode) throws DocumentException, IOException {
    iOut = out;
    if (mode==sModeText) {
        iPrint = new PrintWriter(iOut);
    } else {
        iNrLines = (mode==sModeLedger?116:50);
        iDoc = new Document(mode==sModeLedger?PageSize.LEDGER.rotate():PageSize.LETTER.rotate());

        PdfWriter.getInstance(iDoc, iOut);

        iDoc.addTitle(iTitle);
        iDoc.addAuthor("UniTime "+Constants.getVersion()+", www.unitime.org");
        iDoc.addSubject(iSubject);
        iDoc.addCreator("UniTime "+Constants.getVersion()+", www.unitime.org");

        iDoc.open();
    }
    iEmpty = true;
    iPageNo = 0; iLineNo = 0;
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:21,代碼來源:PdfLegacyReport.java

示例5: main

import com.lowagie.text.PageSize; //導入依賴的package包/類
/**
 * Draws arabic text using java.awt.Graphics2D.
    */
@Test
public void main() throws Exception {
   	// step 1
       Document document = new Document(PageSize.A4, 50, 50, 50, 50);
       try {
       	// step 2
           PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream( "arabictext.pdf"));
           // step 3
           document.open();
           // step 4
           String text1 = "This text has \u0634\u0627\u062f\u062c\u0645\u0647\u0648\u0631 123,456 \u0645\u0646 (Arabic)";
           java.awt.Font font = new java.awt.Font("arial", 0, 18);
           PdfContentByte cb = writer.getDirectContent();
           java.awt.Graphics2D g2 = cb.createGraphicsShapes(PageSize.A4.getWidth(), PageSize.A4.getHeight());
           g2.setFont(font);
           g2.drawString(text1, 100, 100);
           g2.dispose();
           cb.sanityCheck();
           // step 5
           document.close();
       }
       catch (Exception de) {
           de.printStackTrace();
       }
   }
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:29,代碼來源:ArabicTextTest.java

示例6: main

import com.lowagie.text.PageSize; //導入依賴的package包/類
/**
    * Generates a document with a header containing Page x of y and with a Watermark on every page.
    */
@Test
public void main() throws Exception {
       	// step 1: creating the document
           Document doc = new Document(PageSize.A4, 50, 50, 100, 72);
           // step 2: creating the writer
           PdfWriter writer = PdfWriter.getInstance(doc, PdfTestBase.getOutputStream( "pageNumbersWatermark.pdf"));
           // step 3: initialisations + opening the document
           writer.setPageEvent(new PageNumbersWatermarkTest());
           doc.open();
           // step 4: adding content
           String text = "some padding text ";
           for (int k = 0; k < 10; ++k) {
               text += text;
           }
           Paragraph p = new Paragraph(text);
           p.setAlignment(Element.ALIGN_JUSTIFIED);
           doc.add(p);
           // step 5: closing the document
           doc.close();
       
   }
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:25,代碼來源:PageNumbersWatermarkTest.java

示例7: main

import com.lowagie.text.PageSize; //導入依賴的package包/類
@Test
public void main() throws Exception {

	Document document = new Document(PageSize.A4, 50, 50, 50, 50);
	PdfWriter writer = PdfWriter.getInstance(document,	PdfTestBase.getOutputStream( "shading.pdf"));
	document.open();

	PdfFunction function1 = PdfFunction.type2(writer, new float[] { 0, 1 },
			null, new float[] { .929f, .357f, 1, .298f }, new float[] {
					.631f, .278f, 1, .027f }, 1.048f);
	PdfFunction function2 = PdfFunction.type2(writer, new float[] { 0, 1 },
			null, new float[] { .929f, .357f, 1, .298f }, new float[] {
					.941f, .4f, 1, .102f }, 1.374f);
	PdfFunction function3 = PdfFunction.type3(writer, new float[] { 0, 1 },
			null, new PdfFunction[] { function1, function2 },
			new float[] { .708f }, new float[] { 1, 0, 0, 1 });
	PdfShading shading = PdfShading.type3(writer,
			new CMYKColor(0, 0, 0, 0),
			new float[] { 0, 0, .096f, 0, 0, 1 }, null, function3,
			new boolean[] { true, true });
	PdfContentByte cb = writer.getDirectContent();
	cb.moveTo(316.789f, 140.311f);
	cb.curveTo(303.222f, 146.388f, 282.966f, 136.518f, 279.122f, 121.983f);
	cb.lineTo(277.322f, 120.182f);
	cb.curveTo(285.125f, 122.688f, 291.441f, 121.716f, 298.156f, 119.386f);
	cb.lineTo(336.448f, 119.386f);
	cb.curveTo(331.072f, 128.643f, 323.346f, 137.376f, 316.789f, 140.311f);
	cb.clip();
	cb.newPath();
	cb.saveState();
	cb.concatCTM(27.7843f, 0, 0, -27.7843f, 310.2461f, 121.1521f);
	cb.paintShading(shading);
	cb.restoreState();

	cb.sanityCheck();

	document.close();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:39,代碼來源:ShadingTest.java

示例8: main

import com.lowagie.text.PageSize; //導入依賴的package包/類
/**
 * Generates an Acroform with a Combobox
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document(PageSize.A4);

	// step 2:
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("combo.pdf"));

	// step 3: we open the document
	document.open();

	// step 4:
	PdfContentByte cb = writer.getDirectContent();
	cb.moveTo(0, 0);
	String options[] = { "Red", "Green", "Blue" };
	PdfFormField field = PdfFormField.createCombo(writer, true, options, 0);
	field.setWidget(new Rectangle(100, 700, 180, 720), PdfAnnotation.HIGHLIGHT_INVERT);
	field.setFieldName("ACombo");
	field.setValueAsString("Red");
	writer.addAnnotation(field);

	// step 5: we close the document
	document.close();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:29,代碼來源:FormComboTest.java

示例9: main

import com.lowagie.text.PageSize; //導入依賴的package包/類
/**
 * Adds some annotated images to a PDF file.
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document(PageSize.A4, 50, 50, 50, 50);
	// step 2:
	// we create a writer that listens to the document
	PdfWriter.getInstance(document, PdfTestBase.getOutputStream("annotated_images.pdf"));
	// step 3: we open the document
	document.open();
	// step 4: we add some content
	Image jpeg = Image.getInstance(PdfTestBase.RESOURCES_DIR + "otsoe.jpg");
	jpeg.setAnnotation(new Annotation("picture", "This is my dog", 0, 0, 0, 0));
	jpeg.setAbsolutePosition(100f, 550f);
	document.add(jpeg);
	Image wmf = Image.getInstance(PdfTestBase.RESOURCES_DIR + "iText.wmf");
	wmf.setAnnotation(new Annotation(0, 0, 0, 0, "http://www.lowagie.com/iText"));
	wmf.setAbsolutePosition(100f, 200f);
	document.add(wmf);

	// step 5: we close the document
	document.close();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:27,代碼來源:AnnotatedImageTest.java

示例10: main

import com.lowagie.text.PageSize; //導入依賴的package包/類
/**
 * Space Word Ratio.
 */
@Test
public void main() throws Exception {
	// step 1
	Document document = new Document(PageSize.A4, 50, 350, 50, 50);
	// step 2
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("spacewordratio.pdf"));
	// step 3
	document.open();
	// step 4
	String text = "Flanders International Filmfestival Ghent - Internationaal Filmfestival van Vlaanderen Gent";
	Paragraph p = new Paragraph(text);
	p.setAlignment(Element.ALIGN_JUSTIFIED);
	document.add(p);
	document.newPage();
	writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
	document.add(p);

	// step 5
	document.close();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:24,代碼來源:SpaceWordRatioTest.java

示例11: main

import com.lowagie.text.PageSize; //導入依賴的package包/類
/**
 * Break a large table up into several smaller tables for memory management
 * purposes.
 * 
 */
@Test
public void main() throws Exception {
	// step1
	Document document = new Document(PageSize.A4, 10, 10, 10, 10);
	// step2
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("SplitTable.pdf"));
	// step3
	document.open();
	// step4

	PdfContentByte cb = writer.getDirectContent();
	PdfPTable table = new PdfPTable(10);
	for (int k = 1; k <= 100; ++k) {
		table.addCell("The number " + k);
	}
	table.setTotalWidth(800);
	table.writeSelectedRows(0, 5, 0, -1, 50, 650, cb);
	document.newPage();
	table.writeSelectedRows(5, -1, 0, -1, 50, 650, cb);
	document.close();

	// step5
	document.close();
}
 
開發者ID:albfernandez,項目名稱:itext2,代碼行數:30,代碼來源:SplitTableTest.java

示例12: generate

import com.lowagie.text.PageSize; //導入依賴的package包/類
public void generate(OutputStream os) throws Exception
{
	document = new Document(PageSize.A4, 36, 36, 36, 50);
	writer = PdfWriter.getInstance(document,os);		
	writer.setEncryption(null, null, PdfWriter.AllowCopy | PdfWriter.AllowPrinting, PdfWriter.STRENGTH40BITS);
	writer.setPageEvent(new EndPage(this.getCabecera(),this.getPie(),this.getBarcode(),this.isPaginar()));		
	document.open();				
	//Pintar la cabecera que proceda: No pitar, cabecera normal o cabecera peque�a
	if(!noCabecera) {
		if (tipocabecera.equals(TYPE_HEAD_SMALL)) writeCabecera2();
		else writeCabecera();
	}

	
	for(int i=0; i<secciones.size(); i++)
	{
		Seccion obj = (Seccion)secciones.get(i);
		obj.write(this);
	}		
	
	document.close();
}
 
開發者ID:GovernIB,項目名稱:sistra,代碼行數:23,代碼來源:PDFDocument.java

示例13: OscarChartPrinter

import com.lowagie.text.PageSize; //導入依賴的package包/類
public OscarChartPrinter(HttpServletRequest request, OutputStream os) throws DocumentException,IOException {
	this.request = request;
	this.os = os;

	document = new Document();
	// writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
	
    writer = PdfWriter.getInstance(document,os);
	writer.setPageEvent(new EndPage());
	document.setPageSize(PageSize.LETTER);
	document.open();
	//Create the font we are going to print to
       bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
       font = new Font(bf, FONTSIZE, Font.NORMAL);
       boldFont = new Font(bf,FONTSIZE,Font.BOLD);
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:17,代碼來源:OscarChartPrinter.java

示例14: PdfRecordPrinter

import com.lowagie.text.PageSize; //導入依賴的package包/類
public PdfRecordPrinter(HttpServletRequest request, OutputStream os) throws DocumentException,IOException {
    this.request = request;
    this.os = os;
    formatter = new SimpleDateFormat("dd-MMM-yyyy");

    //Create the font we are going to print to
    bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    font = new Font(bf, FONTSIZE, Font.NORMAL);
    boldFont = new Font(bf,FONTSIZE,Font.BOLD);

    //Create the document we are going to write to
    document = new Document();
    writer = PdfWriter.getInstance(document,os);
    writer.setPageEvent(new EndPage());
    writer.setStrictImageSequence(true);

    document.setPageSize(PageSize.LETTER);
    
    document.open();
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:21,代碼來源:PdfRecordPrinter.java

示例15: start

import com.lowagie.text.PageSize; //導入依賴的package包/類
public void start() throws DocumentException,IOException {
    //Create the font we are going to print to
    bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
    font = new Font(bf, FONTSIZE, Font.NORMAL);
    boldFont = new Font(bf,FONTSIZE,Font.BOLD);

    //Create the document we are going to write to
    document = new Document();
    writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
    // writer = PdfWriter.getInstance(document,os);
    // writer.setPageEvent(new EndPage());
    writer.setStrictImageSequence(true);

    document.setPageSize(PageSize.LETTER);
    document.open();
}
 
開發者ID:williamgrosset,項目名稱:OSCAR-ConCert,代碼行數:17,代碼來源:PdfRecordPrinter.java


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