« Real Studio Meeting i… | Home | CrossToolbarKSW - Too… »

DynaPDF Basics

Here are a few basic things you should know and use in your code like the instances, fonts, error event, the color management and character maps.


Initializing a DynaPDFMBS object is time consuming as some initialization code needs to run like finding the fonts on the system. As initialization is costly, you should reuse the object. You call CreateNewPDF again to start a new PDF on the same instance. Of course you should call CloseFile and FreePDF before to cleanup.


On Mac OS X and Windows we automatically load fonts from system font folder. But for other font folders or on Linux, you need to call AddFontSearchPath yourself to scan a folder for font files. That is important to know for people using web apps. Because we have users from time to time which have a web app working well on Mac or Windows, but they see no fonts on Linux.
This standard fonts are always available: Courier, Helvetica, Times, Symbol and ZapfDingbats.

Error Event

You should use the error event. This is an event where you are informed about all errors. While most functions return false or an error code in case of an error, the event gives you a way to decide if you want to ignore an error or handle it. Like when you set a font and the font can't be used. In that case you get error type being kE_WARNING and ErrorCode being 16. In that case you could simply ignore the error and call SetFont again with a different font name. So in error event depending on the error type (kE_FATAL_ERROR, kE_FILE_ERROR, kE_FONT_ERROR, kE_SYNTAX_ERROR, kE_VALUE_ERROR or kE_WARNING), you can decide if you want to display error to user or not.

Color Matching

Please take some time to learn the basics about color matching. If you want DynaPDF to correctly raster PDFs, you need to make sure color matching is initialized properly and used correctly. For that you call InitColorManagement method and pass some profiles. Create a new DynaPDFColorProfilesMBS object and set its properties. You can define a screen profile, a soft proof profile and default profiles for CMYK, RGB and grayscale colors. While RGB and gray profiles are really optional, you should always provide a screen profile for the target color space. If you render an image, this should be a the output color space for that image. If you render for displaying on screen, you should use the profile of your display. Also it is important to provide a default CMYK profile. As separation colors are normally defined with an alternative color in another color space (usually CMYK), this default CMYK profile is important to render them correctly to RGB.

Character Maps

You need to use SetCMapDir. Included with DynaPDF Examples you get a folder called CMAP with character mapping files. Those files are needed for mapping asian character correctly. So if you want to extract text correctly from any PDF, please use SetCMapDir to inform DynaPDF where to find the CMap files. They are needed to map back glyph IDs to actual unicode characters which is required for extracting, deleting or replacing them. The biggest plugin in space...
29 12 12 - 22:31

Start Chat