本文整理汇总了Java中com.lowagie.text.Document.addTitle方法的典型用法代码示例。如果您正苦于以下问题:Java Document.addTitle方法的具体用法?Java Document.addTitle怎么用?Java Document.addTitle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.Document
的用法示例。
在下文中一共展示了Document.addTitle方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: open
import com.lowagie.text.Document; //导入方法依赖的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;
}
示例2: printPdf
import com.lowagie.text.Document; //导入方法依赖的package包/类
/**
* Prints the consultation request.
* @throws IOException when an error with the output stream occurs
* @throws DocumentException when an error in document construction occurs
*/
public void printPdf(LoggedInInfo loggedInInfo) throws IOException, DocumentException {
// Create the document we are going to write to
document = new Document();
// PdfWriter.getInstance(document, os);
PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
document.setPageSize(PageSize.LETTER);
document.addTitle(getResource("msgConsReq"));
document.addCreator("OSCAR");
document.open();
// Create the fonts that we are going to use
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252,
BaseFont.NOT_EMBEDDED);
headerFont = new Font(bf, 14, Font.BOLD);
infoFont = new Font(bf, 12, Font.NORMAL);
font = new Font(bf, 9, Font.NORMAL);
boldFont = new Font(bf, 10, Font.BOLD);
bigBoldFont = new Font(bf, 12, Font.BOLD);
createConsultationRequest(loggedInInfo);
document.close();
}
示例3: addDocumentProps
import com.lowagie.text.Document; //导入方法依赖的package包/类
private void addDocumentProps(Document document, String title, Properties props) {
document.addTitle(title);
document.addSubject("");
document.addKeywords("pdf, itext");
document.addCreator("OSCAR");
document.addAuthor("");
// A0-A10, LEGAL, LETTER, HALFLETTER, _11x17, LEDGER, NOTE, B0-B5, ARCH_A-ARCH_E, FLSA
// and FLSE
// the following shows a temp way to get a print page size
final String PAGESIZE = "printPageSize";
Rectangle pageSize = PageSize.LETTER;
if ("PageSize.HALFLETTER".equals(props.getProperty(PAGESIZE)))
pageSize = PageSize.HALFLETTER;
if ("PageSize.A6".equals(props.getProperty(PAGESIZE)))
pageSize = PageSize.A6;
document.setPageSize(pageSize);
document.open();
}
示例4: addMetaData
import com.lowagie.text.Document; //导入方法依赖的package包/类
/**
* Metadata del documento.
* @param document Documento en cuestión
*/
private void addMetaData(Document document) {
document.addTitle("My first PDF");
document.addSubject("Using iText");
document.addKeywords("Java, PDF, iText");
document.addAuthor("Lars Vogel");
document.addCreator("Lars Vogel");
}
示例5: PdfWorksheet
import com.lowagie.text.Document; //导入方法依赖的package包/类
private PdfWorksheet(OutputStream out, Collection<SubjectArea> subjectAreas, String courseNumber) throws IOException, DocumentException {
iUseCommitedAssignments = ApplicationProperty.WorksheetPdfUseCommittedAssignments.isTrue();
iSubjectAreas = new TreeSet<SubjectArea>(new Comparator<SubjectArea>() {
@Override
public int compare(SubjectArea s1, SubjectArea s2) {
return s1.getSubjectAreaAbbreviation().compareTo(s2.getSubjectAreaAbbreviation());
}
});
iSubjectAreas.addAll(subjectAreas);
iCourseNumber = courseNumber;
if (iCourseNumber!=null && (iCourseNumber.trim().length()==0 || "*".equals(iCourseNumber.trim().length())))
iCourseNumber = null;
iDoc = new Document(PageSize.LETTER.rotate());
iOut = out;
PdfWriter.getInstance(iDoc, iOut);
String session = null;
String subjects = "";
for (SubjectArea sa: iSubjectAreas) {
if (subjects.isEmpty()) subjects += ", ";
subjects += sa.getSubjectAreaAbbreviation();
if (session == null) session += sa.getSession().getLabel();
}
iDoc.addTitle(subjects + (iCourseNumber==null?"":" "+iCourseNumber) + " Worksheet");
iDoc.addAuthor(ApplicationProperty.WorksheetPdfAuthor.value().replace("%", Constants.getVersion()));
iDoc.addSubject(subjects + (session == null ? "" : " -- " + session));
iDoc.addCreator("UniTime "+Constants.getVersion()+", www.unitime.org");
if (!iSubjectAreas.isEmpty())
iCurrentSubjectArea = iSubjectAreas.first();
iDoc.open();
printHeader();
}
示例6: main
import com.lowagie.text.Document; //导入方法依赖的package包/类
/**
* Generates a PDF file with metadata
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
HtmlWriter.getInstance(document, PdfTestBase.getOutputStream("HelloWorldMeta.html"));
// step 3: we add some metadata open the document
// standard meta information
document.addTitle("Hello World example");
document.addAuthor("Bruno Lowagie");
document.addSubject("This example explains step 3 in Chapter 1");
document.addKeywords("Metadata, iText, step 3, tutorial");
// custom (HTML) meta information
document.addHeader("Expires", "0");
// meta information that will be in a comment section in HTML
document.addCreator("My program using iText");
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));
// step 5: we close the document
document.close();
}
示例7: printRtf
import com.lowagie.text.Document; //导入方法依赖的package包/类
public void printRtf()throws IOException, DocumentException{
//create an input stream from the rtf string bytes
byte[] rtfBytes = handler.getOBXResult(0, 0).getBytes();
ByteArrayInputStream rtfStream = new ByteArrayInputStream(rtfBytes);
//create & open the document we are going to write to and its writer
document = new Document();
RtfWriter2 writer = RtfWriter2.getInstance(document,os);
document.setPageSize(PageSize.LETTER);
document.addTitle("Title of the Document");
document.addCreator("OSCAR");
document.open();
//Create the fonts that we are going to use
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, 11, Font.NORMAL);
boldFont = new Font(bf, 12, Font.BOLD);
// redFont = new Font(bf, 11, Font.NORMAL, Color.RED);
//add the patient information
addRtfPatientInfo();
//add the results
writer.importRtfDocument(rtfStream, null);
document.close();
os.flush();
}
示例8: printPdf
import com.lowagie.text.Document; //导入方法依赖的package包/类
public void printPdf() throws IOException, DocumentException{
// check that we have data to print
if (handler == null)
throw new DocumentException();
//response.setContentType("application/pdf"); //octet-stream
//response.setHeader("Content-Disposition", "attachment; filename=\""+handler.getPatientName().replaceAll("\\s", "_")+"_LabReport.pdf\"");
//Create the document we are going to write to
document = new Document();
//PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
// PdfWriter writer = PdfWriter.getInstance(document, os);
PdfWriter writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
//Set page event, function onEndPage will execute each time a page is finished being created
writer.setPageEvent(this);
document.setPageSize(PageSize.LETTER);
document.addTitle("Title of the Document");
document.addCreator("OSCAR");
document.open();
//Create the fonts that we are going to use
bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, 9, Font.NORMAL);
boldFont = new Font(bf, 10, Font.BOLD);
// redFont = new Font(bf, 9, Font.NORMAL, Color.RED);
// add the header table containing the patient and lab info to the document
createInfoTable();
// add the tests and test info for each header
ArrayList<String> headers = handler.getHeaders();
for (int i=0; i < headers.size(); i++)
addLabCategory( headers.get(i) ,null);
for(MessageHandler extraHandler:handlers) {
ArrayList<String> extraHeaders = extraHandler.getHeaders();
for (int i=0; i < extraHeaders.size(); i++)
addLabCategory( extraHeaders.get(i) , extraHandler);
}
// add end of report table
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100);
PdfPCell cell = new PdfPCell();
cell.setBorder(0);
cell.setPhrase(new Phrase(" "));
table.addCell(cell);
cell.setBorder(15);
cell.setBackgroundColor(new Color(210, 212, 255));
cell.setPhrase(new Phrase("END OF REPORT", boldFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
document.add(table);
document.close();
os.flush();
}
示例9: main
import com.lowagie.text.Document; //导入方法依赖的package包/类
/**
* Generates a PDF file with metadata
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("HelloWorldMeta.pdf"));
// step 3: we add some metadata open the document
document.addTitle("Hello World example");
document.addSubject("This example explains how to add metadata.");
document.addKeywords("iText, Hello World, step 3, metadata");
document.addCreator("My program using iText");
document.addAuthor("Bruno Lowagie");
document.open();
// step 4: we add a paragraph to the document
document.add(new Paragraph("Hello World"));
// step 5: we close the document
document.close();
}
示例10: main
import com.lowagie.text.Document; //导入方法依赖的package包/类
/**
* Creates documents with different viewerpreferences.
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document(PageSize.A6);
// step 2:
PdfWriter writer1 = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("TwoColumnLeft.pdf"));
PdfWriter writer2 = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("HideMenuToolbar.pdf"));
PdfWriter writer3 = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("FullScreen.pdf"));
PdfWriter writer4 = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("WithTitle.pdf"));
PdfWriter writer5 = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("NoScaling.pdf"));
// step 3:
writer1.setViewerPreferences(PdfWriter.PageLayoutTwoColumnLeft);
writer2.setViewerPreferences(PdfWriter.HideMenubar | PdfWriter.HideMenubar);
writer3.setViewerPreferences(PdfWriter.PageLayoutTwoColumnRight | PdfWriter.PageModeFullScreen
| PdfWriter.NonFullScreenPageModeUseThumbs);
writer4.setViewerPreferences(PdfWriter.DisplayDocTitle);
writer5.setViewerPreferences(PdfWriter.PrintScalingNone);
document.addTitle("Julius Caesar");
document.open();
// step 4: we grab the ContentByte and do some stuff with it
document.add(new Paragraph(
"GALLIA est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur. Hi omnes lingua, institutis, legibus inter se differunt. Gallos ab Aquitanis Garumna flumen, a Belgis Matrona et Sequana dividit. Horum omnium fortissimi sunt Belgae, propterea quod a cultu atque humanitate provinciae longissime absunt, minimeque ad eos mercatores saepe commeant atque ea quae ad effeminandos animos pertinent important, proximique sunt Germanis, qui trans Rhenum incolunt, quibuscum continenter bellum gerunt. Qua de causa Helvetii quoque reliquos Gallos virtute praecedunt, quod fere cotidianis proeliis cum Germanis contendunt, cum aut suis finibus eos prohibent aut ipsi in eorum finibus bellum gerunt.",
new Font(Font.HELVETICA, 12)));
document.add(new Paragraph(
"[Eorum una, pars, quam Gallos obtinere dictum est, initium capit a flumine Rhodano, continetur Garumna flumine, Oceano, finibus Belgarum, attingit etiam ab Sequanis et Helvetiis flumen Rhenum, vergit ad septentriones. Belgae ab extremis Galliae finibus oriuntur, pertinent ad inferiorem partem fluminis Rheni, spectant in septentrionem et orientem solem. Aquitania a Garumna flumine ad Pyrenaeos montes et eam partem Oceani quae est ad Hispaniam pertinet; spectat inter occasum solis et septentriones.]",
new Font(Font.HELVETICA, 12)));
document.add(new Paragraph(
"Apud Helvetios longe nobilissimus fuit et ditissimus Orgetorix. Is M. Messala, [et P.] M. Pisone consulibus regni cupiditate inductus coniurationem nobilitatis fecit et civitati persuasit ut de finibus suis cum omnibus copiis exirent: perfacile esse, cum virtute omnibus praestarent, totius Galliae imperio potiri. Id hoc facilius iis persuasit, quod undique loci natura Helvetii continentur: una ex parte flumine Rheno latissimo atque altissimo, qui agrum Helvetium a Germanis dividit; altera ex parte monte Iura altissimo, qui est inter Sequanos et Helvetios; tertia lacu Lemanno et flumine Rhodano, qui provinciam nostram ab Helvetiis dividit. His rebus fiebat ut et minus late vagarentur et minus facile finitimis bellum inferre possent; qua ex parte homines bellandi cupidi magno dolore adficiebantur. Pro multitudine autem hominum et pro gloria belli atque fortitudinis angustos se fines habere arbitrabantur, qui in longitudinem milia passuum CCXL, in latitudinem CLXXX patebant.",
new Font(Font.HELVETICA, 12)));
document.add(new Paragraph(
"His rebus adducti et auctoritate Orgetorigis permoti constituerunt ea quae ad proficiscendum pertinerent comparare, iumentorum et carrorum quam maximum numerum coemere, sementes quam maximas facere, ut in itinere copia frumenti suppeteret, cum proximis civitatibus pacem et amicitiam confirmare. Ad eas res conficiendas biennium sibi satis esse duxerunt; in tertium annum profectionem lege confirmant. Ad eas res conficiendas Orgetorix deligitur. Is sibi legationem ad civitates suscipit. In eo itinere persuadet Castico, Catamantaloedis filio, Sequano, cuius pater regnum in Sequanis multos annos obtinuerat et a senatu populi Romani amicus appellatus erat, ut regnum in civitate sua occuparet, quod pater ante habuerit; itemque Dumnorigi Haeduo, fratri Diviciaci, qui eo tempore principatum in civitate obtinebat ac maxime plebi acceptus erat, ut idem conaretur persuadet eique filiam suam in matrimonium dat. Perfacile factu esse illis probat conata perficere, propterea quod ipse suae civitatis imperium obtenturus esset: non esse dubium quin totius Galliae plurimum Helvetii possent; se suis copiis suoque exercitu illis regna conciliaturum confirmat. Hac oratione adducti inter se fidem et ius iurandum dant et regno occupato per tres potentissimos ac firmissimos populos totius Galliae sese potiri posse sperant.",
new Font(Font.HELVETICA, 12)));
document.add(new Paragraph(
"Ea res est Helvetiis per indicium enuntiata. Moribus suis Orgetoricem ex vinculis causam dicere coegerunt; damnatum poenam sequi oportebat, ut igni cremaretur. Die constituta causae dictionis Orgetorix ad iudicium omnem suam familiam, ad hominum milia decem, undique coegit, et omnes clientes obaeratosque suos, quorum magnum numerum habebat, eodem conduxit; per eos ne causam diceret se eripuit. Cum civitas ob eam rem incitata armis ius suum exequi conaretur multitudinemque hominum ex agris magistratus cogerent, Orgetorix mortuus est; neque abest suspicio, ut Helvetii arbitrantur, quin ipse sibi mortem consciverit.",
new Font(Font.HELVETICA, 12)));
// step 5: we close the document
document.close();
}
示例11: testAddedMetadata
import com.lowagie.text.Document; //导入方法依赖的package包/类
@Test
public void testAddedMetadata() throws Exception {
String AUTHOR_NAME = "Mr Bean";
String TITLE = "The title";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Document document = new Document();
PdfWriter.getInstance(document, baos);
document.open();
document.addProducer();
document.addAuthor(AUTHOR_NAME);
document.addTitle(TITLE);
document.add(new Paragraph("Hello World"));
document.close();
PdfReader r = new PdfReader(baos.toByteArray());
// Metadata generated only on demand
Assert.assertEquals(Document.getVersion(), r.getInfo().get("Producer"));
Assert.assertEquals(AUTHOR_NAME, r.getInfo().get("Author"));
Assert.assertEquals(TITLE, r.getInfo().get("Title"));
r.close();
}
示例12: printPdf
import com.lowagie.text.Document; //导入方法依赖的package包/类
public void printPdf() throws IOException, DocumentException{
// check that we have data to print
if (report == null)
throw new DocumentException();
//Create the document we are going to write to
document = new Document();
PdfWriter writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
//Set page event, function onEndPage will execute each time a page is finished being created
writer.setPageEvent(this);
document.setPageSize(PageSize.LETTER);
document.addTitle("HRM Report");
document.addCreator("OSCAR");
document.open();
//Create the fonts that we are going to use
bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, 9, Font.NORMAL);
boldFont = new Font(bf, 10, Font.BOLD);
// redFont = new Font(bf, 9, Font.NORMAL, Color.RED);
// add the header table containing the patient and lab info to the document
createInfoTable();
// add end of report table
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100);
PdfPCell cell = new PdfPCell();
cell.setBorder(0);
cell.setPhrase(new Phrase(" "));
table.addCell(cell);
cell.setBorder(15);
cell.setBackgroundColor(new Color(210, 212, 255));
cell.setPhrase(new Phrase("END OF REPORT", boldFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
document.add(table);
document.close();
os.flush();
}
示例13: printPdf
import com.lowagie.text.Document; //导入方法依赖的package包/类
public void printPdf(LoggedInInfo loggedInInfo) throws IOException, DocumentException{
EctConsultationFormRequestUtil reqForm = new EctConsultationFormRequestUtil();
reqForm.estRequestFromId(loggedInInfo, (String) request.getAttribute("reqId"));
// init req form info
reqForm.specAddr = request.getParameter("address");
if (reqForm.specAddr == null){reqForm.specAddr = new String(); }
reqForm.specPhone = request.getParameter("phone");
if (reqForm.specPhone == null){ reqForm.specPhone = ""; }
reqForm.specFax = request.getParameter("fax");
if (reqForm.specFax == null){ reqForm.specFax = ""; }
//Create new file to save form to
String path = OscarProperties.getInstance().getProperty("DOCUMENT_DIR");
String fileName = path + "ConsultationRequestForm-"+UtilDateUtilities.getToday("yyyy-MM-dd.hh.mm.ss")+".pdf";
FileOutputStream out = new FileOutputStream(fileName);
//Create the document we are going to write to
document = new Document();
// writer = PdfWriter.getInstance(document,out);
writer = PdfWriterFactory.newInstance(document, out, FontSettings.HELVETICA_6PT);
//Use the template located at '/oscar/oscarEncounter/oscarConsultationRequest/props'
reader = new PdfReader("/oscar/oscarEncounter/oscarConsultationRequest/props/consultationFormRequest.pdf");
Rectangle pSize = reader.getPageSize(1);
height = pSize.getHeight();
document.setPageSize(pSize);
document.addTitle("Consultation Form Request");
document.addCreator("OSCAR");
document.open();
//Create the font we are going to print to
bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
cb = writer.getDirectContent();
ct = new ColumnText(cb);
cb.setColorStroke(new Color(0,0,0));
// start writing the pdf document
PdfImportedPage page1 = writer.getImportedPage(reader, 1);
cb.addTemplate(page1, 1, 0, 0, 1, 0, 0);
// addFooter();
setAppointmentInfo(reqForm);
// add the dynamically positioned text elements
float dynamicHeight = 0;
dynamicHeight = addDynamicPositionedText("Reason For Consultation: ", reqForm.reasonForConsultation, dynamicHeight, reqForm);
dynamicHeight = addDynamicPositionedText("Pertinent Clinical Information: ", reqForm.clinicalInformation, dynamicHeight, reqForm);
dynamicHeight = addDynamicPositionedText("Significant Concurrent Problems: ", reqForm.concurrentProblems, dynamicHeight, reqForm);
dynamicHeight = addDynamicPositionedText("Current Medications: ", reqForm.currentMedications, dynamicHeight, reqForm);
dynamicHeight = addDynamicPositionedText("Allergies: ", reqForm.allergies, dynamicHeight, reqForm);
document.close();
reader.close();
writer.close();
out.close();
// combine the recently created pdf with any pdfs that were added to the consultation request form
combinePDFs(loggedInInfo, fileName);
}
示例14: gravaPdf
import com.lowagie.text.Document; //导入方法依赖的package包/类
public boolean gravaPdf(File fArq) {
Rectangle pageSize = new Rectangle(PageSize.A4);
Document document = new Document(pageSize);
try {
PdfWriter.getInstance(document, new FileOutputStream(fArq));
document.addTitle(sTitulo);
document.open();
Font font = FontFactory.getFont(FontFactory.COURIER, 6, Font.NORMAL, Color.black);
for (int i = 1; i <= getNumPags(); ++i) {
Paragraph paragrafo = new Paragraph(lePagina(i), font);
document.add(paragrafo);
if (bImpEject) {
document.newPage();
}
}
}
catch (DocumentException de) {
System.err.println(de.getMessage());
}
catch (Exception ioe) {
System.err.println(ioe.getMessage());
}
document.close();
return true;
}