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


Java DocumentException.printStackTrace方法代码示例

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


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

示例1: outputDebug

import com.lowagie.text.DocumentException; //导入方法依赖的package包/类
public static void outputDebug(Object doc, int groupLevel, String str) {
	System.out.println(str);
	if(doc == null) return;
	if(groupLevel<0) groupLevel = 0;
	char[] a; Arrays.fill(a= new char[groupLevel*2], ' ');
	String spaces= new String(a);
	if(doc instanceof RtfDocument) {
		((RtfDocument)doc).add(new RtfDirectContent("\n" + spaces + str));
	}
	else
		if(doc instanceof Document) {
			try {
				((Document)doc).add(new RtfDirectContent("\n" + spaces + str));
			} catch (DocumentException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:20,代码来源:RtfParser.java

示例2: RtfHeaderFooter

import com.lowagie.text.DocumentException; //导入方法依赖的package包/类
/**
 * Constructs a RtfHeaderFooter as a copy of an existing RtfHeaderFooter.
 * For internal use only.
 * 
 * @param doc The RtfDocument this RtfHeaderFooter belongs to
 * @param headerFooter The RtfHeaderFooter to copy
 * @param displayAt The display location of this RtfHeaderFooter
 */
protected RtfHeaderFooter(RtfDocument doc, RtfHeaderFooter headerFooter, int displayAt) {
    super(new Phrase(""), false);
    this.document = doc;
    this.content = headerFooter.getContent();
    this.displayAt = displayAt;
    for(int i = 0; i < this.content.length; i++) {
        if(this.content[i] instanceof Element) {
            try {
                this.content[i] = this.document.getMapper().mapElement((Element) this.content[i])[0];
            } catch(DocumentException de) {
                de.printStackTrace();
            }
        }
        if(this.content[i] instanceof RtfBasicElement) {
            ((RtfBasicElement) this.content[i]).setInHeader(true);
        }
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:27,代码来源:RtfHeaderFooter.java

示例3: setRtfDocument

import com.lowagie.text.DocumentException; //导入方法依赖的package包/类
/**
 * Sets the RtfDocument this RtfElement belongs to
 * 
 * @param doc The RtfDocument to use
 */
public void setRtfDocument(RtfDocument doc) {
    this.document = doc;
    if(this.document != null) {
        for(int i = 0; i < this.content.length; i++) {
            try {
                if(this.content[i] instanceof Element) {
                    this.content[i] = this.document.getMapper().mapElement((Element) this.content[i])[0];
                    ((RtfBasicElement) this.content[i]).setInHeader(true);
                } else if(this.content[i] instanceof RtfBasicElement){
                    ((RtfBasicElement) this.content[i]).setRtfDocument(this.document);
                    ((RtfBasicElement) this.content[i]).setInHeader(true);
                }
            } catch(DocumentException de) {
                de.printStackTrace();
            }
        }
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:24,代码来源:RtfHeaderFooter.java

示例4: convert

import com.lowagie.text.DocumentException; //导入方法依赖的package包/类
@Override
public byte[] convert(String input) throws ConversionException {
    try {
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocumentFromString(new String(input.getBytes()));
        renderer.layout();
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        renderer.createPDF(outputStream);
        byte[] bytes = outputStream.toByteArray();
        return bytes;
    } catch (DocumentException e) {
        e.printStackTrace();
        throw ConversionException.HTML_TO_PDF_EXCEPTION;
    }
}
 
开发者ID:eamonfoy,项目名称:trello-to-markdown,代码行数:16,代码来源:Html2PdfConverter.java

示例5: addParagraphToDocument

import com.lowagie.text.DocumentException; //导入方法依赖的package包/类
private void addParagraphToDocument() {
	if(this.iTextParagraph != null) {
		try {
			this.rtfParser.getDocument().add(this.iTextParagraph);
		} catch (DocumentException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		this.iTextParagraph = null;
	}	
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:12,代码来源:RtfDestinationDocument.java

示例6: convertToPdf

import com.lowagie.text.DocumentException; //导入方法依赖的package包/类
/**
  * Converts a JFreeChart to PDF syntax.
  * @param filename	the name of the PDF file
  * @param chart		the JFreeChart
  * @param width		the width of the resulting PDF
  * @param height	the height of the resulting PDF
  */
 public static void convertToPdf(JFreeChart chart, int width, int height, String filename) {
 	// step 1
 	Document document = new Document(new Rectangle(width, height));
 	try {
 		// step 2
 		PdfWriter writer;
writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream(filename));
// step 3
 		document.open();
 		// step 4
 		PdfContentByte cb = writer.getDirectContent();
 		PdfTemplate tp = cb.createTemplate(width, height);
 		Graphics2D g2d = tp.createGraphics(width, height, new DefaultFontMapper());
 		Rectangle2D r2d = new Rectangle2D.Double(0, 0, width, height);
 		chart.draw(g2d, r2d);
 		g2d.dispose();
 		tp.sanityCheck();
 		cb.addTemplate(tp, 0, 0);
 		cb.sanityCheck();
 	}
 	catch(DocumentException de) {
 		de.printStackTrace();
 	}
 	catch (FileNotFoundException e) {
 		e.printStackTrace();
 	}
 	// step 5
 	document.close();
 }
 
开发者ID:albfernandez,项目名称:itext2,代码行数:37,代码来源:JFreeChartTest.java

示例7: write

import com.lowagie.text.DocumentException; //导入方法依赖的package包/类
/**
 * Write out the columns.  After writing, use
 * {@link #isOverflow()} to see if all text was written.
 * @param canvas PdfContentByte to write with
 * @param document document to write to (only used to get page limit info)
 * @param documentY starting y position to begin writing at
 * @return the current height (y position) after writing the columns
 * @throws DocumentException on error
 */
public float write(PdfContentByte canvas, PdfDocument document, float documentY) throws DocumentException {
    this.document = document;
    columnText.setCanvas(canvas);
    if (columnDefs.isEmpty()) {
        throw new DocumentException("MultiColumnText has no columns");
    }
    overflow = false;
    float currentHeight = 0;
    boolean done = false;
    try {
        while (!done) {
            if (top == AUTOMATIC) {
                top = document.getVerticalPosition(true); // RS - 07/07/2005 - Get current doc writing position for top of columns on new page.
            }
            else if (nextY == AUTOMATIC) {
                nextY = document.getVerticalPosition(true); // RS - 07/07/2005 - - Get current doc writing position for top of columns on new page.
            }
            ColumnDef currentDef = (ColumnDef) columnDefs.get(getCurrentColumn());
            columnText.setYLine(top);

            float[] left = currentDef.resolvePositions(Rectangle.LEFT);
            float[] right = currentDef.resolvePositions(Rectangle.RIGHT);
            if (document.isMarginMirroring() && document.getPageNumber() % 2 == 0){
                float delta = document.rightMargin() - document.left();
                left = (float[])left.clone();
                right = (float[])right.clone();
                for (int i = 0; i < left.length; i += 2) {
                    left[i] -= delta;
                }
                for (int i = 0; i < right.length; i += 2) {
                    right[i] -= delta;
                }
            }
            
            currentHeight = Math.max(currentHeight, getHeight(left, right));

            if (currentDef.isSimple()) {
                columnText.setSimpleColumn(left[2], left[3], right[0], right[1]);
            } else {
                columnText.setColumns(left, right);
            }

            int result = columnText.go();
            if ((result & ColumnText.NO_MORE_TEXT) != 0) {
                done = true;
                top = columnText.getYLine();
            } else if (shiftCurrentColumn()) {
                top = nextY;
            } else {  // check if we are done because of height
                totalHeight += currentHeight;
                if ((desiredHeight != AUTOMATIC) && (totalHeight >= desiredHeight)) {
                    overflow = true;
                    break;
                } else {  // need to start new page and reset the columns
                    documentY = nextY;
                    newPage();
                    currentHeight = 0;
                }
            }
        }
    } catch (DocumentException ex) {
        ex.printStackTrace();
        throw ex;
    }
    if (desiredHeight == AUTOMATIC && columnDefs.size() == 1) {
    	currentHeight = documentY - columnText.getYLine();
    }
    return currentHeight;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:79,代码来源:MultiColumnText.java

示例8: doGet

import com.lowagie.text.DocumentException; //导入方法依赖的package包/类
/**
 * Returns a PDF, RTF or HTML document.
 * 
 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 */
public void doGet (HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
    
    // we retrieve the presentationtype
    String presentationtype = request.getParameter("presentationtype");
    
    // step 1
    Document document = new Document();
    try {
        // step 2: we set the ContentType and create an instance of the corresponding Writer
        if ("pdf".equals(presentationtype)) {
            response.setContentType("application/pdf");
            PdfWriter.getInstance(document, response.getOutputStream());
        }
        else if ("html".equals(presentationtype)) {
            response.setContentType("text/html");
            HtmlWriter.getInstance(document, response.getOutputStream());
        }
        else if ("rtf".equals(presentationtype)) {
            response.setContentType("text/rtf");
            RtfWriter2.getInstance(document, response.getOutputStream());
        }
        else {
            response.sendRedirect("http://itextdocs.lowagie.com/tutorial/general/webapp/index.html#HelloWorld");
        }
        
        // step 3
        document.open();
        
        // step 4
        document.add(new Paragraph("Hello World"));
        document.add(new Paragraph(new Date().toString()));
    }
    catch(DocumentException de) {
        de.printStackTrace();
        System.err.println("document: " + de.getMessage());
    }
    
    // step 5: we close the document (the outputstream is also closed internally)
    document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:47,代码来源:HelloWorldServlet.java


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