![]() |
Telelogic System Architect (steve huntington) | ![]() |
Topic Title: Data files to 64 base encoding Topic Summary: I know where the files are stored, wmf files, but I want to extract them into a base 64 encoded string. Created On: 31-Jul-2006 05:30 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I know where the files are stored, wmf files, but I want to extract them into a base 64 encoded string for an wordprocessingML report. Using the following SQL string in SQL Server 2000:
select data from files where name = 'D0000006.wmf' FOR XML raw, binary base64This returns a useless string. I'm hoping Dale or someone has the answer to this: - How are the files stored within the Image field in the Files table? - What sort of transformation returns the raw binary file so I can encode it into a string? Thanks. ![]() |
|
![]() |
|
![]() |
|
Man, talk about giving me the hard one!!! Don't know if I'll be able to help you with this one, but I'll tell you what I did to get the usrmatrx.xml file out of the files table, and see if that helps you. Note that I did this in vba instead of directly through SQL Server, so it may be of no use to you anyway.
Here is a portion of the code I used: |
|
![]() |
|
![]() |
|
Thanks Dale. I'll check it out when I get to work.
![]() |
|
![]() |
|
![]() |
|
Got the base 64 encoding working from SQL Server, but it is encoding a WMF file which is not recognised by Word 2003, especially in a WordprocessingML file. Woohoo. So here's the plan:
The file is pumped out to a WMF file. Using good old interoperatiblity, VBA creates a public PowerPoint application in the background. The WMF file is inserted into a presentation and then saved as an EMF file. The EMF file is read back into a BLOB and retrieved as a base 64 encoded string (because I can't be bothered waiting for VBA to convert the data into base 64 code using byte manipulating functions). The string is inserted into the WordprocessingML file and hey presto... We have a meta-file that is scaleable within MS Word. It's prolix in it's processes but mapped out well. I'll probably do the file conversions to EMF and hold them within a temp table in SQL Server for retrieval as base64 strings after processing the rest of the XML for the document. ![]() |
|
![]() |
|
![]() |
|
Good work Duane! If you want to skip the Powerpoint step, you can convert from WMF to EMF using a win32 API call(assuming that you are on 32-bit windows, and I am assuimg that. I'm not up to snuff on the 64-bit API of windows yet. I'm also assuming you aren't on 16-bit, and you can't be because these apps don't run on 16-bit platforms!).
WMF to EMF SetWinMetaFileBits() http://msdn.microsoft.com/libr...gdi/metafile_1xwz.asp EMF to WMF GetWinMetaFileBits() http://msdn.microsoft.com/libr.../gdi/metafile_9bzn.asp |
|
![]() |
|
![]() |
|
Excellent. I forgot about API's. Thanks Jonathon
![]() |
|
![]() |
|
![]() |
|
Hey Jonathon,
I played around with those API's you gave me and nailed it. So far, I have to convert from a WMF file to an EMF file, but I figure with some more tweaking I should be able to just copy the bytes straight into memory and convert them from there.
Code attached...
![]() |
|
![]() |
|
![]() |
|
In fact, now I've looked at it. I can avoid doing anything outside of the memory: |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.