当前位置: 首页>>代码示例>>Java>>正文


Java PageSize.LETTER属性代码示例

本文整理汇总了Java中com.itextpdf.text.PageSize.LETTER属性的典型用法代码示例。如果您正苦于以下问题:Java PageSize.LETTER属性的具体用法?Java PageSize.LETTER怎么用?Java PageSize.LETTER使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.itextpdf.text.PageSize的用法示例。


在下文中一共展示了PageSize.LETTER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showBlank

/** Shows a blank document, in case of a problem in generating the PDF */
private byte[] showBlank() throws DocumentException {
    final Document document = new Document(PageSize.LETTER); // FIXME - get PageSize from label definition
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    
    final PdfWriter writer = PdfWriter.getInstance(document, baos);
    document.open();
    document.add(new Paragraph("No data have been uploaded.  The time is: " + new Date()));
    
    final Barcode128 code128 = new Barcode128();
    code128.setGenerateChecksum(true);
    code128.setCode(new Date().toString());
    
    document.add(code128.createImageWithBarcode(writer.getDirectContent(), null, null));
    document.close();
    return baos.toByteArray();
}
 
开发者ID:chiralsoftware,项目名称:ExcelToBarcode,代码行数:17,代码来源:MainController.java

示例2: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));

		// TODO: force iText to respect the order in which content is added
		writer.setStrictImageSequence(true);

		document.open();

		// step 4 - add content into document
		String[] imageNames = { "35_Cal_Crutchlow.jpg", "38_Bradley_Smith.jpg", "46_Valentino_Rossi.jpg",
				"99_Jorge_Lorenzo.jpg" };
		for (int i = 0; i < 4; i++) {

			Image image = Image.getInstance("resources/img/" + imageNames[i]);

			// TODO: scale image
			image.scaleToFit(500, 500); // scale size

			document.add(image);
			document.add(new Paragraph(imageNames[i]));
		}

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:26,代码来源:T05_Image.java

示例3: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter.getInstance(document, new FileOutputStream(filename));
		document.open();

		// step 4 - add content into document
		for (int i = 0; i < 5; i++) {
			document.add(new Phrase("Hello", new Font(FontFamily.HELVETICA, 32, Font.BOLD)));
			document.add(new Phrase("World", new Font(FontFamily.COURIER, 40, Font.ITALIC)));
			document.add(new Phrase("!!!", new Font(FontFamily.TIMES_ROMAN, 40)));

			document.add(Chunk.NEWLINE);
		}

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:17,代码来源:T03_Phrase.java

示例4: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
		document.open();

		// TODO: 1. get direct content
		PdfContentByte canvas = writer.getDirectContent();

		Font font = new Font(FontFamily.HELVETICA, 18, Font.BOLD, BaseColor.ORANGE);
		Phrase headerText = new Phrase("PSEG DP&C", font);
		int alignLeft = Element.ALIGN_LEFT;
		float right = document.getPageSize().getRight();
		float top = document.getPageSize().getTop();

		// TODO: 2. use ColumnText
		ColumnText.showTextAligned(canvas, alignLeft, headerText, right - 180, top - 36, 0);

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:20,代码来源:T11_ColumnText.java

示例5: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));
		document.open();

		PdfPTable table = new PdfPTable(2);
		PdfReader reader = new PdfReader(T08_Chapter.RESULT);
		int n = reader.getNumberOfPages();
		for (int pageNumber = 1; pageNumber <= n; pageNumber++) {

			// TODO: import page as image
			PdfImportedPage page = writer.getImportedPage(reader, pageNumber);
			table.addCell(Image.getInstance(page));
		}
		document.add(table);

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:19,代码来源:T12_ImportPages.java

示例6: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter.getInstance(document, new FileOutputStream(filename));
		document.open();

		// step 4 - add content into document
		for (int i = 1; i <= 10; i++) {
			Chapter chapter = new Chapter(String.format("Chapter %s", i), i);
			Section section = chapter.addSection("Section");
			section.setIndentation(18);
			section.add(new Paragraph("TestTestTestTestTestTestTestTestTestTestTestTest"));

			for (int j = 1; j <= 3; j++) {
				Section subSection = section.addSection("Sub Section");
				subSection.add(new Paragraph("TestTestTestTestTestTestTestTestTestTestTestTest"));
			}

			document.add(chapter);
		}

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:23,代码来源:T08_Chapter.java

示例7: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		// step 1 - create PDF document
		Document document = new Document(PageSize.LETTER);

		// step 2 - bind PDF document with output stream
		PdfWriter.getInstance(document, new FileOutputStream(filename));

		// step 3 - open document
		document.open();

		// step 4 - add content into document
		document.add(new Paragraph("Hello World!"));

		// step 5 - close document
		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:17,代码来源:T01_HelloWorld.java

