本文整理汇总了Java中com.lowagie.text.Document.addCreator方法的典型用法代码示例。如果您正苦于以下问题:Java Document.addCreator方法的具体用法?Java Document.addCreator怎么用?Java Document.addCreator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.Document
的用法示例。
在下文中一共展示了Document.addCreator方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: downloadPdfFile
import com.lowagie.text.Document; //导入方法依赖的package包/类
/**
* Generates a PDF file with the given text
* http://itext.ugent.be/itext-in-action/
* @return A PDF file as a byte array
*/
public FileTransfer downloadPdfFile(String contents) throws Exception
{
if (contents == null || contents.length() == 0)
{
contents = "[BLANK]";
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
Document document = new Document();
PdfWriter.getInstance(document, buffer);
document.addCreator("DWR.war using iText");
document.open();
document.add(new Paragraph(contents));
document.close();
return new FileTransfer("example.pdf", "application/pdf", buffer.toByteArray());
}
示例3: 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();
}
示例4: 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();
}
示例5: 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");
}
示例6: 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();
}
示例7: 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();
}
示例8: 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();
}
示例9: 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();
}
示例10: 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();
}
示例11: 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();
}
示例12: 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);
}