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


Java DocumentException类代码示例

本文整理汇总了Java中com.lowagie.text.DocumentException的典型用法代码示例。如果您正苦于以下问题:Java DocumentException类的具体用法?Java DocumentException怎么用?Java DocumentException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: close

import com.lowagie.text.DocumentException; //导入依赖的package包/类
@Override
public void close() throws IOException {
	try {
		float width = 0;
		float[] w = new float[iMaxWidth.length - iHiddenColumns.size()]; int wi = 0;
		for (int i = 0; i < iMaxWidth.length; i++)
			if (!iHiddenColumns.contains(i)) { width += 15f + iMaxWidth[i]; w[wi++] = iMaxWidth[i]; }
		Document document = new Document(new Rectangle(60f + width, 60f + width * 0.75f), 30f, 30f, 30f, 30f);
		PdfWriter writer = PdfWriter.getInstance(document, iOutput);
		writer.setPageEvent(new PdfEventHandler());
		document.open();
		iTable.setWidths(w);
		document.add(iTable);
		document.close();
	} catch (DocumentException e) {
		throw new IOException(e.getMessage(), e);
	}
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:19,代码来源:PDFPrinter.java

示例2: setPageNumbers

import com.lowagie.text.DocumentException; //导入依赖的package包/类
private void setPageNumbers() throws DocumentException, IOException {		
	
	int pages = getReader().getNumberOfPages();
	int i = 0;	
	PdfContentByte overContent;
	Rectangle pageSize = null;
	BaseFont font = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.EMBEDDED);

	while (i < pages) {
		i++;
		overContent = getStamper().getOverContent(i);
		pageSize = overContent.getPdfDocument().getPageSize();
		overContent.beginText();
		overContent.setFontAndSize(font, 9);
		overContent.setTextMatrix(pageSize.getWidth() - 50, pageSize.getHeight() - 70);
		overContent.showText("Page " + i + " of " + pages);
		overContent.endText();
	}
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:20,代码来源:PDFController.java

示例3: crearCarta

import com.lowagie.text.DocumentException; //导入依赖的package包/类
@Override
protected void crearCarta(Citizen citizen)
		throws FileNotFoundException, DocumentException, IOException {
	XWPFDocument documento = new XWPFDocument();
	File folder = new File("Letter/WORD");
	folder.mkdir();
	letter = new FileOutputStream(
			"Letter/WORD/" + citizen.getDni() + ".docx");
	XWPFParagraph paragraph = documento.createParagraph();
	XWPFRun run = paragraph.createRun();
	run.setText("Usuario: " + citizen.getDni());
	run.addBreak();
	run.addBreak();
	run.setText("Password: " + citizen.getPassword());
	documento.write(letter);
	documento.close();
}
 
开发者ID:Arquisoft,项目名称:citizensLoader4b,代码行数:18,代码来源:WordLetter.java

示例4: createDocument

import com.lowagie.text.DocumentException; //导入依赖的package包/类
@Override
public void createDocument(String documentName, String content) throws CitizenException {
	String realPath = FILE_PATH + documentName + ".pdf";
	Document doc = new Document();
	try {
		PdfWriter.getInstance(doc, new FileOutputStream(realPath));
		doc.open();
		addMetaData(doc);
		addTitlePage(doc);
		addContent(doc, content);
	} catch (DocumentException | FileNotFoundException e) {
		throw new CitizenException("Error al generar documento pdf" +
				" ["+ FILE_PATH+documentName+".pdf] | ["+this.getClass().getName()+"]");
	} finally {
		if (doc != null) {
			doc.close();
		}
	}

}
 
开发者ID:Arquisoft,项目名称:citizensLoader4a,代码行数:21,代码来源:PDFTextWritter.java

示例5: convertWriteToPdf

import com.lowagie.text.DocumentException; //导入依赖的package包/类
public static void convertWriteToPdf(BufferedImage bufeBufferedImage, String path) {
    try {
        //Image img = Image.getInstance("C:\\Users\\SOFTWARE1\\Desktop\\boshtwain4JImages\\testcapture1507134499431.jpg");
        Image img = Image.getInstance(bufeBufferedImage, null);
        Document document = new Document(img);
        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path));
        //--
        document.open();
        img.setAbsolutePosition(0, 0);
        //--
        document.add(img);
        //--
        document.close();
    } catch (DocumentException | IOException e) {
        System.out.println("Intern Log : " + e.getMessage());
    }
}
 
