Convert PDF File to ASCII / Text File

Hello,
I have a PDF File that was created from a Spools (Output of Smart Form to begin with and run in background) using the SAP Function module - CONVERT_OTFSPOOLJOB_2_PDF and I have the pdf file archived.
Now, I need to do Reverse process. The original Spool is gone, and I need to extract some data from the pdf file - say, for example:
I need to extract A/c numbers where the Label is "Account No:" followed by value of the Account No.
I opened the pdf file in Binary mode, stored into an internal table of type Hex and then LOOP ed through this table.
Moved the Hex data to a long enough data field of Type C to use "CS" operator in an IF Statement to look for the String "4163636F756E74204E6F3A" which is Hex representation of  'Account No:' (without the single quotes).
I can see 'Account No:' in the PDF File but my IF Statement with CS fails. I even tried to find the Zip Code using CS Statement - it fails too.
Some sample codes that I used are as follows:
  LV_TAG_1_C = '4163636F756E74204E6F3A'.
refresh: T_DATA_FILE_C.
  LOOP AT T_DATA_FILE_X.
    ASSIGN T_DATA_FILE_C-DATA TO <FS_C>.
    T_DATA_FILE_C-DATA     = T_DATA_FILE_X-DATA.
    IF T_DATA_FILE_C-DATA CS LV_TAG_1_C.
* The Above IF Statement NEVER became TRUE - even though I can see the "Account No:"
      LV_VAL_1_C = <FS_C>+SY-FDPOS(6).
      APPEND T_DATA_FILE_C.
    ENDIF.
  ENDLOOP.
Outside LOOP, T_DATA_FILE_C is still EMPTY.
Please let me know if you know of any example where I can extract data in ASCII format from a PDF File.
Please NOTE - I do NOT need to convert a spool to PDF File (whole website is full of this) - I need the opposite !!!
Help will be much appreciated.
Regards,
Tarun
Message was edited by: Matthew Billingham - email address removed

Hello Manish,
Thanks a lot for your suggestion. This pdf file is really not a 1 to 1 representation of ASCII to Hex and vice verse. Your suggestion is really good.
I think, we are very close. Do you know the Function Module name that I need to use - this is what we have in ECC / R/3. An example with which Function module I need to use with some sample code - basically, what I need to supply and where does the result go - will be great.
Thanks again Manish.
INCLUDE LSSXPU01.   "SXPG_STEP_XPG_START
INCLUDE LSSXPU02.   "SXPG_STEP_END
INCLUDE LSSXPU03.   "SXPG_STEP_COMMAND_START
INCLUDE LSSXPU04.   "SXPG_JOB_END
INCLUDE LSSXPU05.   "SXPG_STEP_START_UPDATE
INCLUDE LSSXPU06.   "SXPG_STEP_END_UPDATE
INCLUDE LSSXPU07.   "SXPG_JOB_END_UPDATE
INCLUDE LSSXPU08.   "SXPG_COMMAND_CHECK
INCLUDE LSSXPU09.   "SXPG_DUMMY_COMMAND_CHECK
INCLUDE LSSXPU10.   "SXPG_APPSERV_RFCDEST_GET_INT
INCLUDE LSSXPU11.   "SXPG_RFCDEST_OPEN_INT
INCLUDE LSSXPU12.   "SXPG_COMMAND_CHECK_INT

