![]() |
Chilkat • HOME • Android™ • AutoIt • C • C# • C++ • Chilkat2-Python • CkPython • Classic ASP • DataFlex • Delphi DLL • Go • Java • Node.js • Objective-C • PHP Extension • Perl • PowerBuilder • PowerShell • PureBasic • Ruby • SQL Server • Swift • Tcl • Unicode C • Unicode C++ • VB.NET • VBScript • Visual Basic 6.0 • Visual FoxPro • Xojo Plugin
(Unicode C) PDF File Encoding to Base64Demonstrates how to encode a PDF file to base64, and then decode.
#include <C_CkBinDataW.h> void ChilkatSample(void) { HCkBinDataW pdfData; BOOL success; const wchar_t *b64; HCkBinDataW pdfData2; pdfData = CkBinDataW_Create(); success = CkBinDataW_LoadFile(pdfData,L"qa_data/helloWorld.pdf"); if (success != TRUE) { wprintf(L"failed to load PDF file.\n"); CkBinDataW_Dispose(pdfData); return; } // Encode the PDF to base64 // Note: to produce base64 on multiple lines (as it would appear in the MIME of an email), // pass the string "base64_mime" instead of "base64". b64 = CkBinDataW_getEncoded(pdfData,L"base64"); wprintf(L"%s\n",b64); // Decode from base64 PDF. pdfData2 = CkBinDataW_Create(); CkBinDataW_AppendEncoded(pdfData2,b64,L"base64"); success = CkBinDataW_WriteFile(pdfData2,L"qa_output/helloWorld2.pdf"); if (success != TRUE) { wprintf(L"failed to write PDF file.\n"); CkBinDataW_Dispose(pdfData); CkBinDataW_Dispose(pdfData2); return; } CkBinDataW_Dispose(pdfData); CkBinDataW_Dispose(pdfData2); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.