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