Package net.sf.jpluck.plucker

Examples of net.sf.jpluck.plucker.TextRecord


        }
        return imageRecord;
    }

    public TextRecord createTextRecord(String encoding, boolean hires) {
        TextRecord textRecord = new TextRecord((isRedirected() ? redirectionURI : uri), encoding, hires);
        if (isRedirected()) {
            textRecord.setAlternateURI(uri);
        }
        return textRecord;
    }
View Full Code Here


        }
    }

    private void addTextRecord(String uri, String redirectionURI, Node node)
                        throws Exception {
        TextRecord textRecord = new TextRecord(((redirectionURI != null) ? redirectionURI : uri),
                                               jxlDocument.getOutputEncoding(), jxlDocument.isUseHiresMargins());
        if (redirectionURI != null) {
            textRecord.setAlternateURI(uri);
        }
        TextRecordResult result = new TextRecordResult(textRecord, jxlDocument.getURIRewriter(),
                                                       jxlDocument.getTextColorBrightness(),
                                                       jxlDocument.isParseTables(), pluckerDocument);
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
View Full Code Here

        byte[] data = baos.toByteArray();
        Document document = new Document();
        if (mimeType.equals("text/html")) {
      Resource resource = new Resource("http://127.0.0.1/", null, new ContentType(mimeType), data, 0, false);
      org.w3c.dom.Document dom = resource.parseHTML();
      TextRecord textRecord = new TextRecord("http://127.0.0.1/");
      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      TextRecordResult result = new TextRecordResult(textRecord, new URIRewriter(), 100, false, document);
      transformer.transform(new DOMSource(dom), result);
      document.addRecord(textRecord);
        } else if (mimeType.startsWith("image/")) {
View Full Code Here

  public static void main(String[] args) throws Exception {
    Document document = new Document("Bookmark Test");
    for (int i = 1; i <= 10; i++) {
      String uri = "page" + i;
      TextRecord page = new TextRecord(uri);
      String name = "Page " + i;
      page.addParagraph().addFontH1().addText(name).addAnchor("anchor");
     
      document.addBookmark(name, uri + "#anchor");
      document.addRecord(page);
    }
    document.setIncludeURIInfo(true);
View Full Code Here

      boolean generateBookmarks = ClientConfiguration.getDefault().isGenerateBookmarks();
      if (settings.isUsePageStructure()) {
        FeedItem[] items = feed.getItems();
        for (int i = 0, n = items.length; i < n; i++) {
          String uri = resource.getURI() + "_item-" + (i + 1);
          TextRecord textRecord = new TextRecord(uri,
                               jxlDocument.getOutputEncoding(),
                               jxlDocument.isUseHiresMargins());
          HTMLSerializer serializer = new HTMLSerializer(textRecord, jxlDocument.getURIRewriter(),
                                   settings.getTextColorBrightness(), settings.isParseTables(),
                                   pluckerDocument);
          Transformer transformer = TransformerFactory.newInstance().newTransformer();
          transformer.transform(new DOMSource(formatter.getItemDocuments()[i]), new SAXResult(serializer));
          pluckerDocument.addRecord(serializer.getDataRecord());
         
          String[] pageURIs = serializer.getLinkURIs();
          for (int j = 0; j < pageURIs.length; j++) {
            if (!pageURIs[j].startsWith(resource.getURI() + "_item-")) {
              addPageLink(pageURIs[j]);
            }
          }

          String[] imageURIs = serializer.getEmbeddedImageURIs();
          for (int j = 0; j < imageURIs.length; j++) {
            addImageLink(imageURIs[j]);
          }

          if (generateBookmarks) {
            addBookmark(items[i], formatter, uri);         
          }
        }
      } else {
        FeedItem[] items = feed.getItems();
        for (int i = 0; i < items.length; i++) {
          FeedItem item = items[i];
          URIRewriter rewriter = jxlDocument.getURIRewriter();
          String uri = rewriter.rewrite(item.getURL());
          if (generateBookmarks && settings.isUseLinkStructure()) {
            addBookmark(items[i], formatter, uri);
          }
        }
      }

      Transformer transformer = TransformerFactory.newInstance().newTransformer();
      TextRecord textRecord = resource.createTextRecord(jxlDocument.getOutputEncoding(),
                                jxlDocument.isUseHiresMargins());
      TextRecordResult result = new TextRecordResult(textRecord, jxlDocument.getURIRewriter(),
                               settings.getTextColorBrightness(), settings.isParseTables(),
                               pluckerDocument);
      transformer.transform(new DOMSource(formatter.getIndexDocument()), result);
View Full Code Here

import net.sf.jpluck.plucker.TableRow;
import net.sf.jpluck.plucker.TextRecord;

public class TableTest {
    public static void main(String[] args) throws Exception {
        TextRecord home = new TextRecord("home");
        home.addParagraph().addTable("table");

        TableRecord table = new TableRecord("table", 1, Color.GREEN);

        TableRow row = table.addRow();
        TableCell cell = row.addCell();
View Full Code Here

        category = category.substring(0, 15).trim();
      }
      document.setCategories(new String[] { category });
    }
   
    TextRecord home=new TextRecord("home");
    home.addParagraph().addFontH1().addText(name).addFontRegular();    

    for (int i = 1; i < arguments.length; i++) {
      System.out.println(arguments[i] + " (" + i + "/" + (arguments.length-1) + ")");
      File file = new File(arguments[i]);
      if (!file.isFile()) {
        throw new IOException("Not a file: " + file.getAbsolutePath());
      }
      BufferedImage image = ImageIO.read(file);

      int width = image.getWidth();
      int height = image.getHeight();
      image = ImageConverter.rescale(image, ((maxWidth > 0) ? maxWidth : width),
                   ((maxHeight > 0) ? maxHeight : height));

      CompositeBitmap compositeBitmap = CompositeBitmap.create(image, bpp);
      String uri = file.toURI().toString();     
      home.addParagraph(2).addText(i + " ").addLinkStart(uri).addText(file.getName()).addLinkEnd();
     
      String[] uris = new String[compositeBitmap.getRows()];
      for (int j = 0, n = compositeBitmap.getRows(); j < n; j++) {
        uris[j] = uri + "-" + j;
        document.addRecord(new ImageRecord(uris[j], compositeBitmap.getBitmapAt(j, 0)));
View Full Code Here

    super(pluckerDocument, jxlDocument, resource);
  }

  public void handle() throws HandlingException {
    try {
      TextRecord textRecord = new TextRecord(resource.getURI(), jxlDocument.getOutputEncoding(),
                           jxlDocument.isUseHiresMargins());
      String charset = resource.getCharset();
      if (charset == null) {
        charset = "ISO-8859-1";
      }
      LineNumberReader rdr = new LineNumberReader(new InputStreamReader(new ByteArrayInputStream(resource.getData()),
                                        charset));
      Paragraph paragraph = textRecord.addParagraph(Paragraph.DEFAULT_SPACING);
      for (String line; (line = rdr.readLine()) != null;) {
        if (line.length() == 0) {
          paragraph = textRecord.addParagraph(Paragraph.DEFAULT_SPACING);
        } else {
          int start = line.indexOf("http://");
          if (start > -1) {
            int end = line.indexOf(' ', start);
            if (end == -1) {
View Full Code Here

TOP

Related Classes of net.sf.jpluck.plucker.TextRecord

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.