当前位置: 首页>>代码示例>>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;未经允许,请勿转载。