Read a pdf file line by line

Hi
I am trying to read contents of a pdf file .I used pdfbox it worked but the problem ,is for large pdf files it throws OutofMemory Exception
so i want to know how to read a pdf file line by line using pdfbox or any other API's
Thanks

gkraju wrote:
It will work but
String x1= stripper.getText(doc);reads the whole document .so it will also throws exception if the file size is large.It might be an idea if you spent a few minutes considering the code fragment which was kindly posted. Your problem is that reading the whole file's text into memory uses up all the memory. Okay, that's a problem. So instead of whining here, why not consider what might fix that problem? The ridiculously obvious idea is to not read the whole file's text into memory. Can you figure out how to change the posted code to read, for example, only one page? If you can't figure that out then, really, perhaps you ought to consider doing something else instead of programming.

Similar Messages

  • How to specify xml file to populate form fields in the PDF file via command line?

    Hi,
    I would like to specify xml data file to populate my pdf file using command line.
    The form was Reader extended.
    I've tried the following syntax :
    Acrobat.exe /A "zoom=100" "C:\example.pdf"#xml="C:\example.xml" but got an acrobat error: "the file name, directory name or volume label syntax is incorrect".
    Where am I wrong?
    Thanks!

    >If I understand correctly you propose something like this
    Something like, yes.
    >
    >Acrobat.exe /A "zoom=100" "xml=C:\example.xml" ....
    Certainly, neither will work. /A is followed by a single quoted
    string. There must be some separator, but I don't know what it needs
    to be (as I was alluding to in my first reply).
    To see if there is any hope, just try without the zoom= completely. In
    any case you can set the zoom in the document properties.
    Aandi Inston

  • Run PDF File from command line and goto a bookmark

    Hi,
    I need to open a pdf file vi command line (WinXP / Win7).
    Till this I do not have a problem.
    But I need to go to a bookmark in the file direct after opening the file.
    I tried "acrord23.exe /a nameddest=BOOKMARK file.pdf" but this opened only the file.
    "acrord23.exe /a zoom=50 file.pdf" works fine.
    Is there another parameter to go to a bookmark after open a file?
    Where is my mistake?
    Thanks in advance
    Regards
    Marc
    Message was edited by: mgemmerich - reason: typo

    Hi,
    I read the PDF Open Parameters reference. So I tried the nameddest. I think the nameddest is a bookmark, or is this wrong?
    The background is, that we have the dokumentation for our application in word. So we save the word as pdf. Each chapter is now a bookmark.
    In the application we want to call the pdf and jump to the bookmark. Each frame were you can call "help" is a chapter/bookmark.
    Or is there another way to do this?
    Regards
    Marc

  • Problem in Reading a .PDF file

    HI Friends,
    I am reading a .pdf file from within java program using its java.io package.
    I am able to read the file, but when I print the line read from file on to the screen, it all garbage. Its not in readable characters.
    I guess its reagrding mismatch in Charcter Sets of original file and the stream with which I m reading the file.
    So,if u know the solution plz suggest me.

    Hello Simple@java
    Here's an exemple of a class that opens the File "rapport.pdf" located at the same place as the class.
    Of course AcroRd32.exe is the name of Acrobat Reader which allows to read pdf files. You can get it on : adobe.com(http://www.adobe.com/products/acrobat/readstep2.html)
    You will change "rapport.pdf" by the name of your pdf file.
    Then execute "test()".
    * Open the file "rapport.pdf"
    public class test
         public test()
              Runtime a = Runtime.getRuntime();
              try
                   a.exec("AcroRd32.exe rapport.pdf");               
              catch (Exception e)
                   System.out.println(e.getMessage());
    Good luck !

  • Hi... I would like to purchase a Tablet Sony Xperia Z 2 10.1 (the last one of the Z series) and I was told that Adobe does not support Sony anymore.... I need to be able to open and read Adobe PDF files and I would like to know if this tablet can still us

    Hi... I would like to purchase a Tablet Sony Xperia Z 2 10.1 (the last one of the Z series) and I was told that Adobe does not support Sony anymore.... I need to be able to open and read Adobe PDF files and I would like to know if this tablet can still use Flash Player...
    Is there anyo who can help me with this? I asked in the shop and I was told "yes of course" , but when I contacted Sony directly I was advised to check with Adobe as apparently in the recent months Adobe and Sony haven't been getting along anymore...

    You may be mixing up two entirely different Adobe products.
    1. Adobe Flash Player. Needed to view web pages designed with Flash. Not needed to view PDF files. Not available for Android (not just Sony).
    2. Adobe Reader. Reads PDF files. However, the Android can also read most PDF files without needing Adobe Reader.

  • Is there any way to read the pdf file in java

    Hai,
    i need some advice from anyone that is there anyway to read the pdf file directly from java...
    Without converting to other files(txt,html)
    if it is possible please help me..
    Thank you

    Or use the Adobe one (search the adobe site). Or search this forum, this is one of the Top Ten Qestions Asked here.

  • How do I read a pdf file in Acrobat Reader (vs. Preview)?

    How do I read a pdf file in Acrobat Reader (vs. Preview)? I have a Mac OS, need to know the process to read a pdf file document in Acrobat Reader instead of Preview. Much thanks for suggestions.

    Right click the PDF. Choose "Open With..." Select Reader.
    Or.
    Right click and "Get Info"
    under "Opens with" change the default app to Reader, and click "Change all" to set the preference for ALL PDFs.

  • I have an older computer and could not read a pdf file so I just added the Adobe software for $14.95 and downloaded it but still can not open the reader.  If I can't open it, please refund my money.

    downloaded new software and still can't open files

    Hi [email protected] ,
    In order to read the PDF file, you need to download and install Adobe Reader. Please download it from the link below:
    http://get.adobe.com/reader/enterprise/

  • How do I convert a read only word doc to a read only pdf file?

    How do I convert a read only word doc to a read only pdf file?
    Thanks, Linda

    Hi Linda,
    I just tried it, and was able to convert a Word .doc to to PDF, in spite of the fact that it was marked Read Only. Here are the instructions for uploading and converting to PDF with Acrobat.com:
    http://help.adobe.com/en_US/Acrobat.com/Acrobat/WS396AAA88-4AA4-4a40-87B8-004A5DC1E131.htm l
    Kind Regards,
    Michelle

  • I cann't find the"define" option in adobe reader when I read a PDF file in iPad 3.

    I cann't find the "define" option in adobe reader when I read a PDF file in my iPad 3. I have already latest reader version and iOS 5.1.1 installed.

    I believe that I figured it out.
    holding finger over a word, will bring the copy/define menu
    holding finger where there is NO text, empty space or image, will bring up the annotation menu.
    but note that if you have a scanned document, where the words are actually an image, you will get the annotation menu, since there really is no text, just a bunch of pixels that look like text...
    you can turn scanned text into "real" text by using OCR functionality of the desktop version of Acrobat Pro (not Reader), it would then create a layer of invisible text under the image of the text.

  • Using a servlet to read a pdf file that is in remote server

    Hi,
    I read some topics about how to read a pdf file using a servlet...but my issue is that my pdf files are on a remote Sun solaris server (intranet) and my servlet will be in a public network (internet), so my question is, still be possible to use this solution to read my remote file ? how i can access the remote file ??
    any idea from where I can start ??
    best regards,
    carlos.

    You may use a FTP client component to connect with your servlet to the Sun server, retrieve the bytes and serve them to the browser. Instead of reading the stream from a local file, you will be reading from a network socket, but the code -if well written and designed- may be very similar.
    There are many good ftp client components for java, you may also use other protocols like HTTP or SCP (ssh file transfer).
    Regards,
    Martin Cordova
    http://www.martincordova.com
    Dinamica framework for J2EE
    - the easiest way to Java webapps...

  • How read a pdf file and change TableCell height after reading it using itext api

    I have created a pdf form file using itext ( see class CreatingFormClass ) with itext PdfPTable and PdfPCell. It is done successfully .
    Now I  read this pdf file and filling this pdf file(see class FillingFormClass  ) and at this point i want to change  PdfPCell height () according to Items.
    It is possible or Not???
    My code is given below.
    Thanx in advance
    public class FillPdfFormMainClass {
    public static  String RESULT1 = "E:/BlankForm.pdf";
        public static  String RESULT2 = "E:/FilledForm.pdf";
        public static void main(String[] args) throws DocumentException, IOException {
            String empName="Rakesh Kumar Verma";
                    // This part is Dynamic. It can be 1 item Or can be 25 items
            String listOfItem="Item 1 \n Item 2 \n Item 3\n Item 4 \n Item 5 \n Item 6 \n Item 7 \n Item 8 \n Item 9";
            CreatingFormClass example = new CreatingFormClass(0);
            example.createPdf(RESULT1);
            FillingFormClass class1 = new FillingFormClass();
            class1.manipulatePdf(RESULT1, RESULT2,empName,listOfItem);
    public class CreatingFormClass implements PdfPCellEvent {
        protected int tf;
        public CreatingFormClass(int tf) {
            this.tf = tf;
        public void createPdf(String filename) throws DocumentException, IOException {
            Document document = new Document();
            PdfWriter.getInstance(document, new FileOutputStream(filename));
            document.open();
            PdfPCell cell;
            PdfPTable table = new PdfPTable(2);
            table.setWidths(new int[]{1, 2});
            table.addCell("Name:");
            cell = new PdfPCell();
            cell.setCellEvent(new CreatingFormClass(1));
            table.addCell(cell);
            table.addCell("Item List:");
            cell = new PdfPCell();
            cell.setCellEvent(new CreatingFormClass(2));
            cell.setFixedHeight(60);
            table.addCell(cell);
            document.add(table);
            document.close();
        public void cellLayout(PdfPCell cell, Rectangle rectangle, PdfContentByte[] canvases) {
            PdfWriter writer = canvases[0].getPdfWriter();
            TextField text = new TextField(writer, rectangle, String.format("text_%s", tf));
            text.setBackgroundColor(new GrayColor(0.95f));
            switch (tf) {
                case 1:
                    text.setText("Enter your name here...");
                    text.setFontSize(8);
                    text.setAlignment(Element.ALIGN_CENTER);
                    break;
                case 2:
                    text.setFontSize(8);
                    text.setText("Enter Your Address");
                    text.setOptions(TextField.MULTILINE);
                    break;
            try {
                PdfFormField field = text.getTextField();
                writer.addAnnotation(field);
            } catch (IOException ioe) {
                throw new ExceptionConverter(ioe);
            } catch (DocumentException de) {
                throw new ExceptionConverter(de);
    public class FillingFormClass {
        public void manipulatePdf(String src, String dest,String empName,String listOfItem) throws IOException, DocumentException {
            PdfReader reader = new PdfReader(src);
            PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(String.format(dest, empName)));
            AcroFields form = stamper.getAcroFields();
            form.setField("text_1", empName);
            form.setField("text_2", listOfItem);
            stamper.close();
            reader.close();

    Hi,
    I am facing the same problem. Please help me out. I just want to read a PDF file as bytes from one location and write it as another pdf file in some other location with a diolog box prompting to open or save in the location where we want.
    I executed the following code:
    try{
    File report =new File(location);
    BufferedInputStream in=new BufferedInputStream(new FileInputStream(report));
    response.setContentType("application/x-download");
    response.setHeader("Content-Disposition", "attachment; filename=" + report.getName());
    OutputStream outs = response.getOutputStream();
    int readlen;
    byte buffer[] = new byte[ 256 ];
    while( (readlen = in.read( buffer )) != -1 )
    outs.write( buffer, 0, readlen );
    outs.flush();
    outs.close();
    in.close();
    response.setStatus(HttpServletResponse.SC_OK);
    } catch (FileNotFoundException fileNotFoundException) {
    PrintWriter out= response.getWriter();
    out.print("<center><Font color = 'RED'><b>"+PxDSLUtils.getApplicationProperty("label.error.CTM_E017")+"</b></Font></center>");
    Though it prompts with open, save dialog box when i try to open directly or when i save it some where locally and then open it i am getting the following message " File is repaired ot damaged.Operation failed." Any idea about what can be done??? Its very urgent.Please suggest.
    I am not convetin to string just reading and writng as bytes itself.
    Thanks in advance,
    Mani

  • How to read a PDF file content???

    Hi Experts,
    I need to read the pdf file content.
    Pdf file is in some repository
    I m unable to read pdf data with getContent() function.
    Please suggest me a way to read the pdf file
    Help will be appreciated and rewarded

    Hi Pankaj,
    Are you able to achieve the above said functionality? Even I too have the similar requirement.
    Can you pls let me know the solution or alternatives for your requirement you have followed...
    Thanks in advance.
    Nandu.

  • Reader will not read my pdf files. after an automatic update the pdf files are not accessable.

    adobe automatic update to XI caused the reader of my pdf files to stop working. The reader tries to open -- the adobe reader window opens for a few seconds, nothing in the window is activated -- then the window automatically closes.
    I have uninstalled and reinstalled previous versions that used to work but the reader 9 and X now do the same thing. open, unactivated window after a few seconds the program then shuts down.
    I cannot open and read any pdf file on this computer.
    There are no error messages and everything seems normal. The program does not work properly.
    I have ran the windows diagnostic tools to no avail.
    This computer operates windows 7

    See if you can open the EULA.exe file in the folder that contains the install of Reader or Acrobat.

  • Make Acrobat the default reader for pdf-files.

    Since some time (probably after I installed Mavericks) pdf-files are by default opened
    in Preview. To open them in Adobe Acrobat, I can right-click the pdf-file, choose Acrobat,
    and indicate that Acrobat should be the default reader for pdf-files.
    This works, and after logout and login, it does still work.
    But after a reboot, Preview is again the default reader.
    Also, if in Finder I right-click a pdf-file, and via Get Info I configure Acrobat
    to be the default reader for the specific file and all other pdf-files (by clicking
    Change All), this only works for the current session. After a reboot Preview again is the
    default.
    How can I make Acrobat Reader the default reader for pdf-files, and make this setting
    permanent?
    Where is this setting saved?
    Regards,
    Kees.

    I finally solved this, but I still don't understand how.
    To begin with I have 2 hard-drives in my iMac. The OS is on the primary HD, and data are on the secondary drive. My Home directory too is on this secondary HD.
    To check whether the location of the Home directory might be the problem, I copied the Home directory to the primary HD, changed the path in my profile, and did a reboot.
    The next step was to configure Adobe Acrobat as the default reader for pdf-files. To my surprise,  after rebooting, Acrobat still was the default reader for pdf-files.
    So it looks as if this problem has something to do with the location of the Home directory.
    The original Home directory was still present on the secondary  HD,  So the next step was to change in my profile the path to the Home directory again (pointing again to the original Home directory on the second HD), do a reboot and delete the copy of the Home directory on the primary HD.
    So now the situation was back to as it was before: the Home directory on the second HD.
    To my surprise now Acrobat still was the default reader for pdf-files.
    And I could also change the default reader to Preview, and back to Acrobat, and this setting was saved across reboots.
    I'm curious to what solved this problem, and where the setting of the default pdf-reader, or more general, the default application for file types, is stored.
    So I hope that someone who reads this, can shed some light on this.

Maybe you are looking for

  • Displaying image, stored in KM, using HTMLB image UI Element...

    Hello all, I want to display the images in HTMLB UI Element which are stored under KM folder. Image element requires src field to be filled with URL. So do I need to provide the full path to images including server's host name and port (e.g. http://<

  • License Agreements not displayed during Install

    I created and installer in LabVIEW 2011 (64-bit OS with Windows 7).  I added a custom license agreement (rtf) file to my installer and included it as shown below.  The setup.ini includes a reference to the file and I confirmed that the file exists in

  • Outbound idocs failed

    Sending out material master extended the idoc MATMAS03 Created one segment with one field added it to the idoc populated that segment in the Customer Exit 'CAll function 002' of FM:Masteridoc_create_matmas On sending the materials via bd10 I get erro

  • How to create and edit anomalous tables in DIAdem? Such as the example list.

    How to create and edit anomalous tables in DIAdem? Can the tables  be edited as in MS Word? 帖子被yangafreet在08-21-2007 10:28 PM时编辑过了 Attachments: table example.doc ‏26 KB

  • Auditing_in_ebiz_r12

    Hi, I need to enable auditing in my APPS database.Myebiz version is r12.1.3 with the 11.2.0.3 database integrated with the application. Recently the data from the base table was dropped in my instance. So i decided to enable auditing in my database w