Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reading .PDF file

Posted on 2003-11-20
8
Medium Priority
?
332 Views
Last Modified: 2010-04-16
Hi friends,
I would like to read .PDF content and store that content in the database(SQL Server 2000). What are all the available methods do we have to achieve the above task?

Thanks,
Ramachandra

0
Comment
Question by:raama16
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 3

Expert Comment

by:barryfandango
ID: 9787417
raama16,

In principle you can open the file with C# and put it into a blob, or "image" field in sql server.  Generally this is not recommended though, as moving entire files can really slow down your SQL server.  It's often better to just store the filename and/or path and have that file kept on the hard disk.  (just a suggestion of course.)
0
 
LVL 3

Accepted Solution

by:
barryfandango earned 204 total points
ID: 9787498
using System.IO;
using System.Data;
using System.Data.SqlClient;

FileStream myFile = new FileStream(ImageFile, FileMode.Open, FileAccess.Read);
byte[] MyPDF = new byte[myFile.Length];
myFile.Read(MyPDF, 0, (int)myFile.Length);
myFile.Close();

string ConnectString = "MyDSNEtc";
SqlConnection myCon = new SqlConnection(ConnectString) )
myCon.Open();

SqlCommand myCmd = new SqlCommand("AddPDF", myCon);
myCmd.CommandType = CommandType.StoredProcedure;
myCmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.Int32));
myCmd.Parameters.Add(new SqlParameter("@Data", SqlDbType.Image));
myCmd.Parameters["@Data"].Value = MyPDF;
myCmd.ExecuteNonQuery();
myCon.Close();

This uses a stored procedure that would look something like

CREATE PROCEDURE dbo.AddPDF
(
      @Id int,
      @Data image
)
AS
INSERT INTO MyPDFTable
      ( Id, Data )
VALUES
      ( @Id, @Data )
0
 
LVL 9

Assisted Solution

by:malharone
malharone earned 198 total points
ID: 9789101
i think rama means actually parsing the contents... i don't think its easily possible ... since there are many encryptions & encoding for pdfs. what i've done is let the user open the pdf file first. from the reader CTRL+A, CTRL+C - to copy all the content. then wrote a little program that does pattern recognition of the data using regex & little bit of AI. i also let the users interactively create their own pattern. and then store the parsed contents in a DB/Excel file.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:ptmcomp
ID: 9800166
If you want to extract the text buy a third party tool or use Acrobat. (The implementation would take you months - believe me!)
About the performance storing text in a database - we once zipped the text to make it faster and it got slower cause zip was slower than the database. It depends on the computer and network speed you have. Of course locally files are faster than the database over network but in a database you have transaction and locking control.
0
 
LVL 1

Author Comment

by:raama16
ID: 9829639
Hi Friends,
I am going to accept any one of the above answers. Before that, are there any way to read PDF file using Crystal Report.Net engine?

Thanks,
Ramachandra
0
 
LVL 10

Assisted Solution

by:ptmcomp
ptmcomp earned 198 total points
ID: 9830071
Don't think so since Reporting is the opposite of parsing.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question