当前位置: 首页>>代码示例>>Java>>正文


Java PdfAction.javaScript方法代码示例

本文整理汇总了Java中com.lowagie.text.pdf.PdfAction.javaScript方法的典型用法代码示例。如果您正苦于以下问题:Java PdfAction.javaScript方法的具体用法?Java PdfAction.javaScript怎么用?Java PdfAction.javaScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.lowagie.text.pdf.PdfAction的用法示例。


在下文中一共展示了PdfAction.javaScript方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import com.lowagie.text.pdf.PdfAction; //导入方法依赖的package包/类
/**
 * Creates a document with chained Actions.
 * 
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document();

	// step 2:
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("ChainedActions.pdf"));
	// step 3: we add Javascript as Metadata and we open the document
	document.open();
	// step 4: we add some content
	PdfAction action = PdfAction.javaScript("app.alert('Welcome at my site');\r", writer);
	action.next(new PdfAction("http://www.lowagie.com/iText/"));
	Paragraph p = new Paragraph(new Chunk("Click to go to Bruno's site").setAction(action));
	document.add(p);

	// step 5: we close the document
	document.close();

}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:25,代码来源:ChainedActionsTest.java

示例2: main

import com.lowagie.text.pdf.PdfAction; //导入方法依赖的package包/类
/**
 * Creates a document with chained Actions.
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {

	System.out.println("Chained actions");

	// step 1: creation of a document-object
	Document document = new Document();

	try {

		// step 2:
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "ChainedActions.pdf"));
		// step 3: we add Javascript as Metadata and we open the document
		document.open();
		// step 4: we add some content
		PdfAction action = PdfAction.javaScript("app.alert('Welcome at my site');\r", writer);
		action.next(new PdfAction("http://www.lowagie.com/iText/"));
		Paragraph p = new Paragraph(new Chunk("Click to go to Bruno's site").setAction(action));
		document.add(p);
	} catch (Exception de) {
		de.printStackTrace();
	}

	// step 5: we close the document
	document.close();

}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:33,代码来源:ChainedActions.java

示例3: main

import com.lowagie.text.pdf.PdfAction; //导入方法依赖的package包/类
/**
 * Creates a document with some PdfAnnotations.
 * 
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document();

	// step 2:
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("Annotations.pdf"));
	// step 3:
	writer.setPdfVersion(PdfWriter.VERSION_1_5);
	document.open();
	// step 4:
	PdfContentByte cb = writer.getDirectContent();
	// page 1
	PdfFileSpecification fs = PdfFileSpecification.fileExtern(writer, PdfTestBase.RESOURCES_DIR + "cards.mpg");
	writer.addAnnotation(PdfAnnotation.createScreen(writer, new Rectangle(200f, 700f, 300f, 800f), "cards.mpg", fs,
			"video/mpeg", true));
	PdfAnnotation a = new PdfAnnotation(writer, 200f, 550f, 300f, 650f, PdfAction.javaScript(
			"app.alert('Hello');\r", writer));
	document.add(new Chunk("click to trigger javascript").setAnnotation(a).setLocalDestination("top"));
	writer.addAnnotation(a);
	writer.addAnnotation(PdfAnnotation.createFileAttachment(writer, new Rectangle(100f, 650f, 150f, 700f),
			"This is some text", "some text".getBytes(), null, "some.txt"));
	writer.addAnnotation(PdfAnnotation.createText(writer, new Rectangle(200f, 400f, 300f, 500f), "Help",
			"This Help annotation was made with 'createText'", false, "Help"));
	writer.addAnnotation(PdfAnnotation.createText(writer, new Rectangle(200f, 250f, 300f, 350f), "Help",
			"This Comment annotation was made with 'createText'", true, "Comment"));
	cb.rectangle(200, 700, 100, 100);
	cb.rectangle(200, 550, 100, 100);
	cb.rectangle(200, 400, 100, 100);
	cb.rectangle(200, 250, 100, 100);
	cb.stroke();
	document.newPage();
	// page 2
	writer.addAnnotation(PdfAnnotation.createLink(writer, new Rectangle(200f, 700f, 300f, 800f),
			PdfAnnotation.HIGHLIGHT_TOGGLE, PdfAction.javaScript("app.alert('Hello');\r", writer)));
	writer.addAnnotation(PdfAnnotation.createLink(writer, new Rectangle(200f, 550f, 300f, 650f),
			PdfAnnotation.HIGHLIGHT_OUTLINE, "top"));
	writer.addAnnotation(PdfAnnotation.createLink(writer, new Rectangle(200f, 400f, 300f, 500f),
			PdfAnnotation.HIGHLIGHT_PUSH, 1, new PdfDestination(PdfDestination.FIT)));
	writer.addAnnotation(PdfAnnotation.createSquareCircle(writer, new Rectangle(200f, 250f, 300f, 350f),
			"This Comment annotation was made with 'createSquareCircle'", false));
	document.newPage();
	// page 3
	PdfContentByte pcb = new PdfContentByte(writer);
	pcb.setColorFill(new Color(0xFF, 0x00, 0x00));
	writer.addAnnotation(PdfAnnotation.createFreeText(writer, new Rectangle(200f, 700f, 300f, 800f),
			"This is some free text, blah blah blah", pcb));
	writer.addAnnotation(PdfAnnotation.createLine(writer, new Rectangle(200f, 550f, 300f, 650f), "this is a line",
			200, 550, 300, 650));
	writer.addAnnotation(PdfAnnotation.createStamp(writer, new Rectangle(200f, 400f, 300f, 500f),
			"This is a stamp", "Stamp"));
	writer.addAnnotation(PdfAnnotation.createPopup(writer, new Rectangle(200f, 250f, 300f, 350f),
			"Hello, I'm a popup!", true));
	cb.rectangle(200, 700, 100, 100);
	cb.rectangle(200, 550, 100, 100);
	cb.rectangle(200, 250, 100, 100);
	cb.stroke();

	// step 5: we close the document
	document.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:67,代码来源:AnnotationsTest.java

示例4: main

import com.lowagie.text.pdf.PdfAction; //导入方法依赖的package包/类
/**
 * Demonstrates some PageLabel functionality.
 * 
 */