开发者ID:nrreal,项目名称:twainBDirect,代码行数:18,代码来源:ImageManager.java

示例6: printReport

import com.lowagie.text.DocumentException; //导入依赖的package包/类
@Override
public void printReport() throws DocumentException {
       setHeader(buildHeaderString());
       List results = getAuditResults(getSubjectAreas());
       Vector<String> lines = new Vector<String>();
       Iterator it = results.iterator();
       while(it.hasNext()) {
       	MultipleCourseEnrollmentsAuditResult result = new MultipleCourseEnrollmentsAuditResult((Object[]) it.next());
       	lines.add(buildLineString(result));
       }
       printHeader();
       for (String str : lines) {
               println(str);
       }
       if (!lines.isEmpty()){
       	lastPage();
       }

}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:20,代码来源:MultipleCourseEnrollmentsAuditReport.java

示例7: printReport

import com.lowagie.text.DocumentException; //导入依赖的package包/类
@Override
public void printReport() throws DocumentException {
       setHeader(buildHeaderString());
       List results = getAuditResults(getSubjectAreas());
       Vector<String> lines = new Vector<String>();
       Iterator it = results.iterator();
       while(it.hasNext()) {
       	EnrollmentsViolatingCourseStructureAuditResult result = new EnrollmentsViolatingCourseStructureAuditResult((Object[]) it.next());
       	lines.add(buildLineString(result));
       }
       printHeader();
       for (String str : lines) {
               println(str);
       }
       if (!lines.isEmpty()){
       	lastPage();
       }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:19,代码来源:EnrollmentsViolatingCourseStructureAuditReport.java

示例8: printReport

import com.lowagie.text.DocumentException; //导入依赖的package包/类
@Override
public void printReport() throws DocumentException {
       setHeader(buildHeaderString());
       List results = getAuditResults(getSubjectAreas());
       Vector<String> lines = new Vector<String>();
       Iterator it = results.iterator();
       while(it.hasNext()) {
       	MissingCourseEnrollmentsAuditResult result = new MissingCourseEnrollmentsAuditResult((Object[]) it.next());
       	lines.add(buildLineString(result));
       }
       printHeader();
       for (String str : lines) {
               println(str);
       }
       if (!lines.isEmpty()){
       	lastPage();
       }

}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:20,代码来源:MissingCourseEnrollmentsAuditReport.java

示例9: open

import com.lowagie.text.DocumentException; //导入依赖的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

示例10: print

import com.lowagie.text.DocumentException; //导入依赖的package包/类
public static boolean print(OutputStream out, Collection<SubjectArea> subjectAreas) throws IOException, DocumentException {
    TreeSet courses = new TreeSet(new Comparator() {
        public int compare(Object o1, Object o2) {
            CourseOffering co1 = (CourseOffering)o1;
            CourseOffering co2 = (CourseOffering)o2;
            int cmp = co1.getCourseName().compareTo(co2.getCourseName());
            if (cmp != 0) return cmp;
            return co1.getUniqueId().compareTo(co2.getUniqueId());
        }
    });
    String subjectIds = "";
    for (SubjectArea sa: subjectAreas)
    	subjectIds += (subjectIds.isEmpty() ? "" : ",") + sa.getUniqueId();
    courses.addAll(SessionDAO.getInstance().getSession().createQuery(
    		"select co from CourseOffering co where  co.subjectArea.uniqueId in (" + subjectIds + ")").list());
    if (courses.isEmpty()) return false;
    PdfWorksheet w = new PdfWorksheet(out, subjectAreas, null);
    for (Iterator i=courses.iterator();i.hasNext();) {
        w.print((CourseOffering)i.next());
    }
    w.lastPage();
    w.close();
    return true;
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:25,代码来源:PdfWorksheet.java

示例11: start

import com.lowagie.text.DocumentException; //导入依赖的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

示例12: reorderPages

import com.lowagie.text.DocumentException; //导入依赖的package包/类
int reorderPages(int order[]) throws DocumentException {
    if (order == null)
        return pages.size();
    if (parents.size() > 1)
        throw new DocumentException("Page reordering requires a single parent in the page tree. Call PdfWriter.setLinearMode() after open.");
    if (order.length != pages.size())
        throw new DocumentException("Page reordering requires an array with the same size as the number of pages.");
    int max = pages.size();
    boolean temp[] = new boolean[max];
    for (int k = 0; k < max; ++k) {
        int p = order[k];
        if (p < 1 || p > max)
            throw new DocumentException("Page reordering requires pages between 1 and " + max + ". Found " + p + ".");
        if (temp[p - 1])
            throw new DocumentException("Page reordering requires no page repetition. Page " + p + " is repeated.");
        temp[p - 1] = true;
    }
    Object copy[] = pages.toArray();
    for (int k = 0; k < max; ++k) {
        pages.set(k, copy[order[k] - 1]);
    }
    return max;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:24,代码来源:PdfPages.java

示例13: writeFont

import com.lowagie.text.DocumentException; //导入依赖的package包/类
void writeFont(PdfWriter writer, PdfIndirectReference ref, Object params[]) throws DocumentException, IOException {
    IntHashtable cjkTag = (IntHashtable)params[0];
    PdfIndirectReference ind_font = null;
    PdfObject pobj = null;
    PdfIndirectObject obj = null;
    pobj = getFontDescriptor();
    if (pobj != null){
        obj = writer.addToBody(pobj);
        ind_font = obj.getIndirectReference();
    }
    pobj = getCIDFont(ind_font, cjkTag);
    if (pobj != null){
        obj = writer.addToBody(pobj);
        ind_font = obj.getIndirectReference();
    }
    pobj = getFontBaseType(ind_font);
    writer.addToBody(pobj, ref);
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:19,代码来源:CJKFont.java

示例14: createNeedHeader

import com.lowagie.text.DocumentException; //导入依赖的package包/类
private PdfPTable createNeedHeader(String name) throws DocumentException {
	Font whiteFont = new Font(Font.HELVETICA,14,Font.BOLD,Color.WHITE);
	PdfPTable table = new PdfPTable(3);
	table.setWidthPercentage(100);
	table.setWidths(new float[]{0.10f,0.20f,0.70f});
	PdfPCell emptyCell = new PdfPCell();
	emptyCell.setBorder(0);
	table.addCell(emptyCell);

	PdfPCell headerCell = new PdfPCell();
	headerCell.setColspan(2);
	headerCell.setPhrase(new Phrase(name,whiteFont));
	headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
	headerCell.setBackgroundColor(Color.LIGHT_GRAY);
	table.addCell(headerCell);
	return table;
}
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:18,代码来源:SummaryOfActionsAndCommentsReportGenerator.java

示例15: calculateFontSize

import com.lowagie.text.DocumentException; //导入依赖的package包/类
private float calculateFontSize(float w, float h) throws IOException, DocumentException {
    BaseFont ufont = getRealFont();
    float fsize = fontSize;
    if (fsize == 0) {
        float bw = ufont.getWidthPoint(text, 1);
        if (bw == 0)
            fsize = 12;
        else
            fsize = w / bw;
        float nfsize = h / (1 - ufont.getFontDescriptor(BaseFont.DESCENT, 1));
        fsize = Math.min(fsize, nfsize);
        if (fsize < 4)
            fsize = 4;
    }
    return fsize;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:17,代码来源:PushbuttonField.java


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