Problems with path when reading in files

Help
2008-01-25
2013-05-28
  • Paul Mattocks
    Paul Mattocks
    2008-01-25

    Hi,

    Firstly thanks for providing a great library!

    Now onto the issue I am having!

    I have the following method:-

      /**
       * read a pdf document.
       */
      protected void readFile(String location) throws IOException
      {
        Debug.logInfo("File location passed into PDFIngestService:" + location, module);
        FileLocator locator = new FileLocator(location);
        try
        {
          document = PDDocument.createFromLocator(locator);
        }
        catch (COSLoadException e)
        {
          Debug.logInfo("Problem parsing PDF document. Check format.", module);
        }
      }

    The issue I am having is that the filename the locator is using has my local path appended, ie: the path I pass in is:

    http://uat.schemetrack.net/img/aviva/TempDocs/Doc01.doc

    and the path the createFromLocator method uses is:-

    /home/paulm/workspace/http:/uat.schemetrack.net/img/aviva/TempDocs/Doc01.doc

    It appears to append my local path when trying to access the file.

    Any advice you could give would be much appreciated.

    Thanks In Advance,

    Paul M.

     
    • Waldemar Dick
      Waldemar Dick
      2008-01-25

      Hello Paul,

      >The issue I am having is that the filename the locator is using has my local path appended,
      >ie: the path I pass in is:  http://webadress/img/aviva/TempDocs/Doc01.doc

      The class FileLocator just handles local files and not URLs. So the FileLocator behaves as expected. You have to load the URL yourself and store it either in a temporary file or in memory. Then you can access the temporary file with a FileLocator (new FileLocator("path/to/tempFile")) or use a ByteArrayLocator to access a in memory byte array, if you saved the URL's document in memory.

      The other thing is, it seems like you are trying to load a Word document (Doc01.doc), which will not work. You can only load PDF documents with the jPod library. If you want to convert the doc file to a PDF document, then you will have to use one of the many Ghostscript bases PDF printers.

      Greeting,

      wdick

       
    • Paul Mattocks
      Paul Mattocks
      2008-01-28

      Many thanks for the reply. Apologies the example I stated was using a word document but I was using a PDF file in actual code!

      I thought it may be an issue with using a http location in the locator!

      Problem is now fixed!

      Regards,

      Paul.