.pdf from .doc giving error on writing Chunk to Oracle DB

If you are a VB developer and have questions about using our products from VB, here is the place to post them.
Post Reply
tyrellc
Posts: 2
Joined: Thu Apr 17 2003
Location: South Africa
Contact:

.pdf from .doc giving error on writing Chunk to Oracle DB

Post by tyrellc »

I am using VB6, on Win XP Pro and connecting to an Oracle 8i database using Oracle Objects for OLE (0040 Automation Server)

I can convert powerpoint docs and write them to a BLOB in Oracle but the converted word documents are giving me an error in the same code as below.

It fails on the statement ;

amount_written = PartImage.Write(ImageChunk)

However, I can open the file it would have converted in Acrobat Reader 5.0.


Public Sub WriteDBO(OptionName As String, ByVal DocName As String, DocFile As String)

Dim OraSession As OraSession ' oracle session object
Dim OitDB As OraDatabase ' oracle database object
Dim Part As OraDynaset ' oracle recordset object for the
Dim PartImage As OraBlob ' oracle binary large object object variable
Dim ImageChunk() As Byte ' temporary storage for the file object
Dim amount_written As Long ' the large object size variable

On Error GoTo DBErr:
'Create the OraSession Object.
Set OraSession = CreateObject("OracleInProcServer.XOraSession")

Set OitDB = OraSession.OpenDatabase(fm_OIT.tnsname, fm_OIT.usrname & "/" & fm_OIT.passwrd, 0&)

ThemeName = "Process"

MissionNameField = ThemeName + "_name"
DocumentNameField = ThemeName + "_doc_name"
DocumentBLOBField = ThemeName + "_doc"
DocumentFileField = ThemeName + "_doc_file"

TableName = ThemeName

SQLQuery = "select * from system." & TableName
Set Part = OitDB.CreateDynaset(SQLQuery, 0&)

Set PartImage = Part.Fields(DocumentBLOBField).Value

Part.AddNew
Part.Fields(MissionNameField).Value = OptionName
Part.Fields(DocumentNameField).Value = DocName
Part.Fields(DocumentBLOBField).Value = Empty
Part.Fields(DocumentFileField).Value = DocFile
Part.Fields(TypeNameField).Value = "Some Type"
Part.Update

'move to the newly added row
Part.MoveLast

'Open the file for reading PartImages
Open fm_OIT.tempdir & DocName For Binary As #1

'Re adjust the buffer size to hold entire file data
ReDim ImageChunk(LOF(1))

'read the entire file and put it into buffer
Get #1, , ImageChunk

'call dynaset's Edit method to lock the row
Part.Edit
amount_written = PartImage.Write(ImageChunk)
Part.Update

'close the file I/O channel

Close 1

Part.Close

End Sub
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

I am not very good in Oracle, but I will try to give you some advices from my knowledge of the PDF Converter.

Please check that the word document is not read only and not password protected.

Also please check in the registry under Hkey-Current-Config --> Software --> Amyuni PDF Converter that the values you for "File Location" , "File Name" and "Options" keys are valid at the time you are printing the word document to the PDF Printer.

If you are able to convert a Powrpoint document to pdf and not a Word document it should be something related to the Word document or to the way you are opening it and printing it.
I couldn't however see where is the function that prints the document to the PDF Printer, is it "amount_written = PartImage.Write(ImageChunk)" ?

Also what is the error you are getting?

Hope this will be helpful in any way.
tyrellc
Posts: 2
Joined: Thu Apr 17 2003
Location: South Africa
Contact:

Post by tyrellc »

I will check as indicated. The amount_written function is just writing to the database. The conversion is done by a batch convert function which is working fine. I can open the .pdf from the word document by double clicking on it.

Will revert back after checking and testing on your suggestions

Thanks

Tyrell
Post Reply