Tutorial: Create Your First PDF Project
In this tutorial, you will create a C/C++ Windows console application and use ImageGear components to open a PDF file and save it as a new file.
The following tutorial refers specifically to 64-bit installations. For 32-bit installations, throughout these instructions, substitute x64 with x86.
Using Visual Studio (2015 or later):
- Create a new "Win32 Console Application" project named "IG_Tutorial_PDF".
- Create a new solution platform for platform x64.
- Set the solution configuration to either "Debug|x64" or "Release|x64" and apply the following changes:
- Set Configuration Properties\General\Output Directory to the absolute path to the ImageGear binaries directory.
e.g. [INSTALLDIR]\ImageGear for C and C++ vXX\Build\Bin\x64\
- Modify project setting Configuration Properties\C/C++\General\Additional Include Directories to include the absolute path to ImageGear header files directory.
e.g. [INSTALLDIR]\ImageGear for C and C++ vXX\Build\Include
- Modify project setting Configuration Properties\Linker\General\Additional Library Directories to include the absolute path to ImageGear libraries directory.
e.g. [INSTALLDIR]\ImageGear for C and C++ vXX\Build\Lib\x64
- Modify project setting Configuration Properties\Linker\Input\Additional Library Dependencies to link with the ImageGear CORE component import library, igCOREXXd.lib.
- At this point, your project is ready for some sample code. We will highlight key snippets in the following steps. But first, open the source file, IG_Tutorial_PDF.cpp, which Visual Studio created automatically, and replace with the following:
- If you are using a Deployment license (also known as "Runtime" license), then add the license initialization code. This is not necessary if you are using an Evaluation license or Development license (also known as a "Toolkit" license).
- To work with PDF documents you always need to attach and initialize the PDF component:
- We load the PDF document using:
- We save the loaded document with a new file name:
The majority of ImageGear functions return either an error code, enumIGErrorCodes, or an error count, AT_ERRCOUNT. For brevity, we ignore ImageGear return values in this sample except for saving. This will allow us to indicate that saving was successful with an appropriate message and exit code.
- Finally, release any ImageGear resources and terminate the component before exiting:
Now that you've created your first PDF project in ImageGear, you're ready for more advanced functionality. You can start with our suite of PDF Samples, browse the How to... topics, or dig right into the PDF API.