C/C++ Interface

The C/C++ Interface makes it possible to integrate AHPDFXML Conversion Library V2.0 into the C/C++ program.

Header File

The following header file is included in [Install directory]/include.

Header File Contents Location
apxa_interface.h Header for C++ [Install directory]/include
/AH/*.h
/AHCommon/*.h
/AHVersion/*.h
Header file included in apxa_interface.h [Install directory]/include
/ICU/icu*.h ICU related header file [Install directory]/include

Library File

The following library files are included in [Install directory] or [Install directory]/lib.

Library File Contents Location
AHPDFAnalyzer20.dll etc.
Please refer to "Windows Module Configuration" for more details.
C/C++ Interface for Windows [Install directory]
AHPDFAnalyzer.so etc.
Please refer to "Linux Module Configuration" for more details.
C/C++ Interface for Linux [Install directory]/lib

In the Windows version, the following library files for links are included in [Install directory]/lib

Library File Contents Location
AHPDFAnalyzer.libLibrary for DLL link [Install directory]/lib
AHCommon13.lib Common library [Install directory]/lib
icu*.lib ICU related library [Install directory]/lib

Compilers

Windows

AHPDFXML Conversion Library V2.0 Windows version is built with Microsoft Visual Studio 2015.
Use a compatible compiler for the program.

Note: The Windows 32-bit version can be installed on Windows 64-bit. In this case, the program using the C/C++ Interface must be compiled for Win32.

Linux

AHPDFXML Conversion Library V2.0 Linux 64-bit version is built with GCC 4.8. Therefore, the program must be compiled with GCC 4.8 or later.
Refer to GCC, the GNU Compiler Collection for more details.

AHPDFXML Conversion Class APXA Converter

[Method]
int APXA_GetPageCount(std::istream *inputStream);

[Feature]
Acquires PDF page number

[Parameter]
inputStream: PDF file stream

[Return Value]
Page number
[Method]
void APXA_SetBaseName(AHString baseName);

[Feature]
Specifies output file base name

[Paramete]
baseName: Output file base name

[Return Value]
None
[Method]
void APXA_SetOutFolder(AHString outFolder);

[Feature]
Specifies output data folder

[Parameter]
outFolder: Output folder name

[Return Value]
None
[Method]
APXA_ERROR APXA_SetPassword(AHString password);

[Feature]
Specifies the access password

[Parameter]
password : Password character string(less than 32 characters)(input:required)

[Return Value]
APXA_ERROR
[Method]
void APXA_SetConversionOption(int option);

[Feature]
Specifies conversion condition

[Parameter]
option: Conversion condition

[Return Value]
None
[Method]
void APXA_SetStartPage(int pageNo);

[Feature]
Specifies the starting page number of conversion
If this method is not called, conversion starts from the first page.

[Parameter]
pageNo: Starting page number

[Return Value]
None
[Method]
void APXA_SetEndPage(int pageNo);

[Feature]
Specifies the end page number of conversion
If this method is not called, conversion goes through to the last page.

[Parameter]
pageNo: End page number

[Return Value]
None
[Method]
APXA_ERROR APXA_Convert(inputStream);

[Feature]
Converts PDF file to AHPDFXML

[Parameter]
std::istream *input PDF stream(input:required)

[Return Value]
APXA_ERROR

Examples of APXA_Converter class

/**
* Converts PDF to AHPDFXML with APXA_Converter().
*/
void execute()
{
    // Makes APXA_Converter() class.
    APXA_ANALYZER::APXA_Converter *converter = new APXA_ANALYZER::APXA_Converter();

    AHString outputFolder = "D:\\OUTFOLDER";
    AHString prefix = "TEST";
    AHString accessPassword = "abc";
    // Specifies output folder.
    converter->APXA_SetOutFolder(outputFolder);
    // Specifies base file name.
    converter->APXA_SetBaseName(prefix);

    std::ifstream pdfstream;
    std::istream *inputStream;
    char inputfile[1024] = "d:\\INPUTFOLDER\\test.pdf";
    // Makes input stream.
    pdfstream.open(inputfile, std::ios_base::in|std::ios_base::binary);
    if(pdfstream.good()) {
        inputStream = new std::istream(pdfstream.rdbuf());
    }
    else {
        // Make error message.
        return;
    }
    // Specifies the password, if a user has.
    if (accessPassword.length() != 0)
        converter->APXA_SetPassword(accessPassword);
    int pageCount;
    try {
        // Acquires page number.
        pageCount = converter->APXA_GetPageCount(inputStream);
        if (pageCount == 0) {
            // Makes eroor message.
            return;
        }
        // Specifies conversion condition.
        converter->APXA_SetConversionOption(APXA_ANALYZER::APXA_OPT_UNDERLINEOUT | APXA_ANALYZER::APXA_OPT_NOTTEXTSVG);
        // Specifies start page.
        converter->APXA_SetStartPage(1);
        // Specifies end page.
        converter->APXA_SetEndPage(pageCount);
        // Runs conversion.
        converter->APXA_Convert(inputStream);
    } catch (const int& error) {
        // Makes error message.
    }
    return;
}