示例8: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter.getInstance(document, new FileOutputStream(filename));
		document.open();

		// step 4 - add content into document
		for (int i = 0; i < 5; i++) {
			document.add(new Paragraph("Hello World !", new Font(FontFamily.HELVETICA, 32, Font.BOLD)));
		}

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:13,代码来源:T02_Paragraph.java

示例9: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(filename));

		// TODO: 3. get imported page
		PdfReader stationery = new PdfReader(T11_ColumnText.RESULT);
		PdfImportedPage page = writer.getImportedPage(stationery, 1);
		writer.setPageEvent(new HeaderFooter(page));

		document.open();

		// step 4 - add content into document
		for (int i = 1; i <= 10; i++) {
			Chapter chapter = new Chapter(String.format("Chapter %s", i), i);
			Section section = chapter.addSection("Section");
			section.add(new Paragraph("TestTestTestTestTestTestTestTestTestTestTestTest"));

			for (int j = 1; j <= 3; j++) {
				Section subSection = section.addSection("Sub Section");
				subSection.add(new Paragraph("TestTestTestTestTestTestTestTestTestTestTestTest"));
			}

			document.add(chapter);
		}

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:28,代码来源:T13_ImportStationery.java

示例10: createPdf

public void createPdf(String filename) throws DocumentException, IOException {

		Document document = new Document(PageSize.LETTER);
		PdfWriter.getInstance(document, new FileOutputStream(filename));
		document.open();

		// step 4 - add content into document
		String[] imageNames = { "35_Cal_Crutchlow.jpg", "38_Bradley_Smith.jpg", "46_Valentino_Rossi.jpg",
				"99_Jorge_Lorenzo.jpg" };
		for (int i = 0; i < 4; i++) {

			// TODO: 1. Add image into Chunk
			Image image = Image.getInstance("resources/img/" + imageNames[i]);
			image.scaleToFit(500, 500);
			Chunk imageChunk = new Chunk(image, 0, 0, true);

			Phrase phrase = new Phrase(imageNames[i]);

			Paragraph paragraph = new Paragraph();
			paragraph.add(imageChunk);
			paragraph.add(Chunk.NEWLINE);
			paragraph.add(phrase);

			// TODO: 2. Ask iText to keep a paragraph together
			paragraph.setKeepTogether(true);
			paragraph.setSpacingAfter(12);

			document.add(paragraph);
		}

		document.close();
	}
 
开发者ID:kohmiho,项目名称:iTextTutorial,代码行数:32,代码来源:T06_Image.java

示例11: createPortraitPdfDoc

/**
 * Create a simple PDF document using portrait letter orientation.
 * The document is opened by this method.
 */
public static Document createPortraitPdfDoc(final OutputStream out,
                                            final PdfPageEvent pageHandler)
    throws DocumentException {
  final Document pdfDoc = new Document(PageSize.LETTER);
  commonPdfDocCreate(out, pageHandler, pdfDoc);

  return pdfDoc;
}
 
开发者ID:jpschewe,项目名称:fll-sw,代码行数:12,代码来源:PdfUtils.java

示例12: write

public void write () throws java.io.IOException, DocumentException
    {
        //PdfReader read = null;
        Document document = new Document (PageSize.LETTER, 36, 36, 36, 36);
        PdfWriter writer = PdfWriter.getInstance (document, new FileOutputStream (file));

        if (this.getGroupData() == null)
        {
            throw new DocumentException ("No group data set");
        }
        if (getScope() != MapScope.SECTOR)
        {
            throw new DocumentException ("Scope not set to Sector, please reset the scope to either Sector to output to PDF.");
        }

        /* Get the blank map as a base write */
/*
        if (getScope() == MapIcon.SCOPE_SECTOR)
        {
            URL url = Resources.getSectorPDFTemplate();
            read = new PdfReader (url);
           
        }
        else if (getScope() == MapIcon.SCOPE_QUADRANT)
        {
            read = new PdfReader (Resources.getQuadrantPDFTemplate());
        }
        
        if (read == null) throw new DocumentException ("Unable to read PDF Template file.");
*/
        /* Add metadata header information */
        document.addTitle(this.getGroupData().getName());
        document.addAuthor("Traveller Stellar Cartographer");
        document.open();
        
        
        PdfContentByte cb = writer.getDirectContent();
        //PdfImportedPage page1 = writer.getImportedPage(read, 1);
        //cb.addTemplate(page1, 0, -30);

        // Create the graphic state         
        cb.saveState();
        cb.concatCTM(1, 0, 0, 1, 0, 0);
        
        g2 = cb.createGraphics(PageSize.LETTER.getWidth(), PageSize.LETTER.getHeight());
        // draw things to g2

        // This also puts the map to a full sector offset. 
        setMapOffset (1,1);

        if (getScope() == MapScope.SECTOR)
        {
            writeSector();
        }
        else if (getScope() == MapScope.QUADRANT)
        {
            setXStart (8.0);
            setYStart (4.8);
            setXSize (10.0);
            setYSize (18.0);
            g2.setFont (new Font ("Arial", Font.PLAIN, 6));
            drawAll();
        }

        g2.setFont(new Font ("Arial", Font.PLAIN, 14));
        Point center = new Point ((int)(PageSize.LETTER.getWidth() / 2.0), 10);
        layout.drawString (this.getGroupData().getName(), StyleConstants.ALIGN_CENTER, center, g2);
        
        g2.dispose();
        cb.restoreState();         
/*
        HeaderFooter header = new HeaderFooter (new Phrase (this.getGroupData().getName()), false);
        header.setBorder(Rectangle.NO_BORDER);
        document.setHeader(header);
*/        
        // Close the document
        document.close();
    }
 
