Java Code Examples for com.lowagie.text.Anchor#setReference()
The following examples show how to use
com.lowagie.text.Anchor#setReference() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElementFactory.java From gcs with Mozilla Public License 2.0 | 5 votes |
/** * Creates an Anchor object based on a list of properties. * * @param attributes * @return an Anchor */ public static Anchor getAnchor(Properties attributes) { Anchor anchor = new Anchor(getPhrase(attributes)); String value; value = attributes.getProperty(ElementTags.NAME); if (value != null) { anchor.setName(value); } value = (String) attributes.remove(ElementTags.REFERENCE); if (value != null) { anchor.setReference(value); } return anchor; }
Example 2
Source File: ElementFactory.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * Creates an Anchor object based on a list of properties. * @param attributes * @return an Anchor */ public static Anchor getAnchor(Properties attributes) { Anchor anchor = new Anchor(getPhrase(attributes)); String value; value = attributes.getProperty(ElementTags.NAME); if (value != null) { anchor.setName(value); } value = (String) attributes.remove(ElementTags.REFERENCE); if (value != null) { anchor.setReference(value); } return anchor; }
Example 3
Source File: HelloWorldMultipleTest.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * Generates simple PDF, RTF and HTML files using only one Document object. */ @Test public void main() throws Exception { // step 1: creation of a document-object Document document = new Document(); // step 2: // we create 3 different writers that listen to the document PdfWriter pdf = PdfWriter.getInstance(document,PdfTestBase.getOutputStream("HelloWorldPdf.pdf")); RtfWriter2 rtf = RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("HelloWorldRtf.rtf")); HtmlWriter.getInstance(document, PdfTestBase.getOutputStream("HelloWorldHtml.html")); // step 3: we open the document document.open(); // step 4: we add a paragraph to the document document.add(new Paragraph("Hello World")); // we make references Anchor pdfRef = new Anchor("see Hello World in PDF."); pdfRef.setReference("./HelloWorldPdf.pdf"); Anchor rtfRef = new Anchor("see Hello World in RTF."); rtfRef.setReference("./HelloWorldRtf.rtf"); // we add the references, but only to the HTML page: pdf.pause(); rtf.pause(); document.add(pdfRef); document.add(Chunk.NEWLINE); document.add(rtfRef); pdf.resume(); rtf.resume(); // step 5: we close the document document.close(); }
Example 4
Source File: AHrefTest.java From itext2 with GNU Lesser General Public License v3.0 | 5 votes |
/** * Demonstrates some Anchor functionality. * */ @Test public void main() throws Exception { // step 1: creation of a document-object Document document = new Document(); // step 2: PdfWriter.getInstance(document, PdfTestBase.getOutputStream("AHref.pdf")); HtmlWriter.getInstance(document, PdfTestBase.getOutputStream("AHref.html")); // step 3: we open the document document.open(); // step 4: Paragraph paragraph = new Paragraph("Please visit my "); Anchor anchor1 = new Anchor("website (external reference)", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.UNDERLINE, new Color(0, 0, 255))); anchor1.setReference("http://www.lowagie.com/iText/"); anchor1.setName("top"); paragraph.add(anchor1); paragraph.add(new Chunk(".\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")); document.add(paragraph); Anchor anchor2 = new Anchor("please jump to a local destination", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 255))); anchor2.setReference("#top"); document.add(anchor2); // step 5: we close the document document.close(); }
Example 5
Source File: PdfProcessInformationsReport.java From javamelody with Apache License 2.0 | 5 votes |
private void addPsCommandReference() throws DocumentException { final Anchor psAnchor = new Anchor("ps command reference", PdfFonts.BLUE.getFont()); psAnchor.setName("ps command reference"); psAnchor.setReference("http://en.wikipedia.org/wiki/Ps_(Unix)"); psAnchor.setFont(PdfFonts.BLUE.getFont()); final Paragraph psParagraph = new Paragraph(); psParagraph.add(psAnchor); psParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(psParagraph); }
Example 6
Source File: PdfJavaInformationsReport.java From javamelody with Apache License 2.0 | 5 votes |
private void writeDatabaseVersionAndDataSourceDetails(JavaInformations javaInformations) { if (!noDatabase && javaInformations.getDataBaseVersion() != null) { addCell(getString("Base_de_donnees") + ':'); addCell(javaInformations.getDataBaseVersion()); } if (javaInformations.getDataSourceDetails() != null) { addCell(getString("DataSource_jdbc") + ':'); addCell(javaInformations.getDataSourceDetails()); addCell(""); final Anchor anchor = new Anchor("DataSource reference", PdfFonts.BLUE.getFont()); anchor.setName("DataSource reference"); anchor.setReference("http://commons.apache.org/proper/commons-dbcp/configuration.html"); currentTable.addCell(anchor); } }
Example 7
Source File: PdfCacheInformationsReport.java From javamelody with Apache License 2.0 | 5 votes |
private void addConfigurationReference() throws DocumentException { final Anchor ehcacheAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont()); ehcacheAnchor.setName("Ehcache configuration reference"); ehcacheAnchor.setReference( "http://www.ehcache.org/apidocs/2.9/net/sf/ehcache/config/CacheConfiguration.html#field_summary"); ehcacheAnchor.setFont(PdfFonts.BLUE.getFont()); final Paragraph ehcacheParagraph = new Paragraph(); ehcacheParagraph.add(ehcacheAnchor); ehcacheParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(ehcacheParagraph); }
Example 8
Source File: PdfJobInformationsReport.java From javamelody with Apache License 2.0 | 5 votes |
private void addConfigurationReference() throws DocumentException { final Anchor quartzAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont()); quartzAnchor.setName("Quartz configuration reference"); quartzAnchor.setReference("http://www.quartz-scheduler.org/documentation/"); quartzAnchor.setFont(PdfFonts.BLUE.getFont()); final Paragraph quartzParagraph = new Paragraph(); quartzParagraph.add(quartzAnchor); quartzParagraph.setAlignment(Element.ALIGN_RIGHT); addToDocument(quartzParagraph); }
Example 9
Source File: JavaScriptActionTest.java From itext2 with GNU Lesser General Public License v3.0 | 4 votes |
/** * Creates a document with Named Actions. * */ @Test public void main() throws Exception { // step 1: creation of a document-object Document document = new Document(); // step 2: HtmlWriter.getInstance(document, PdfTestBase.getOutputStream("JavaScriptAction.html")); // step 3: we add Javascript as Metadata and we open the document StringBuffer javaScriptSection = new StringBuffer(); javaScriptSection.append("\t\tfunction load() {\n"); javaScriptSection.append("\t\t alert('Page has been loaded.');\n"); javaScriptSection.append("\t\t}\n"); javaScriptSection.append("\t\tfunction unload(){\n"); javaScriptSection.append("\t\t alert('Page has been unloaded.');\n"); javaScriptSection.append("\t\t}\n"); javaScriptSection.append("\t\tfunction sayHi(){\n"); javaScriptSection.append("\t\t alert('Hi !!!');\n"); javaScriptSection.append("\t\t}"); document.add(new Header(HtmlTags.JAVASCRIPT, javaScriptSection.toString())); document.setJavaScript_onLoad("load()"); document.setJavaScript_onUnLoad("unload()"); document.open(); // step 4: we add some content Phrase phrase1 = new Phrase( "There are 3 JavaScript functions in the HTML page, load(), unload() and sayHi().\n\n" + "The first one will be called when the HTML page has been loaded by your browser.\n" + "The second one will be called when the HTML page is being unloaded,\n" + "for example when you go to another page.\n"); document.add(phrase1); // add a HTML link <A HREF="..."> Anchor anchor = new Anchor("Click here to execute the third JavaScript function."); anchor.setReference("JavaScript:sayHi()"); document.add(anchor); // step 5: we close the document document.close(); }