本文整理匯總了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();
}
}
}
示例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);
}
}
}
示例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();
}
}
}
}
示例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;
}
}
示例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;
}
}
示例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();
}
示例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;
}
示例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();
}