<%@ page import="com.lowagie.text.Document"%> <%@ page import="com.lowagie.text.Table"%> <%@ page import="com.lowagie.text.PageSize"%> <%@ page import="com.lowagie.text.Cell"%> <%@ page import="com.lowagie.text.Anchor"%> <%@ page import="com.lowagie.text.Image"%> <%@ page import="com.lowagie.text.Jpeg"%> <%@ page import="com.lowagie.text.Chunk"%> <%@ page import="com.lowagie.text.Phrase"%> <%@ page import="com.lowagie.text.FontFactory"%> <%@ page import="com.lowagie.text.Font"%> <%@ page import="com.lowagie.text.HeaderFooter"%> <%@ page import="com.lowagie.text.pdf.PdfWriter"%> <%@ page import="java.io.BufferedOutputStream"%> <%@ page import="java.io.ByteArrayOutputStream"%> <%@ page import="java.awt.Color" %> <%@ page import="java.text.SimpleDateFormat"%> <%@ page import="java.io.File"%> <%@ page import="java.net.URL"%> <%@ page import="java.net.URLEncoder"%> <%@ page import="java.net.MalformedURLException"%> <%@ page import="java.io.IOException"%> <%@ page import="java.io.FileOutputStream"%> <%@ page import="java.io.FileInputStream"%> <%@ page import="java.io.InputStream"%> <%@ page import="java.util.Properties"%> <%@ page import="java.util.Vector"%> <%@ page import="org.crosswire.community.data.User"%> <%@ page import="org.crosswire.xml.XMLRepo"%> <%@ page import="org.crosswire.sword.mgr.SWMgr"%> <%@ page import="org.crosswire.sword.modules.SWModule"%> <%@ page import="org.crosswire.sword.mgr.SWConfig"%> <%@ page import="com.objectspace.jgl.HashMap"%> <%@ page import="com.objectspace.jgl.Map"%> <% response.setContentType("application/x-pdf"); response.setHeader("Content-Disposition","attachment; filename=document.pdf"); String user = request.getParameter("user"); if (user == null) { User loginUser = (User) session.getAttribute("user"); if (loginUser != null) user = loginUser.getID(); } String doc = request.getParameter("doc"); if (doc == null) { doc = (String)session.getAttribute("modName"); } if (user == null || doc == null) return; SimpleDateFormat df = new SimpleDateFormat("dd-MMM-yyyy"); String root = session.getServletContext().getContextPath(); String libURL = "/users/" + user + "/library"; String libPath = session.getServletContext().getRealPath(libURL); XMLRepo repo = XMLRepo.instance(pageContext); org.crosswire.community.data.Document modDoc = (org.crosswire.community.data.Document)repo.get(new org.crosswire.community.data.Document(user, doc), false); if (modDoc != null) { String baseURL = modDoc.getBaseURL(); String desc = modDoc.getDescription(); String abbr = modDoc.getAbbrevPref(); String otherAbbr = modDoc.getAbbrevOther(); String dateMean = modDoc.getDateMean(); String dateRange = modDoc.getDateRange(); String gaName = modDoc.getGAName(); String legal = "The requirements that need to be satisfied for using these images in publication vary from manuscript to manuscript. Each possessing institute or individual has its own requirements. If you wish to publish any of these images, you will need to get permission from CSNTM first. We can then direct you to the contact person of the institute that owns the manuscript(s) for further instructions. CSNTM does not charge for the use of these images, though the institute that owns the manuscripts may. At minimum, CSNTM needs to be credited with the photographs and the possessing institute needs to be credited with ownership of the manuscript in all research for which these images are used."; Document document = new Document(PageSize.A4, 25, 25, 25, 25); try { // creation of the different writers PdfWriter.getInstance(document, response.getOutputStream()); document.addAuthor("CSNTM"); document.addSubject(modDoc.getGAName()); document.setHeader(new HeaderFooter(new Phrase(gaName, FontFactory.getFont(FontFactory.HELVETICA, 14, Font.BOLD, new Color(0, 0, 0))), false)); document.open(); int colCount = 3; Table table = new Table(colCount); table.setBorderWidth(1); table.setBorderColor(new Color(0, 0, 255)); table.setPadding(5); table.setSpacing(0); Cell cell = new Cell(new Chunk("Gregory Aland Name", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); cell = new Cell(gaName); cell.setColspan(colCount-1); table.addCell(cell); cell = new Cell(new Chunk("Description", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); cell = new Cell(desc); cell.setColspan(colCount-1); table.addCell(cell); cell = new Cell(new Chunk("Preferred Abbreviation", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); cell = new Cell(abbr); cell.setColspan(colCount-1); table.addCell(cell); cell = new Cell(new Chunk("Other Abbreviations", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); cell = new Cell(otherAbbr); cell.setColspan(colCount-1); table.addCell(cell); cell = new Cell(new Chunk("Mean Date\n(e.g., IV = 350)", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); cell = new Cell(dateMean); cell.setColspan(colCount-1); table.addCell(cell); cell = new Cell(new Chunk("Date Range\n(e.g., IV = 100)", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); cell = new Cell(dateRange); cell.setColspan(colCount-1); table.addCell(cell); cell = new Cell(new Chunk("Image Use", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); cell = new Cell(new Chunk(legal, FontFactory.getFont(FontFactory.HELVETICA, 8, Font.NORMAL, new Color(0, 0, 0)))); cell.setColspan(colCount-1); table.addCell(cell); cell = new Cell(new Chunk("Description", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); cell = new Cell(new Chunk("Biblical Coverage", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); cell = new Cell(new Chunk("Image Filename", FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)))); cell.setHeader(true); table.addCell(cell); for (org.crosswire.community.data.Document.Page p: modDoc.getPages()) { String fullURL = baseURL + "/"+p.getURL(); String cacheName = libURL + "/modules/"+doc+"/cache/" + p.getURL().hashCode() + ".jpg"; File cacheFile = new File(request.getSession().getServletContext().getRealPath(cacheName)); Anchor anchor = new Anchor(p.getDescription()); anchor.setName("LINK"); anchor.setReference(fullURL); table.addCell(new Cell(anchor)); anchor = new Anchor(p.getBibleCoverage()); anchor.setName("LINK"); anchor.setReference(fullURL); table.addCell(new Cell(anchor)); anchor = new Anchor(p.getURL()); anchor.setName("LINK"); anchor.setReference(fullURL); table.addCell(new Cell(anchor)); /* Jpeg thumb = new Jpeg(cacheFile.toURL()); table.addCell(new Cell(thumb)); */ } document.add(table); } catch(Exception e) { System.err.println(e.getMessage()); } document.close(); } %>