Store pdf in blob
can any one tell me how to store a pdf file in the blob.
I m using forms 10g rel2 and oracle xe 10g.
Hello Master,
<p>Have a look at this one</p>
Francois
Similar Messages
-
To store PDF into BLOB and retrieve into OLE/OCX
We would like to:
1. Store a PDF file (output of a report saved in file server) into a BLOB
column.
2. Retrieve previously stored PDF in the BLOB column and display using either
OLE automation or ActiveX (OCX) control.
I read all related documents in metalink that addresses this issue however cant
get this to work. We have Acrobat Reader 4.0. Here are some issues from the
tests that I did:
1. To load the PDF file the program code that uses BFILE and LOADFROMFILE does
not work since the database is on a remote server and the PDF file is on a
local file server. The DIRECTORY created on the database is unable to find the
PDF file.
2. Though I want the loading of the file to be programmatic, I tried
right-click on the OLE container and inserted object from file. This loaded the
file into the container (Icon on the container appeared) however I was not able
to view the document by double-clicking. An error in Adobe occured: 'There was
an error opening this document. A file read error occured'. My guess is the
'Insert Object' did not insert the file properly into the BLOB.
3. When trying to display the PDF file stored in file server (in case storing
into BLOB does not work), I used an OCX control, right-clicked and Insert
Object and select Adobe Control for ActiveX. The problem here is when I run the
form, the OCX control shows up empty and I have to 'Insert Object' again in
runtime. Once I manually insert object from runtime the GET_INTERFACE POINTER &
SET_PROPERTY works fine is displaying the document. Is there any way to
maintain the control property of the OCX when the form is run?
4. Are there any workarounds and better solution to store PDFs into BLOBs and
retrieve and display in OLE/OCX controls? Using temporary file into local drive
is not an issue.
5. Would I be able to make use of 'PDF.PdfCtrl.1' OLE class?
6. Does OLE automation work for Acrobat Reader 4.0.?
I would appreciate all the help.
ShyamIm facing a similar kind of problem. I want to store and retrieve Office files, PDF and Jpegs into/from the database to view them on web in disconnected mode. Please reply as I cant find any help/documentation regarding saving BLOB data into files. I was able to store file data into BLOB, using DBMS_LOB package.
Shahzad -
How to store pdf into blob, index it and search it?
I am trying to store pdf into a column, index the column and search it.
I store pdf file into blob column with either the following code or with an interface in apex
declare
Dest_loc BLOB;
Src_loc BFILE := BFILENAME('DIR_TESTCASE', 'intermedia.pdf');
BEGIN
INSERT INTO pdffiles(id, description)
VALUES(1, 'InterMedia Concepts')
RETURN text INTO Dest_loc;
DBMS_LOB.FILEOPEN(Src_loc, DBMS_LOB.LOB_READONLY);
DBMS_LOB.LOADFROMFILE(Dest_loc, Src_loc, dbms_lob.getlength(Src_loc));
DBMS_LOB.FILECLOSE(Src_loc);
COMMIT;
END;
then i need to create an index
begin
ctx_ddl.create_preference('pdf
lexer', 'BASICLEXER');
ctx_ddl.set_attribute('pdf_lexer', 'printjoins', '_-');
end;
create index PDFFILES_TEXT on PDFFILES(TEXT) indextype is ctxsys.context
parameters ('lexer pdf_lexer');
sqlplus says index created but windows gives an error and closes ctxhx.exe
and of cource when I tried to make a search like
select id, description
from pdffiles
where contains(text,'Oracle') > 0;
it doesn't return any results.
My database is 10g XE, I also tried it on Oracle 10.2.0.3 EEIt is possible to store pdf and doc files in a blob column, create a text index, and search them, and display them. However, you cannot expect to just select doc and pdf data directly from a blob column and expect to be able to read it, due to all of the special formatting characters. You need to use ctx_doc.snippet or ctx_doc.markup or some such thing to format it and make it readable. Please see the demonstration below. You can search the online documentation for complete syntax, additional information, and examples.
SCOTT@orcl_11g> CREATE TABLE my_files
2 (id NUMBER,
3 doc BLOB)
4 /
Table created.
SCOTT@orcl_11g> CREATE OR REPLACE DIRECTORY DIR_TESTCASE AS 'c:\oracle11g'
2 /
Directory created.
SCOTT@orcl_11g> declare
2 Dest_loc BLOB;
3 Src_loc BFILE;
4 BEGIN
5 INSERT INTO my_files (id, doc) VALUES (1, EMPTY_BLOB())
6 RETURNING doc INTO Dest_loc;
7 Src_loc := BFILENAME ('DIR_TESTCASE', 'banana.pdf');
8 DBMS_LOB.FILEOPEN (Src_loc, DBMS_LOB.LOB_READONLY);
9 DBMS_LOB.LOADFROMFILE (Dest_loc, Src_loc, dbms_lob.getlength (Src_loc));
10 DBMS_LOB.FILECLOSE (Src_loc);
11 INSERT INTO my_files (id, doc) VALUES (2, EMPTY_BLOB())
12 RETURNING doc INTO Dest_loc;
13 Src_loc := BFILENAME ('DIR_TESTCASE', 'test1.doc');
14 DBMS_LOB.FILEOPEN (Src_loc, DBMS_LOB.LOB_READONLY);
15 DBMS_LOB.LOADFROMFILE (Dest_loc, Src_loc, dbms_lob.getlength (Src_loc));
16 DBMS_LOB.FILECLOSE (Src_loc);
17 END;
18 /
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> INSERT INTO my_files (id, doc)
2 VALUES (3, UTL_RAW.CAST_TO_RAW ('blob data for id 3'))
3 /
1 row created.
SCOTT@orcl_11g> COMMIT
2 /
Commit complete.
SCOTT@orcl_11g> SELECT id, DBMS_LOB.GETLENGTH (doc) FROM my_files
2 /
ID DBMS_LOB.GETLENGTH(DOC)
1 222824
2 19968
3 18
SCOTT@orcl_11g> CREATE INDEX my_files_idx ON my_files(doc)
2 INDEXTYPE IS CTXSYS.CONTEXT
3 /
Index created.
SCOTT@orcl_11g> SELECT COUNT (*) FROM dr$my_files_idx$i
2 /
COUNT(*)
308
SCOTT@orcl_11g> COLUMN first_45 FORMAT A45
SCOTT@orcl_11g> SELECT id,
2 UTL_RAW.CAST_TO_VARCHAR2 (DBMS_LOB.SUBSTR (doc, 18, 1)) AS first_45
3 FROM my_files
4 /
ID FIRST_45
1 %PDF-1.5
%âãÏÓ
1
2 ÐÏࡱá
3 blob data for id 3
SCOTT@orcl_11g> EXEC CTX_DOC.SET_KEY_TYPE ('ROWID')
PL/SQL procedure successfully completed.
SCOTT@orcl_11g> COLUMN keywords_in_context FORMAT A45 WORD_WRAPPED
SCOTT@orcl_11g> SELECT id,
2 CTX_DOC.SNIPPET
3 ('MY_FILES_IDX',
4 ROWID,
5 'contents OR (fruit of the month) OR data',
6 '<<',
7 '>>')
8 AS keywords_in_context
9 FROM my_files
10 WHERE CONTAINS (doc, 'contents OR (fruit of the month) OR data') > 0
11 /
ID KEYWORDS_IN_CONTEXT
1 <<Fruit of the Month>>
Banana
Bananas are the most popular
2 This is the original <<contents>> of
test1.doc.
3 blob <<data>> for id 3
SCOTT@orcl_11g> -
Any good way to store pdf files in oracle 10g?
have, i have many pdf files, i want to store in database. Any good way to do that in 10g? Or, I have to go to 11?
thanks,
t.k.mbobak wrote:
Justin Cave wrote:
user10217806 wrote:
Can I store pdf in blob, and still search words in the pdfs?Probably not, no. If you want to search the data inside Oracle, you'll want to look at Oracle Multimedia.I think the correct answer is "not efficiently". :-)Well, there is nothing that prevents you from building Oracle Multimedia yourself and getting similar levels of efficiency. Other than a desire not to invest dozens of man-years replicating delivered functionality, of course. -
Error while trying to store PDF in Oracle's BLOB field
Hi folks!
I'm having problems while trying to store PDF file in a BLOB field of an Oracle table
This is the message code:
Exception in thread "main" java.sql.SQLException: Data size bigger than max size for this type: 169894
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.ttc7.TTCItem.setArrayData(TTCItem.java:95)
at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2414)
at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1134)
at oracle.jdbc.driver.OraclePreparedStatement.setBytes(OraclePreparedStatement.java:2170)
at vgoactualizacion.Main.main(Main.java:84)
This is the piece of code i'm using:
Assuming conn = conection to Oracle 10g Database ( it's working )
String miProcedimientoAlmacenado = "{ call package_name.update_client(?,?, ?) }";
CallableStatement miComando = conn.prepareCall(miProcedimientoAlmacenado);
miComando.setString(1,miClienteID ); //first parameter : IN
//second parameter : IN
File miPDF = new File(pathPDF + "//" + miClienteID + ".pdf");
byte[] bodyIn = readFully(miPDF); //readFully procedure is shown below
miComando.setBytes(2, bodyIn); //THIS IS THE LINE WHERE THE ERROR IS PRODUCED
//3rd parameter: OUT
miComando.registerOutParameter(3, java.sql.Types.VARCHAR);
miComando.execute();
private static byte[] readFully(File miPDF) throws FileNotFoundException, IOException {
FileInputStream fis = new FileInputStream(miPDF);
byte[] tmp = new byte[1024];
byte[] data = null;
int sz, len = 0;
while ((sz = fis.read(tmp)) != -1) {
if (data == null) {
len = sz;
data = tmp;
} else {
byte[] narr;
int nlen;
nlen = len + sz;
narr = new byte[nlen];
System.arraycopy(data, 0, narr, 0, len);
System.arraycopy(tmp, 0, narr, len, sz);
data = narr;
len = nlen;
if (len != data.length) {
byte[] narr = new byte[len];
System.arraycopy(data, 0, narr, 0, len);
data = narr;
return data;
}//fin readFully
This approach indicates that the PDF file is converted into an array of bytes, then is stored as binary in the BLOB field.
Thanx in advance, and looking forward for your comments.You will probably need to use the setBinaryStream() method instead of setBytes().
-
Store pdf in oracle BLOB hibernate
I need to store PDF files in the oracle BLOB using hibernate. I am using the below code and getting a null pointer. Any thoughts?
Blob blob=null;
byte [] bFile = (byte[])objVal;
blob.setBytes(0,bFile); //null pointer here...
logger.info("EventsDAO- insertDetails- else:--"+((byte[])objVal)+"---blob----"+blob);
hmForm.put(objKey,blob); Thanks in advance.Samples? Are you asking how to make a blob? I have my doubts about the wisdom of using Hibernate if you can't diagnose a NPE unless that was just momentary code snow-blindness, but whatever, it's your problem:
Either call Hibernate.createBlob(InputStream,long) or just map the field as a byte[] and map it to a Blob type.
Edited by: dcminter on 09-Jun-2008 22:22 -
How To Store pdf or doc file in Oracle Database using Java Jdbc?
can any one help me out How To Store pdf or doc file in Oracle Database using Java Jdbc in JSP/Serlet? i tried like anything. using blob also i tried. but i am able 2 store images in DB not files. please if u know or else if u have some code like this plz send that to me, and help me out plz. i need that urgent.
Hi.. i am not getting error, But i am not getting the original contents from my file. i am getting all ASCII vales, instead of my original data. here i am including my code.
for Adding PDF in DB i used image.jsp
Database table structure (table name. pictures )
Name Null? Type
ID NOT NULL NUMBER(11)
IMAGE BLOB
<%@ page language="java" import="java.util.*,java.sql.*,java.io.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
PreparedStatement ps,pstmt,psmnt;
ps = con.prepareStatement("INSERT INTO pictures VALUES(?,?)");
File file =
new File("D:/info.pdf");
FileInputStream fs = new FileInputStream(file);
ps.setInt(1,4);
ps.setBinaryStream(2,fs,fs.available());
int i = ps.executeUpdate();
if(i!=0){
out.println("<h2>PDF inserted successfully");
else{
out.println("<h2>Problem in image insertion");
catch(Exception e){
out.println("<h2>Failed Due To "+e);
%>
O/P: PDF inserted successfully
i tried to display that pdf using servlet. i am giving the code below.
import java.io.IOException;
import java.sql.*;
import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class DispPDF extends HttpServlet {
* The doGet method of the servlet. <br>
* This method is called when a form has its tag value method equals to get.
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//response.setContentType("text/html"); i commented. coz we cant use response two times.
//PrintWriter out = response.getWriter();
try{
InputStream sPdf;
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@192.168.1.135:1521:orcl","scott","tiger");
PreparedStatement ps,pstmt,psmnt;
psmnt = con.prepareStatement("SELECT image FROM pictures WHERE id = ?");
psmnt.setString(1, "4"); // here integer number '4' is image id from the table.
ResultSet rs = psmnt.executeQuery();
if(rs.next()) {
byte[] bytearray = new byte[1048576];
//out.println(bytearray);
int size=0;
sPdf = rs.getBinaryStream(1);
response.reset();
response.setContentType("application/pdf");
while((size=sPdf.read(bytearray))!= -1 ){
//out.println(size);
response.getOutputStream().write(bytearray,0,size);
catch(Exception e){
System.out.println("Failed Due To "+e);
//out.println("<h2>Failed Due To "+e);
//out.close();
OP
PDF-1.4 %âãÏÓ 2 0 obj <>stream x+är á26S°00SIá2PÐ5´1ôÝ BÒ¸4Ü2KüsSSS4C²ê Pkø$VãGÒU×713CkW )(Ü endstream endobj 4 0 obj <>>>/MediaBox[0 0 595 842]>> endobj 1 0 obj <> endobj 3 0 obj <> endobj 5 0 obj <> endobj 6 0 obj <> endobj xref 0 7 0000000000 65535 f 0000000325 00000 n 0000000015 00000 n 0000000413 00000 n 0000000168 00000 n 0000000464 00000 n 0000000509 00000 n trailer <<01b2fa8b70ac262bfa939cc786f8770c>]/Root 5 0 R/Size 7/Info 6 0 R>> startxref 641 %%EOF
plz help me out. -
How to store PDF files in a table
Hi,
Is there a way to store PDF files in a table? Do I use LOB? How do I automatically read them if I want them to be available in a web site?
Thanks.
CamilleU have to use either BLOBs (internal LOBs) or BFILEs (external LOBs). check out docu. at http://www.akadia.com/services/ora_blob.html
-
Hi,
Oracle Form 6i,
Oracle Database 11g.
Is there any way to store pdf file from user client machine without transfer the file to OS of database?
Regards,In Forms 6i you can create an item of type OLE Container to store a PDF file.
However, I do not recommend this. You will never be able to retrieve the document in any other way than via Forms again. You cannot simply get the value of the BLOB column and store it somewhere as a PDF file. When using an OLE item, Forms "serializes" the data (whatever that means ) before storing it in the database. Also, OLE is obsolete in later versions of Forms.
>without transfer the file to OS of database
You don't have to transfer to the database server per se. Any file server will do, as long as the database has access to the directory (via CREATE DIRECTORY). This would be my preferred way to do it. -
Store PDF File in Oracle database 10g
Hi all,
I want to store PDF File in Oracle database 10g,
and then I want to access the pdf file using Oracle Developer 6i
can anyone tell me how to do this,
thanks in advance.This question has already been posted a lot of times.....
See the following:
http://forums.oracle.com/forums/search.jspa?threadID=&q=pdf+file&objID=f82&dateRange=lastyear&userID=&numResults=15
Greetings,
Sim -
Adobe Acrobat XI pro version, Windows 7, running on iMac parallels, converting pdf to a pdf with reduced size is not possible, error: error in converting the file! What to do? Its a bit annoying not to be able to store pdf files in reduced size, any idea?? Thanks, Jörg
Hi Jorg ,
Are you trying to reduce the file size with the "Reduced size PDF" in the save as other option.
Give it a try if you haven't done it prior.
Open that PDF>File>Save as Other>Reduced size PDF.
If possible ,please share the snapshot of the error message with us so that we can have a look in order to assist you further.
Regards
Sukrit Dhingra -
How to load externl files (PDF) into BLOB column. Please help.
Hi All,
I've currently been working on loading many external binary files (PDF) into BLOB column. After some digging, I learn that the SQL*LOADER can be used to load data from external files into table. I also got help from another forummate mentioning to use PL/SQL procedure to do so. Since I have not done anything like this before. So, my question is what is the simple approach needed to upload PDF files into a table(there is only one table containing BLOB column in my database). In addition, the LOBs can not be query-able, I wanted to list the contents of the LOBs column to make sure that I did successfully upload data into the database. How can I do that?. I do need your help. Please direct me step by step how to do so. Your help is greatly appreciated.
Regards,
TrangHi,
If the following link helps to you then great.
http://www.exefind.com/oralobeditor-P25468.html
Regards,
Sailaja -
Store PDF files in database.
hi all
how to store PDF files in database and how to retreive plz guide me thanks in davance.
sarahSarah,
so your pdf-document is stored in the database.
we jump over step 4 what would be the code for sending the pdf-file to the database ...
Step 5 open the stored pdf-file:
Please create a when-mouse-doubleclick trigger on your filename-item:
declare
l_temp_file constant varchar2(255) := client_win_api_environment.get_environment_string ( 'Temp' ) || '\temp.pdf';
begin
if
:pdf.filename is not null
then
if
webutil_file_transfer.db_to_client ( l_temp_file, 'PDF', 'PDF', ' id_pdf = ''' || :pdf.id_pdf || '''' )
then
client_host ( 'cmd /C start ' || l_temp_file );
else
Message ( 'Failure while downloading ' || :pdf.filename || ' from the database. ' || dbms_error_text );
Message ( ' ' );
clear_message;
end if;
else
Message ( 'No PDF-file selected.' );
Message ( ' ' );
clear_message;
end if;
end;Save your form, compile and run it.
Execute a query on the pdf-block and doubleclick your filename item.
Now you can read your forms reference pdf direct from the database :).
Regards -
HT5663 How to store PDF files in iCloud?
Is there a way to store PDF files in iCloud? I see that Preview supposedly stores PDF's in iCloud, but when I try it, I cannot find the file in iCloud.
Sorry AMCarter3, my bad. While it used to be in GoodReader they apparently removed it some time ago, supposedly for some legal reasons?
I too use GoodReader primarily with dropbox and box so had not noticed it was gone.
As an aside, for those apps that support iCloud storage, if you have a Mac, enable Documents & Data in the iCloud control panel. That will make a folder on your hard drive, named "Mobile Documents" that is your local mirror of your iCloud folders. Apps that sync their content to iCloud will make a folder for themselves when they first conntect to iCloud, and that folder will in turn get created as a sub-folder in Mobile Documents on your Mac (I still have my one for Goodreader, "JFJWWP64QD~com~goodiware~GoodReader", along with ones for Pages, Numbers, and a host of others).
You can then drag and drop any file you wish into that folder (as long as it is a file type supported by the app), and they will then sync to iCloud. You then use the app and download them for use on your iOS device from within the app. That folder on your Mac will be updated whenever it changes and your Mac has internet access to iCloud.
But, for PDFs in Goodreader, yes, dropbox works great, and has their free companion app for OS X if you want things on your computer to sync automatically too. -
problem store pdf file after download from web. Message, store to littel from reader11. Where ist tht problem or the solution?
thanksDear Mr Willener
Thanks for the mail, that problem is soluted, press the botton, store as copy.I found it in secound read
A wish: In reader 9 is the solution better.
Regards from Ilmenau
L.Gleichmann
[signature and auto-quote removed by host]
Maybe you are looking for
-
Problem with a text in the last page of XML Publisher Template
Oracle Applications : 11.5.10.2 Oracle BI Publisher Template Builder for Word 10.1.3.4 Build 129 Hi, I have a problem with XML Templates, I need that a text (*Este documento no confiere origen, señala únicamente país de manufactura.) is always at the
-
Hi , I have posted the following : Full Table Scans for small tables... in Oracle10g v.2 and the first post of Mr. Chris Antognini was that : "I'm sorry to say that the documentation is wrong! In fact when a full table scan is executed, and the block
-
Table Changes 11.5.10 to 12.1
I am looking for technical documentation that tells me the EBS table changes from 11.5.10 to 12.1. Don't tell me I have to read every trm and compare!! Thanks
-
My Epson scanner recognizes I am trying to scan a slide ...
My Epson scanner recognizes I am trying to scan a slide, but it scans the slide holder instead of scanning the actual slide. How can I fix this?
-
Using too much processor to render
This is really upsetting me I just got a new motherboard asus M5a99xevo used for gaming so it should be pretty good New Gtx 2gb 560 Video card put in 16 gig ddr3 ram 13 gig dedicated to premiere and when I did a practice render its maxing