List of usage examples for com.itextpdf.text Annotation Annotation
public Annotation(final float llx, final float lly, final float urx, final float ury, final int named)
Annotation
. From source file:org.opentox.io.publishable.PDFObject.java
License:Open Source License
public void publish(YaqpIOStream stream) throws YaqpException { if (stream == null) { throw new NullPointerException("Cannot public pdf to a null output stream"); }//from www. j a v a 2 s . c om try { Document doc = new Document(); try { PdfWriter.getInstance(doc, (OutputStream) stream.getStream()); } catch (ClassCastException ex) { throw new ClassCastException("The stream you provided is not a valid output stream"); } doc.open(); doc.addAuthor(pdfAuthor); doc.addCreationDate(); doc.addProducer(); doc.addSubject(subject); doc.addCreator(pdfCreator); doc.addTitle(pdfTitle); doc.addKeywords(pdfKeywords); doc.addHeader("License", "GNU GPL v3"); Image image = null; try { image = Image.getInstance(new URL(OpenToxLogoUrl)); } catch (Exception ex) {// OpenTox Logo was not found on the web... try {// use the cached image instead YaqpLogger.LOG.log(new Trace(getClass(), "OpenTox Logo not found at " + OpenToxLogoUrl)); image = Image.getInstance(alternativeLogoPath); } catch (Exception ex1) {// if no image at local folder YaqpLogger.LOG.log(new Debug(getClass(), "OpenTox Logo not found at " + alternativeLogoPath + " :: " + ex1)); } } if (image != null) { image.scalePercent(40); image.setAnnotation(new Annotation(0, 0, 0, 0, "http://opentox.org")); Chunk ck_ot = new Chunk(image, -5, -30); doc.add(ck_ot); } try { Image yaqp = Image.getInstance(yaqpLogo); yaqp.scalePercent(30); yaqp.setAnnotation(new Annotation(0, 0, 0, 0, "https://opentox.ntua.gr")); yaqp.setAlt("YAQP(R), yet another QSAR Project"); Chunk ck_yaqp = new Chunk(yaqp, 15, -30); doc.add(ck_yaqp); } catch (Exception ex) { YaqpLogger.LOG .log(new Warning(getClass(), "YAQP Logo not found at " + kinkyDesignLogo + " :: " + ex)); } doc.add(new Paragraph("\n\n\n")); for (Element e : elements) { doc.add(e); } doc.close(); } catch (DocumentException ex) { String message = "Error while generating PDF representation."; YaqpLogger.LOG.log(new Warning(getClass(), message)); throw new YaqpException(XPDF18, message, ex); } }