Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
Load file into XML as Base64 Encoded ContentLoads any type file into an XML document. The file content is encoded as base64. CREATE PROCEDURE ChilkatSample AS BEGIN DECLARE @hr int DECLARE @sTmp0 nvarchar(4000) DECLARE @docRoot int EXEC @hr = sp_OACreate 'Chilkat.Xml', @docRoot OUT IF @hr <> 0 BEGIN PRINT 'Failed to create ActiveX component' RETURN END DECLARE @success int EXEC sp_OASetProperty @docRoot, 'Tag', 'myDoc' -- To zip compress the content, set this flag to 1 DECLARE @zipContent int SELECT @zipContent = 0 -- To 128-bit AES encrypt the content, set this flag to 1 DECLARE @encryptContent int SELECT @encryptContent = 0 DECLARE @encryptPassword nvarchar(4000) SELECT @encryptPassword = '' DECLARE @pdfNode int EXEC sp_OAMethod @docRoot, 'NewChild', @pdfNode OUT, 'pdf', '' -- Embed a PDF into XML EXEC sp_OAMethod @pdfNode, 'SetBinaryContentFromFile', @success OUT, 'sample.pdf', @zipContent, @encryptContent, @encryptPassword IF @success <> 1 BEGIN EXEC sp_OAGetProperty @pdfNode, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END EXEC sp_OAGetProperty @pdfNode, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 -- Display the entire XML document: EXEC sp_OAMethod @docRoot, 'GetXml', @sTmp0 OUT PRINT @sTmp0 -- Get the Base64-encoded content and display it: EXEC sp_OAGetProperty @pdfNode, 'Content', @sTmp0 OUT PRINT @sTmp0 -- Extract the binary content from XML: DECLARE @unzipContent int SELECT @unzipContent = 0 DECLARE @decryptContent int SELECT @decryptContent = 0 DECLARE @decryptPassword nvarchar(4000) SELECT @decryptPassword = '' EXEC sp_OAMethod @pdfNode, 'SaveBinaryContent', @success OUT, 'out.pdf', @unzipContent, @decryptContent, @decryptPassword IF @success <> 1 BEGIN EXEC sp_OAGetProperty @pdfNode, 'LastErrorText', @sTmp0 OUT PRINT @sTmp0 RETURN END PRINT 'Success!' END GO |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.