本文整理匯總了Java中com.itextpdf.text.Document.addTitle方法的典型用法代碼示例。如果您正苦於以下問題:Java Document.addTitle方法的具體用法?Java Document.addTitle怎麽用?Java Document.addTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.itextpdf.text.Document
的用法示例。
在下文中一共展示了Document.addTitle方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addMetaData
import com.itextpdf.text.Document; //導入方法依賴的package包/類
private static 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");
}
示例2: putPdfInfo
import com.itextpdf.text.Document; //導入方法依賴的package包/類
private void putPdfInfo(Document document) {
document.addAuthor("AswCensuses2B");
document.addCreationDate();
document.addCreator("AswCensuses2B.com");
document.addTitle("Personal Voter Letter");
document.addSubject("A pdf file with your password and user at the online service.");
}
示例3: getPDF
import com.itextpdf.text.Document; //導入方法依賴的package包/類
public Document getPDF() throws Exception {
Document document = new Document();
PdfWriter.getInstance(document, new FileOutputStream(FILE + problem.getPid() + ".pdf"));
Image image = Image.getInstance(this.logo);
document.open();
document.add(image);
document.addCreationDate();
document.add(new Paragraph("Title: "+problem.getTitle()));
document.add(new Paragraph("Code: "+problem.getPid()));
document.add(new Paragraph(" "));
document.add(addParagraph("Description",problem.getDescription(), true));
document.add(addParagraph("Input",problem.getInput(), true));
document.add(addParagraph("Output",problem.getOutput(), true));
document.add(addParagraph("Input Example",problem.getInputex().replaceAll("<br/>", ""), true));
document.add(addParagraph("Output Example",problem.getOutputex(), true));
document.add(new Paragraph("Time(ms): "+problem.getTime()));
document.add(new Paragraph("Memory(kb): "+problem.getMemory()));
document.add(new Paragraph("Source(kb): "+problem.getFontsize()));
document.addTitle("Challenger Online Judge");
document.addAuthor("Chjudge");
document.close();
return document;
}
示例4: makePDF
import com.itextpdf.text.Document; //導入方法依賴的package包/類
private static void makePDF(Bitmap bmp, File file) {
Document document = new Document();
try {
PdfWriter.getInstance(document, new FileOutputStream(file));
document.addAuthor(FullscreenActivity.mAuthor.toString());
document.addTitle(FullscreenActivity.mTitle.toString());
document.addCreator("OpenSongApp");
if (bmp!=null && bmp.getWidth()>bmp.getHeight()) {
document.setPageSize(PageSize.A4.rotate());
} else {
document.setPageSize(PageSize.A4);
}
document.addTitle(FullscreenActivity.mTitle.toString());
document.open();//document.add(new Header("Song title",FullscreenActivity.mTitle.toString()));
BaseFont urName = BaseFont.createFont("assets/fonts/Lato-Reg.ttf", "UTF-8",BaseFont.EMBEDDED);
Font TitleFontName = new Font(urName, 14);
Font AuthorFontName = new Font(urName, 10);
document.add(new Paragraph(FullscreenActivity.mTitle.toString(),TitleFontName));
document.add(new Paragraph(FullscreenActivity.mAuthor.toString(),AuthorFontName));
addImage(document,bmp);
document.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: doInBackground
import com.itextpdf.text.Document; //導入方法依賴的package包/類
@Override
protected Exception doInBackground(String... photos) {
try {
// Get output Directory
// Create the PDF and set some metadata
Document document = new Document(PageSize.A4, DOCUMENT_MARGIN, DOCUMENT_MARGIN, DOCUMENT_MARGIN, DOCUMENT_MARGIN);
Resources resources = mContext.getResources();
document.addTitle(mFilename);
document.addAuthor(resources.getString(R.string.app_name));
document.addSubject(resources.getString(R.string.file_subject));
// Open the file that we will write the pdf to.
java.io.File fileContent = new java.io.File(ImageUtils.getAlbumStorageDir(MainActivity.ALBUM_NAME) + mFilename);
OutputStream outputStream = new FileOutputStream(fileContent);
PdfWriter.getInstance(document, outputStream);
document.open();
// Get the document's size
Rectangle pageSize = document.getPageSize();
float pageWidth = pageSize.getWidth() - (document.leftMargin() + document.rightMargin());
float pageHeight = pageSize.getHeight();
//Loop through images and add them to the document
for (String path : photos) {
Image image = Image.getInstance(path);
image.scaleToFit(pageWidth, pageHeight);
document.add(image);
document.newPage();
}
// Cleanup
document.close();
outputStream.close();
// Upload time!
FileContent mediaContent = new FileContent("application/pdf", fileContent);
File body = new File();
if (mFolder != null)
body.setParents(Arrays.asList(new ParentReference().setId(mFolder.getId())));
body.setTitle(mFilename);
body.setDescription(resources.getString(R.string.file_subject));
body.setMimeType("application/pdf");
Drive.Files.Insert insert = mService.files().insert(body, mediaContent);
MediaHttpUploader uploader = insert.getMediaHttpUploader();
uploader.setDirectUploadEnabled(false);
uploader.setChunkSize(MediaHttpUploader.MINIMUM_CHUNK_SIZE);
uploader.setProgressListener(new FileProgressListener());
File file = insert.execute();
Log.d("C2P", "File Id: " + file.getId());
/* Database Code */
DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
Date date = new Date();
//file.getFileSize().toString()
String parentFolder = mFolder != null ? mFolder.getId() : "root";
Long size = file.getFileSize();
String fileSizeString = humanReadableByteCount(size);
Upload upload = new Upload(-1, mFilename, mFolderPath, fileSizeString, parentFolder, format.format(date), mService.about().get().execute().getUser().getEmailAddress());
UploadDataAdapter mUploadDataAdapter = new UploadDataAdapter(mContext);
mUploadDataAdapter.open();
mUploadDataAdapter.addUpload(upload);
mUploadDataAdapter.close();
} catch (Exception e) {
Log.d("C2P", "ERROR", e);
return e;
}
return null;
}
示例6: generarPdf
import com.itextpdf.text.Document; //導入方法依賴的package包/類
protected File generarPdf(String author, String creator, String subject, String title, String contenido, String ruta, boolean concat) {
Document document = new Document(PageSize.A4, 35, 30, 70, 50);
FileOutputStream fileO;
File file = new File(ruta);
if (!file.exists()) {
try {
if (concat) {
fileO = new FileOutputStream(new File(ruta));
} else {
fileO = new FileOutputStream(ruta);
}
PdfWriter writer = PdfWriter.getInstance(document, fileO);
writer.setBoxSize("art", new Rectangle(36, 54, 559, 788));
HeaderFooter event = new HeaderFooter();
writer.setPageEvent(event);
document.open();
if (!concat) {
document.addAuthor(author);
document.addCreator(creator);
document.addSubject(subject);
document.addCreationDate();
document.addTitle(title);
}
contenido = procesarHtml(contenido);
HTMLWorker htmlWorker = new HTMLWorker(document);
if (concat) {
htmlWorker.newPage();
}
htmlWorker.parse(new StringReader(contenido));
document.close();
File file1 = new File(ruta);
return file1;
} catch (Exception e) {
return null;
}
}
return file;
}