@Test
public void main() throws Exception {

	// step 1: creation of a document-object
	Document document = new Document();
	Document remote = new Document();
	// step 2:
	PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("OutlineActions.pdf"));
	PdfWriter.getInstance(remote, PdfTestBase.getOutputStream("remote.pdf"));
	// step 3:
	writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
	document.open();
	remote.open();
	// step 4:
	// we add some content
	document.add(new Paragraph("Outline action example"));
	// we add the outline
	PdfContentByte cb = writer.getDirectContent();
	PdfOutline root = cb.getRootOutline();
	PdfOutline links = new PdfOutline(root, new PdfAction("http://www.lowagie.com/iText/links.html"),
			"Useful links");
	links.setColor(new Color(0x00, 0x80, 0x80));
	links.setStyle(Font.BOLD);
	new PdfOutline(links, new PdfAction("http://www.lowagie.com/iText"), "Bruno's iText site");
	new PdfOutline(links, new PdfAction("http://itextpdf.sourceforge.net/"), "Paulo's iText site");
	new PdfOutline(links, new PdfAction("http://sourceforge.net/projects/itext/"), "iText @ SourceForge");
	PdfOutline other = new PdfOutline(root, new PdfDestination(PdfDestination.FIT), "other actions", false);
	other.setStyle(Font.ITALIC);
	new PdfOutline(other, new PdfAction("remote.pdf", 1), "Go to yhe first page of a remote file");
	new PdfOutline(other, new PdfAction("remote.pdf", "test"), "Go to a local destination in a remote file");
	new PdfOutline(other, PdfAction.javaScript("app.alert('Hello');\r", writer), "Say Hello");

	remote.add(new Paragraph("Some remote document"));
	remote.newPage();
	Paragraph p = new Paragraph("This paragraph contains a ");
	p.add(new Chunk("local destination").setLocalDestination("test"));
	remote.add(p);

	// step 5: we close the document
	document.close();
	remote.close();
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:47,代码来源:OutlineActionsTest.java

示例5: main

import com.lowagie.text.pdf.PdfAction; //导入方法依赖的package包/类
/**
 * Creates a document with some PdfAnnotations.
 * 
 * @param args
 *            no arguments needed
 */