开发者ID:makhidkarun,项目名称:cartography,代码行数:78,代码来源:PDFFileWriter.java

示例13: write

public void write(final File file) throws FileNotFoundException, DocumentException {
    final Document pdf = new com.itextpdf.text.Document(PageSize.LETTER);
    PdfWriter.getInstance(pdf, new FileOutputStream(file));
    pdf.open();
    pdf.add(generateBestPairingTable());
    pdf.add(new Paragraph("\n"));
    pdf.add(generatePlayerInfoTable());
    pdf.close();
}
 
开发者ID:armanbilge,项目名称:ChessPairs,代码行数:9,代码来源:PDFGenerator.java

示例14: generatePdf

@RequestMapping(value = "/export.pdf")
public ResponseEntity<byte[]> generatePdf(@RequestParam Map<String,String> allRequestParams) 
        throws DocumentException {
    final LabelFormat labelFormat = allRequestParams.containsKey("labelFormatString") ?
            LabelFormat.valueOf(allRequestParams.get("labelFormatString")) :
            LabelFormat.AVERY5160;
    
    createLineTypes(allRequestParams);

    if(xSSFWorkbook == null) {
        LOG.info("The workbook is null so this wouldn't work really");
        return new ResponseEntity<>(showBlank(), HttpStatus.OK);
    }
    if(allRequestParams == null) {
        LOG.info("the allRequestParams param is null so this wouldn't work really");
        return new ResponseEntity<>(showBlank(), HttpStatus.OK);
    }
    
    // we create a new document with zero left/right margins
    // we calculate the top and bottom margin
    final float topMargin = (PageSize.LETTER.getHeight() - labelFormat.getRows() * labelFormat.getHeight() * 72) / 2;
    final Document document = new Document(PageSize.LETTER, 0,0,topMargin,topMargin);
    final ByteArrayOutputStream baos = new ByteArrayOutputStream();
    
    final PdfWriter writer = PdfWriter.getInstance(document, baos);
    
    document.open();
    
    final XSSFSheet sheet = xSSFWorkbook.getSheetAt(0);
    final int rowCount = sheet.getLastRowNum();
    LOG.info("With: " + rowCount + " rows, "
            + "and " + labelFormat.getRows() * labelFormat.getColumns() + " labels per page, "
            + "we need: " + (1 + rowCount / (labelFormat.getRows() * labelFormat.getColumns())) + " pages");
    for(int i = 0 ; i <=  rowCount / labelFormat.getLabelsPerPage(); i++) {
        LOG.info("Showing page: " + i);
        int firstRow = i * labelFormat.getLabelsPerPage();
        int lastRow =  firstRow + labelFormat.getLabelsPerPage();
        if(lastRow > rowCount) lastRow = rowCount;
        LOG.info("At i = " + i + ", we need to show rows " + firstRow + " to " + lastRow);
        if(lastRow > firstRow) {
            final PdfPTable t = createTable(writer, labelFormat, firstRow, lastRow);
            document.add(t);
            t.setComplete(true);
            LOG.info("i = " + i + ", added the table and adding a new page");
            document.newPage();
        }
    } 
    
    document.close();
    
    final HttpHeaders httpHeaders = new HttpHeaders();
    httpHeaders.setContentType(MediaType.APPLICATION_PDF);
    final ResponseEntity<byte[]> result = new ResponseEntity<>(baos.toByteArray(), 
            httpHeaders, HttpStatus.OK);
    return result;
}
 
开发者ID:chiralsoftware,项目名称:ExcelToBarcode,代码行数:56,代码来源:MainController.java

示例15: getPageSize

public Rectangle getPageSize() {
	return PageSize.LETTER;
}
 
开发者ID:ltrr-arizona-edu,项目名称:tellervo,代码行数:3,代码来源:CornellSampleLabelPage.java


注:本文中的com.itextpdf.text.PageSize.LETTER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。