當前位置: 首頁>>代碼示例>>Java>>正文


Java Document.addAuthor方法代碼示例

本文整理匯總了Java中com.itextpdf.text.Document.addAuthor方法的典型用法代碼示例。如果您正苦於以下問題:Java Document.addAuthor方法的具體用法?Java Document.addAuthor怎麽用?Java Document.addAuthor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.itextpdf.text.Document的用法示例。


在下文中一共展示了Document.addAuthor方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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");
}
 
開發者ID:gonzapala,項目名稱:CPI,代碼行數:8,代碼來源:generarPDF.java

示例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.");
}
 
開發者ID:Arquisoft,項目名稱:Voting_2b,代碼行數:8,代碼來源:PDFLetterWriter.java

示例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;
}
 
開發者ID:dovier,項目名稱:coj-web,代碼行數:24,代碼來源:PDFExportProblem.java

示例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();
    }
}
 
開發者ID:thebigg73,項目名稱:OpenSongTablet,代碼行數:26,代碼來源:ExportPreparer.java

示例5: save

import com.itextpdf.text.Document; //導入方法依賴的package包/類
public static final void save(File file, Component c, int width, int height) {
	if (file == null) {
		logger.log(Level.WARNING, "no file selected");
		return;
	}
	if (c == null) {
		logger.log(Level.WARNING, "no component provided");
		return;
	}
	try {
		Document document = new Document(new Rectangle(width, height));
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file.getAbsolutePath()));
		document.addAuthor("UJMP v" + UJMP.UJMPVERSION);
		document.open();
		PdfContentByte cb = writer.getDirectContent();
		PdfTemplate tp = cb.createTemplate(width, height);
		Graphics2D g2 = new PdfGraphics2D(cb, width, height, new DefaultFontMapper());
		if (c instanceof CanRenderGraph) {
			((CanRenderGraph) c).renderGraph(g2);
		} else {
			c.paint(g2);
		}
		g2.dispose();
		cb.addTemplate(tp, 0, 0);
		document.close();
		writer.close();
	} catch (Exception e) {
		logger.log(Level.WARNING, "could not save PDF file", e);
	}
}
 
開發者ID:ujmp,項目名稱:universal-java-matrix-package,代碼行數:31,代碼來源:ExportPDF.java

示例6: 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;
}
 
開發者ID:rockwotj,項目名稱:Cam2PDF,代碼行數:63,代碼來源:UpvertTask.java

示例7: 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;
    }
 
開發者ID:dovier,項目名稱:coj-web,代碼行數:51,代碼來源:BasePdf.java

示例8: writeAsPDF

import com.itextpdf.text.Document; //導入方法依賴的package包/類
/**
 * Save chart as PDF file. Requires iText library.
 * 
 * @param chart JFreeChart to save.
 * @param fileName Name of file to save chart in.
 * @param width Width of chart graphic.
 * @param height Height of chart graphic.
 * @throws Exception if failed.
 * @see <a href="http://www.lowagie.com/iText">iText</a>
 */
@SuppressWarnings("deprecation")
public static void writeAsPDF(File fileToSave, int width, int height) throws Exception {
	
	if (chart != null)
	{
		BufferedOutputStream out = null;
		try
		{
			out = new BufferedOutputStream(new FileOutputStream(fileToSave.getAbsolutePath()));
			
			// convert chart to PDF with iText:
			Rectangle pagesize = new Rectangle(width, height);
			Document document = new Document(pagesize, 50, 50, 50, 50);
			try
			{
				PdfWriter writer = PdfWriter.getInstance(document, out);
				document.addAuthor("JFreeChart");
				document.open();
				
				PdfContentByte cb = writer.getDirectContent();
				PdfTemplate tp = cb.createTemplate(width, height);
				Graphics2D g2 = tp.createGraphics(width, height, new DefaultFontMapper());
				
				Rectangle2D r2D = new Rectangle2D.Double(0, 0, width, height);
				chart.draw(g2, r2D, null);
				g2.dispose();
				cb.addTemplate(tp, 0, 0);
			}
			finally
			{
				document.close();
			}
		}
		finally
		{
			if (out != null)
				out.close();
		}
	}
}
 
開發者ID:petebrew,項目名稱:fhaes,代碼行數:51,代碼來源:SSIZCurveChart.java

示例9: PDFLabelMaker

import com.itextpdf.text.Document; //導入方法依賴的package包/類
public PDFLabelMaker(LabelPage margins, OutputStream output) throws IOException, DocumentException {
	this.margins = margins;
	
	float sides, page, h, w, labelGap;

	// calculate the number of labels wide this page is
	page = margins.getPageSize().getWidth();
	labelGap = margins.getLabelHorizontalGap();
	w = margins.getLabelWidth();
	sides = margins.getPageLeftMargin() + margins.getPageRightMargin();
	if(sides + w > page)
		throw new IllegalArgumentException("0 labels fit across");
	
	for(int i = 1; sides + (((float)i) * w) + (((float)(i - 1)) * labelGap) <= page; i++) {
		nAcross = i;
	}

	// the number of labels 'tall'
	page = margins.getPageSize().getHeight();
	labelGap = margins.getLabelVerticalGap();
	h = margins.getLabelHeight();
	sides = margins.getPageTopMargin() + margins.getPageBottomMargin();
	if(sides + h > page)
		throw new IllegalArgumentException("0 labels fit down");
	
	for(int i = 1; sides + (((float)i) * h) + (((float)(i - 1)) * labelGap) <= page; i++) {
		nDown = i;
	}

	System.out.println("LABELS: across: " + nAcross + ", down: " + nDown);
	
	document = new Document(margins.getPageSize());
	PdfWriter writer = PdfWriter.getInstance(document, output);
	document.addAuthor("Tellervo Label Generator");
	document.addCreationDate();
	
	document.open();
	
	contentb = writer.getDirectContent();
	// first off, pdfs are weird and go from high y coordinates to low for pages (ie, highest y = top of page)
	// also, this sets the page margins
	new ColumnText(contentb).setSimpleColumn(
			margins.getPageLeftMargin(), 	// lower x margin
			margins.getPageBottomMargin(),	// bottom y margin
			margins.getPageSize().getWidth() - (margins.getPageRightMargin() + margins.getPageLeftMargin()),  // upper x margin
			margins.getPageSize().getHeight() - (margins.getPageTopMargin() + margins.getPageBottomMargin()), // upper y margin
			0, 						// no leading
			Element.ALIGN_MIDDLE	// align in the middle of the label
			);
	
	int realCols = nAcross + nAcross - 1; // number of labels + number of intra-label gaps
	
	float colwidth[] = new float[realCols];
	float totalWidth = 0;
	for(int i = 0; i < realCols; i++) {
		if((i & 1) == 1) {
			// odd, so it's a margin
			totalWidth += margins.getLabelHorizontalGap();
			colwidth[i] = margins.getLabelHorizontalGap();
		}
		else {
			// even, so it's an actual label
			totalWidth += margins.getLabelWidth();
			colwidth[i] = margins.getLabelWidth();
		}
	}
			
	table = new PdfPTable(realCols); 
	table.setTotalWidth(totalWidth);
	table.setWidths(colwidth);
	table.setLockedWidth(true);
	table.getDefaultCell().setPadding(0);
	table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_MIDDLE);
	table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
	

}
 
開發者ID:ltrr-arizona-edu,項目名稱:tellervo,代碼行數:78,代碼來源:PDFLabelMaker.java


注:本文中的com.itextpdf.text.Document.addAuthor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。