Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6644517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:10:36+00:00 2026-05-26T00:10:36+00:00

I want to convert a PDF file into a CSV file. I am using

  • 0

I want to convert a PDF file into a CSV file.
I am using iText library for this.
The program is working fine but the output is not in desired format.
All the data is coming in first line of the csv file. The output should be exactly same as pdf file(means with line breaks).
Please help.
Thanks in advance.

Document document = new Document();
  document.open();
  PdfReader reader = new PdfReader("C:\\Indiaops-projects\\PREMIUM_PAID_ACKNOWLEDGEMENT.pdf");
  PdfDictionary dictionary = reader.getPageN(1);
  AcroFields fileds = reader.getAcroFields();
  PRIndirectReference reference = (PRIndirectReference) 
            dictionary.get(PdfName.CONTENTS);
                    PRStream stream = (PRStream) PdfReader.getPdfObject(reference);
                    byte[] bytes = PdfReader.getStreamBytes(stream);
                    PRTokeniser tokenizer = new PRTokeniser(bytes);
                    FileOutputStream fos=new FileOutputStream("C:\\Indiaops-projects\\pdf.csv");
                    StringBuffer buffer = new StringBuffer();
                    StringBuffer data = new StringBuffer();
                    int i=0;
                    while (tokenizer.nextToken()) {
                    if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
                        String value = tokenizer.getStringValue();

                        if("x-none".equals(value)){
                            String datastr =data.toString();
                            if(!"".equals(datastr)){
                                buffer.append("\""+datastr+"\",");
                                data = new  StringBuffer();
                            }
                        }else{
                               data.append(value);
                        }
                     }
                  }
            String test=buffer.toString();
            StringReader stReader = new StringReader(test);
            int t;
            while((t=stReader.read())>0)
            fos.write(t);
            document.add(new Paragraph(".."));
            document.close();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:10:37+00:00Added an answer on May 26, 2026 at 12:10 am

    You need to introduce a line break ‘\n’ in the buffer after each table row.

    buffer.append("\n");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to convert a pdf file to an image with PHP, but i
I want to convert .pdf file to .png file using Imagemagick php API. we
I have a PDF file that I want to convert to PowerPoint using .NET.
I want to convert jepg file into pdf file in an iphone application... Do
I want to convert an HTML file to PDF using iTextSharp . I used
i want to convert my webpage(displayed in UIWebView) contents in pdf file. which can
How do I convert byte[] into a PDF document in C#? I want to
I want to convert this code into PHP, it's a function that hides layers
i am using Imagemagick for converting my .pdf file to .png images but when
I want to convert tiff files to pdf using GnuWin32 tiff2pdf utility. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.