public static void main(String[] args) {

	System.out.println("PdfAnnotations");

	// step 1: creation of a document-object
	Document document = new Document();
	try {

		// step 2:
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "Annotations.pdf"));
		// step 3:
		writer.setPdfVersion(PdfWriter.VERSION_1_5);
		document.open();
		// step 4:
		PdfContentByte cb = writer.getDirectContent();
		// page 1
		PdfFileSpecification fs = PdfFileSpecification.fileExtern(writer, "cards.mpg");
		writer.addAnnotation(PdfAnnotation.createScreen(writer, new Rectangle(200f, 700f, 300f, 800f), "cards.mpg",
				fs, "video/mpeg", true));
		PdfAnnotation a = new PdfAnnotation(writer, 200f, 550f, 300f, 650f, PdfAction.javaScript(
				"app.alert('Hello');\r", writer));
		document.add(new Chunk("click to trigger javascript").setAnnotation(a).setLocalDestination("top"));
		writer.addAnnotation(a);
		writer.addAnnotation(PdfAnnotation.createFileAttachment(writer, new Rectangle(100f, 650f, 150f, 700f),
				"This is some text", "some text".getBytes(), null, "some.txt"));
		writer.addAnnotation(PdfAnnotation.createText(writer, new Rectangle(200f, 400f, 300f, 500f), "Help",
				"This Help annotation was made with 'createText'", false, "Help"));
		writer.addAnnotation(PdfAnnotation.createText(writer, new Rectangle(200f, 250f, 300f, 350f), "Help",
				"This Comment annotation was made with 'createText'", true, "Comment"));
		cb.rectangle(200, 700, 100, 100);
		cb.rectangle(200, 550, 100, 100);
		cb.rectangle(200, 400, 100, 100);
		cb.rectangle(200, 250, 100, 100);
		cb.stroke();
		document.newPage();
		// page 2
		writer.addAnnotation(PdfAnnotation.createLink(writer, new Rectangle(200f, 700f, 300f, 800f),
				PdfAnnotation.HIGHLIGHT_TOGGLE, PdfAction.javaScript("app.alert('Hello');\r", writer)));
		writer.addAnnotation(PdfAnnotation.createLink(writer, new Rectangle(200f, 550f, 300f, 650f),
				PdfAnnotation.HIGHLIGHT_OUTLINE, "top"));
		writer.addAnnotation(PdfAnnotation.createLink(writer, new Rectangle(200f, 400f, 300f, 500f),
				PdfAnnotation.HIGHLIGHT_PUSH, 1, new PdfDestination(PdfDestination.FIT)));
		writer.addAnnotation(PdfAnnotation.createSquareCircle(writer, new Rectangle(200f, 250f, 300f, 350f),
				"This Comment annotation was made with 'createSquareCircle'", false));
		document.newPage();
		// page 3
		PdfContentByte pcb = new PdfContentByte(writer);
		pcb.setColorFill(new Color(0xFF, 0x00, 0x00));
		writer.addAnnotation(PdfAnnotation.createFreeText(writer, new Rectangle(200f, 700f, 300f, 800f),
				"This is some free text, blah blah blah", pcb));
		writer.addAnnotation(PdfAnnotation.createLine(writer, new Rectangle(200f, 550f, 300f, 650f),
				"this is a line", 200, 550, 300, 650));
		writer.addAnnotation(PdfAnnotation.createStamp(writer, new Rectangle(200f, 400f, 300f, 500f),
				"This is a stamp", "Stamp"));
		writer.addAnnotation(PdfAnnotation.createPopup(writer, new Rectangle(200f, 250f, 300f, 350f),
				"Hello, I'm a popup!", true));
		cb.rectangle(200, 700, 100, 100);
		cb.rectangle(200, 550, 100, 100);
		cb.rectangle(200, 250, 100, 100);
		cb.stroke();

	} catch (Exception de) {
		de.printStackTrace();
	}

	// step 5: we close the document
	document.close();
}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:75,代码来源:Annotations.java

示例6: main

import com.lowagie.text.pdf.PdfAction; //导入方法依赖的package包/类
/**
 * Demonstrates some PageLabel functionality.
 * 
 * @param args
 *            no arguments needed here
 */
public static void main(String[] args) {

	System.out.println("Outlines with actions");

	// step 1: creation of a document-object
	Document document = new Document();
	Document remote = new Document();
	try {
		// step 2:
		PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "OutlineActions.pdf"));
		PdfWriter.getInstance(remote, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "remote.pdf"));
		// step 3:
		writer.setViewerPreferences(PdfWriter.PageModeUseOutlines);
		document.open();
		remote.open();
		// step 4:
		// we add some content
		document.add(new Paragraph("Outline action example"));
		// we add the outline
		PdfContentByte cb = writer.getDirectContent();
		PdfOutline root = cb.getRootOutline();
		PdfOutline links = new PdfOutline(root, new PdfAction("http://www.lowagie.com/iText/links.html"),
				"Useful links");
		links.setColor(new Color(0x00, 0x80, 0x80));
		links.setStyle(Font.BOLD);
		new PdfOutline(links, new PdfAction("http://www.lowagie.com/iText"), "Bruno's iText site");
		new PdfOutline(links, new PdfAction("http://itextpdf.sourceforge.net/"), "Paulo's iText site");
		new PdfOutline(links, new PdfAction("http://sourceforge.net/projects/itext/"), "iText @ SourceForge");
		PdfOutline other = new PdfOutline(root, new PdfDestination(PdfDestination.FIT), "other actions", false);
		other.setStyle(Font.ITALIC);
		new PdfOutline(other, new PdfAction("remote.pdf", 1), "Go to yhe first page of a remote file");
		new PdfOutline(other, new PdfAction("remote.pdf", "test"), "Go to a local destination in a remote file");
		new PdfOutline(other, PdfAction.javaScript("app.alert('Hello');\r", writer), "Say Hello");

		remote.add(new Paragraph("Some remote document"));
		remote.newPage();
		Paragraph p = new Paragraph("This paragraph contains a ");
		p.add(new Chunk("local destination").setLocalDestination("test"));
		remote.add(p);
	} catch (DocumentException de) {
		System.err.println(de.getMessage());
	} catch (IOException ioe) {
		System.err.println(ioe.getMessage());
	}

	// step 5: we close the document
	document.close();
	remote.close();
}
 
开发者ID:fc-dream,项目名称:PDFTestForAndroid,代码行数:56,代码来源:OutlineActions.java


注:本文中的com.lowagie.text.pdf.PdfAction.javaScript方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。