Similar Messages

  • How to convert a HTML files into a text file using Java

    Hi guys...!
    I was wondering if there is a way to convert a HTML file into a text file using java programing language. Likewise I would also like to know if there is a way to convert any type of file (excel, power point, and word) into text using java.
    By the way, I really appreciated the help that you guys gave me on my previous topic on how to extract tests from a pdf file.
    Thank you....

    HTML files are already text files. What do you mean you want to convert them?
    I think if you search the web, you can find things for converting those MS Office files to text (or extracting text from them, as I assume you mean).

  • How do I convert an audio mp3 file to a text file?

    How do I convert an audio mp3 file to a text file?

    StephenInAZ wrote:
    I keep responding to posters here but my responses dissapear.
    there were reasons for that, see:
    https://discussions.apple.com/static/apple/tutorial/tou.html

  • How can I convert a mp3 to a text file?

    How can I convert a mp3 to a text file?

    Agree with dwb
    .. and wanted to say hi from my Schnauzer....

  • How to convert a Form to a Text file and XML file?

    Hi:
    I want to convert a Form to a Text file and XML file,but I don't know how convert?
    Please help!
    Oracle Form Builder V10.1.2.0.2
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
    Thanks in advance!

    ..or follow the steps in Mtalink note; Doc ID: Note:196924.1
    Forms XML Conversion Feature ( Converting Forms To XML)

  • How to save the contents of a file(not a text file)

    Hi all, I want to save the contents of a file(,png file, not a text file) as a field in a class. Shall I have it as a string or byte array or something?
    I have tried saving a file in a string but there were some problems with loading the file from a different platform. Following is my code.
            String string;
            try {
                StringBuffer sb = new StringBuffer(1024);
                char[] characterArray = new char[1024];
                BufferedReader br = new BufferedReader(new FileReader(file));
                while(br.read(characterArray) != -1){
                    sb.append(String.valueOf(characterArray));
                br.close();
                string= sb.toString();
            } catch (IOException ex) {
                ex.printStackTrace();
            }and I use the following code to recover the string back to a stream, and save that stream back to a time later.
        ByteArrayInputStream bais = new ByteArrayInputStream(map.getBytes());I realized that because this file is not a text file, the string could cause some problems. But anyone could tell me if I should use a byte array or someting? and how?
    Any help would be appreciated!
    Cheers,
    Jing

    You should use a byte array, and the binary streams (InputStream a& OutputStream). Never use Strings and Reader/Writer if you have binary data.
    Kaj

  • How to write the location of a file in a text file?

    Hello All,
    I am doing a POC with the following scenario:
    Steps:
    1. Move a file from one location in your system to another location, say from C drive to D drive.
    2. After that i want to write the new location of the file in a text file.
    I have succesfully moved the file from C drive to D drive using the File Adapter and also FTP Adapter. However I am unable to copy or write the new location of the file into a text file. Please provide me any suggestions regarding this issue i am facing. Your help and support is highly appreciated. Thanks in advance.

    Hi,
    If want the file directory name to be captured in the BPEL process then add <element name="directory" type="string"/> in the inbound or outbound adapter header wsdl file. Then declare a variable of the header message type and in the 'adapter' tab of the receive or invoke activity select that variable which you previously created.
    Hope this helps.
    Rdgs.

  • Copy one text file to another text file and delete last line

    Hi all wonder if someone can help, i want to be able to copy one text file to another text file and remove the last line of the first text file. So currently i have this method:
    Writer output = null;
             File file = new File("playerData.xml");
             try {
                   output = new BufferedWriter(new FileWriter(file, true));
                   output.write("\t" + "<player>" + "\n");
                   output.write("\t" + "\t" + "<playerName>" + playerName + "</playerName>" + "\n");
                   output.write("\t" + "\t" + "<playerScore>" + pointCount + "</playerScore>" + "\n");
                   output.write("\t" + "\t" + "<playerTime>" + minutes + " minutes " + seconds + " seconds" + "</playerTime>" + "\n");
                   output.write("\t" + "</player>" + "\n");
                   output.write("</indianaTuxPlayer>" + "\n");
                  output.close();
                  System.out.println("Player data saved!");
             catch (IOException e) {
                   e.printStackTrace();
              }However each time the method is run i get the "</indianaTuxPlayer>" line repeated, now when i come to read this in as a java file i get errors becuase its not well formed. So my idea is to copy the original file, remove the last line of that file, so the </indianaTuxPlayer> line and then add this to a new file with the next data saved in it. So i would end up with something like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <indianaTuxPlayers>
         <player>
              <playerName>Default Player</playerName>
              <playerScore>0</playerScore>
              <playerTime>null minutes null seconds</playerTime>
         </player>
         <player>
              <playerName>Default Player</playerName>
              <playerScore>0</playerScore>
              <playerTime>null minutes null seconds</playerTime>
         </player>
         <player>
              <playerName>Default Player</playerName>
              <playerScore>0</playerScore>
              <playerTime>null minutes null seconds</playerTime>
         </player>
    </indianaTuxPlayers>
    However after all day searching the internet and trying ways, i have been unable to get anything working, could anyone give me a hand please?

    I would go the XML route too, but for fun, open a file as a BufferedWriter and do this:
    void copyAllButLastLine(File src, BufferedWriter tgt) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader(src));
        try {
            String previous= in.readLine();
            for (String current = null; (current = in.readLine()) != null; previous=current) {
                tgt.write(previous);
                tgt.newLine();
        } finally {
            in.close();
    }

  • Having active file links to text files in pdf

    Hi,
    I have a Word doc that has a number of embedded text files that are accessible by double-clicking the text icon. When I convert the Word doc to pdf these will not launch Notepad with the actual text file that is needed. Any suggestions on how to embed the text file so that it is launchable from the pdf? I originally just copied and pasted the icons from the email as they were sent to me. They launch from Word with no issues but will not when converted to pdf. Thank you.
    Brian

    I have tried to embed the mp3 and mp4 files, but the place command will not recognise them (they are always greyed). The only way I have been able to make the sound files play is by linking to the files using a button, but the 'embed all' command on making a pdf doesn't seem to work with this.

  • Saving Page files as ascii text

    How can you save files in pages as text? Exporting to text looses list numbers (rather than treating them a plain numbers.) Printing to pdf, then using Acrobat to save to text gets the line numbers, but still also gets lots of non-printing characters like quotes, etc. What I want is ALL the characters on a page, as plain ascii characters. I don't mind loosing bold, underlines, spacing and so forth, but I'd like to get all the readable stuff.
    (I know UNIX, so I tried to use "tr" to get some of the special characters, and to change CR to New Line, but there are too many special characters to be sure of finding them all.)
    Thanks for any suggestions.

    Yvan:
    Well, I'd like to argue with you about this. What you are saying is, of course, correct, FROM THE POINT OF VIEW OF A COMPUTER EXPERT!! But Apple Mac had tried to do a particularly good job of being useful to normal people. I'm a computer programmer and a mathematician myself, so I know how we like to talk to each other. BUT I also know it is not normal language. The Macintosh, and Pages, are trying very hard to be useful to non-experts, and I think in this case, they have acted as "techies". If Pages says it will save a document as text, I think it should try to translate everything possible from formatted text to plain text, even to the extent of putting extra lines with dashes for underscored characters, cleaning up backspaces, and so forth. (If you used UNIX in the old days, man pages were printed with a program called troff, but then there was an alternate way to get the output so it would be visible on a plain ascii terminal. That's the kind of thing I'm asking for here.)
    You might make an argument that normal people don't need the plain Ascii text that I am asking for, and you may be correct -- though there are enough non-standard programs floating around the computer world that I would think the ability to get very vanilla text would be useful for many people as a workaround.
    -- Stan

  • How Do I Save an ASCII Text File?

    In the Windoze world, Notepad is a simple editor that saves text strictly in ASCII format. Clean, not embellishments or tags. Sometimes it needs to be that way.
    What do I use to save ASCII text on a Mac? Somebody at the Apple store told me the answer is TextEdit, but when I went to save a file just now my choices were rich text (.rtf), HTML, Word format, or XML. No ASCII in the bunch.
    So, is there a program on here that does what Notepad does? Is there one out there somewhere...??
    --PS

    I forgot to mention, that this can also be set in the Preferences of Textedit to be the default setting:
    use plain text; add .txt extension when saving.
    I think that's all I needed to hear -- I've looked at the preferences for TextEdit and set them the way I think I want them.
    Thanks,
    --PS

  • Making an ASCII file into a text file

    Hi-
    I am trying to read the lines of an ASCII file as Strings and write them to a new text file. Eventually I will modify the info in the lines, but for now I'm just trying to get the flow from one file to another. I can't figure out how to write a String to a new file. Below is the code that I've written so far, followed by the error that i get when I run it (it compiles fine). One problem I see is that FileWriters are made to write characters, but I want to write Strings to a new file. How do I get around this?
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    class Delimiter {
    public static void main (String[] args) throws IOException {
    try {
    File inputFile=new File("test.asc");
    File outputFile=new File(test.txt");
    BufferedReader in=new BufferedReader(new FileReader(inputFile));
    BufferedWriter out=new BufferedWriter(new FileWriter(outputFile));
    String line=" ";
    while (line != null) {
    line=in.readLine();
    out.write(line);
    out.newLine();
    in.close();
    out.close();
    } catch (IOException e) {
    ERROR:
    Exception in thread "main" java.lang.NullPointerException
    at java.io.Writer.write(Unknown Source)
    at Delimiter.main(Delimiter.java:23)

    sorry, I responded too quickly. I put out.write(null);
    just before the in.close(); statement and got an error
    saying that command is ambiguous b/c write() could
    belong to multiple classes. did you mean that I should
    put it in the while loop?I didn't mean for you to put
    out.write(null);
    in your code. I meant to point out that when 'line' is null, the problem is that you are passing a null to the out.write() method. That is bad. Don't do that. Use the above. It will test for null before doing the write().

  • Convert a line read from text file into string

    how to convert a line from text file into string?
    i know how to convert to numbers,
    private int  parseLine1(String line) {
              StringTokenizer tokenizer = new StringTokenizer(line);
                  value1 = Integer.valueOf(tokenizer.nextToken()).intValue();
                  value2 = Integer.valueOf(tokenizer.nextToken()).intValue();
                 return value1;
                     }but what about charactrs?

    ok, here is my problem, i have a file with a bunch of Xs in it but position function doesn't return a correct value, what's going wrong?
    private int positioni(){
           int i=0;
           int j=0;
           int b=0;
           String line="";
            while(line!= null){
                for(int a=0; a<line.length(); a++){
                    if(line.charAt(a)=='X'){
                        i=a;}
                b++;
                j=b;
                t=line.length();
                line=read(gridFileN);
           return i;
    private String read(String ggridFileN){
             TextStreamReader ggridFile = new TextStreamReader(ggridFileN);
             return ggridFile.readLine();

  • Why does the orientation change when I convert pdf to a docx (Word) file?

    I want my converted files to come back in the orientation that I uploaded them. How do I do that.

    Hi aaron1975,
    May i know is this happening with every files or with this file only?
    Which pdf are you trying to convert?
    Try with another file.
    You can use different browser.
    If this problem still persist then please let me know.
    Regards,
    Florence

  • Convert pdf bank statement into excel file????

    I am trying to convert a pdf bank statement file into a excel file and its not working.... the cells are too long or to short.... please let me know how to do it, please. Thanks

    Here's some points that might help you with your question:
    1. You don't have to be the author of a PDF to run scripts on it.
    2. You don't have to have the non-free (Reader) version of Acrobat to run scripts, but you will have much more options available to you if you had Acrobat Pro or Standard.
    3. There's no ready-made tool that can do what you asked for. It *might* be possible with a custom-made tool, but it's very much dependent on the structure of the PDFs you have.
    If you're interested in such a tool contact me by email. I might be able to help you out.

Maybe you are looking for