Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) PDF File Encoding to Base64Demonstrates how to encode a PDF file to base64, and then decode.
#include <CkBinData.h> void ChilkatSample(void) { CkString strOut; CkBinData pdfData; bool success = pdfData.LoadFile("qa_data/helloWorld.pdf"); if (success != true) { strOut.append("failed to load PDF file."); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); 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". const char *b64 = pdfData.getEncoded("base64"); strOut.append(b64); strOut.append("\r\n"); // Decode from base64 PDF. CkBinData pdfData2; pdfData2.AppendEncoded(b64,"base64"); success = pdfData2.WriteFile("qa_output/helloWorld2.pdf"); if (success != true) { strOut.append("failed to write PDF file."); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.