Explanation of error code APXA_ERROR

APXA_SUCCESS = 0 Normal end
APXA_OPEN_ERROR = 1 Cannot open PDF file
APXA_PASSWORD_ERROR = 2 Password is set to PDF file
APXA_READ_ERROR = 3 Cannot read PDF file
APXA_PAGE_ERROR = 4 Error occurred during page processing
APXA_SECTION_ERROR = 5 Error occurred during section processing
APXA_FRAME_ERROR = 6 Error occurred during frame processing
APXA_PARAGRAPH_ERROR = 7 Error occurred during paragraph processing
APXA_TEXTLINE_ERROR = 8 Error occurred during text line processing
APXA_TEXT_ERROR = 9 Error occurred during text processing
APXA_CELL_ERROR = 10 Error occurred during cell processing
APXA_GRAPHIC_ERROR = 11 Error occurred during image processing
APXA_TABLE_ERROR = 12 Error occurred during table processing
APXA_ROW_ERROR = 13 Error occurred during table line processing
APXA_SVG_ERROR = 14 Error occurred during SVG processing
APXA_WRITE_ERROR = 15 Error occurred during AHPDFXML writing
APXA_OUTFOLDER_ERROR = 16 Output folder error
APXA_LICENSE_ERROR = 17 License file error
APXA_OTHER_ERROR = 18 An unspecified error occurred

Explanation of Conversion Conditions

APXA_OPT_ONECHAR = 0x00000001 Splits the run element (ahp:run) into single characters with coordinate information.
If this condition is set, each character will be outputted separately.
APXA_OPT_CIDOUTPUT = 0x00000002 Outputs character ID (CID), not only unicode.
The character ID is used to acquire character glyphs from a font file.
APXA_OPT_TABLE_NOT_PUT = 0x00000008 No table analysis.
Set this condition if the conversion of tables with many line images are not required.
APXA_OPT_ALL_TEXT_IS_SHAPE = 0x00000010 Outputs characters to text boxes.
If this condition is set, the text in a PDF will be outputted into text boxes.
APXA_OPT_UNDERLINEOUT = 0x00000040 Analyzes the underlines of characters.
If this condition is set, straight lines under characters will convert to underline attribute.
APXA_OPT_PICTURENOTOUT = 0x00000080 Specifies that graphics will not be outputted as SVG images.
Note: Embedded images in the original PDF are always outputted regardless of this setting.
APXA_OPT_PARANOTCREATEINCELL = 0x00000100 Does not create a paragraph in a table cell.
If this condition is set, a line break will be inserted after every line of text in a cell.
APXA_OPT_NOTTEXTSVG = 0x00000200 If there are characters in an SVG image area, this condition will convert the characters to text.
If this condition is not set, characters in the SVG image area will be included in the SVG output.
APXA_OPT_NOTIMAGESVG = 0x00000400 Outputs the original image without clipping.
If this condition is not set, the image is converted as SVG with clipping.

Copyright (c) 2015-2017 Antenna House, Inc. All rights reserved.
Antenna House is a trademark of Antenna House, Inc.