Searchable PDFs

edited October 2015 in Library Questions

Is it possible to create searchable PDFs in processing?

Answers

  • edited October 2015

    Processing is what we can see in its reference here: https://Processing.org/reference/
    For anything else we need to search for a Java library or write 1 ourselves! ~O)

  • I guess what I mean is: with the PDF library that comes preinstalled with processing is it possible to create a searchable PDF?

    The link on the processing website https://processing.org/reference/libraries/pdf/index.html gives examples of how to create PDFs in different ways, but no examples for searchable PDFs. It doesn't state that it's not possible, so I hope it is ... ... and would like to know how.

  • The PDF library there is to create ".pdf" files from the "canvas".
    I don't think it got any reading/loading capabilities. Much less any searching feature!

  • edited October 2015

    It saves pdf as image

    Not searchable

    You need a lib that can generate text pdf

    In theory you can write a txt file with saveStrings (see reference) and then open it and print it to a pdf printer // or save it as pdf (ms word can do that)

  • Yes you can

    import processing.pdf.*;
    PFont myFont;
    
    void setup() {
      size(200, 200,PDF, "test.pdf");
      textMode(MODEL);
      myFont = createFont("Arial", 32);
      textFont(myFont);
      textAlign(CENTER, CENTER);
    
    }
    
    void draw(){
      text("hoera!", width/2, height/2);
      println("cool");
      exit();
    }
    
  • Not sure if I remember correct but I think text breaks up when using long strings. You should test!

  • Thanks, this is exactly the information I was looking for and your example worked a treat. Unfortunately, when I change the textMode() in my code it doesn't do the same thing as I get the error message:

    "Use textMode(SHAPE) with the default font when exporting to PDF."

    I was using Baskerville & Georgia, so I changed them both to Arial but still got the same message.

    Here's the start of the code:

    void setup() {
      size(9933, 14043, PDF, wDesktop+"Poster.pdf");
      textMode(MODEL);  
    
      //f1 = createFont("Baskerville", 15);
      //f2 = createFont("Georgia", 15);
      f1 = createFont("Arial", 15);
      f2 = createFont("Arial", 15);
    

    I don't see that I'm doing anything different than the example, so could this be an Issue with the library/processing or have I misunderstood the error message?

Sign In or Register to comment.