PDF Form Filler C/C++ header file, Merge FDF, XFDF, XML into fillable PDF forms, Flatten PDF Forms

PDF Form Filler SDK can be downloaded from following web page,
https://www.verypdf.com/app/pdf-form-filler/try-and-buy.html#buy-sdk

#ifndef __PDFFORMFUNC_H__

#define __PDFFORMFUNC_H__

 

#include <windows.h>

 

#ifdef __cplusplus

extern "C" {

#endif

 

#define EXTERN __declspec(dllexport)

 

//PDFForm_SetLicenseKey

//Parameters:

//  lpLicenseKey: a License Key which issued by VeryPDF

EXTERN void WINAPI PDFForm_SetLicenseKey(LPCTSTR lpLicenseKey);

 

 

//PDFForm_MergeFDFIntoPDF

//  Merge FDF file into an existing PDF file and generate a new filled PDF file.

//Parameters:

//  lpInPDF: input PDF file

//  lpInFDF: input FDF file

//  lpOutPDF: merged PDF file

//Return value:

//  TRUE is success, FALSE is fail

EXTERN BOOL WINAPI PDFForm_MergeFDFIntoPDF(LPCTSTR lpInPDF, LPCTSTR lpInFDF, LPCTSTR lpOutPDF);

EXTERN BOOL WINAPI PDFForm_MergeXFDFIntoPDF(LPCTSTR lpInPDF, LPCTSTR lpInFDF, LPCTSTR lpOutPDF);

 

 

//PDFForm_ExtractFDFFromPDF

//  Extract FDF file from a filled PDF file.

//Parameters:

//  lpInPDF: input PDF file

//  lpOutFDF: output FDF file

//Return value:

//  TRUE is success, FALSE is fail

EXTERN BOOL WINAPI PDFForm_ExtractFDFFromPDF(LPCTSTR lpInPDF, LPCTSTR lpOutFDF);

 

 

//PDFForm_FlattenPDF

//  Flatten a form filled PDF file

//Parameters:

//  lpInPDF: input PDF file

//  lpOutPDF: output PDF file

//Return value:

//  TRUE is success, FALSE is fail

EXTERN BOOL WINAPI PDFForm_FlattenPDF(LPCTSTR lpInPDF, LPCTSTR lpOutPDF);

 

 

//PDFForm_EncryptPDF

//  Encrypt a PDF file.

//Parameters:

//  lpInPDF: input PDF file

//  lpUserPwd: user password

//  lpOwnerPwd: owner password

//  lpPermissions: permissions, it can be following values,

//                                           Printing // top quality printing

//                                           ModifyContents = ModifyContents | Assembly

//                                           Copy = Copy | ScreenReaders

//                                           ModifyAnnotations = ModifyAnnotations | FillIn

//                                           FillIn

//                                           ScreenReaders

//                                           Assembly

//                                           DegradedPrinting

/*

Security Options:

    Printing:  Allow to print

    Modify Contents:  Allow to modify

    Copy:  Allow to copy or extract

    Modify Annotations: Allow to add or modify annotations or form fields

    Fill In:  Allow to input form field and signature (128-bit RC4 only)

    Screen Readers:  Allow to enable accessibility (128-bit RC4 only)

    Assembly:  Allow to modify document assembly (128-bit RC4 only)

    Degraded Printing:  Allow to print degraded mode (128-bit RC4 only)

*/

//  You can use "Allow" parameter to concatenate several options, e.g.,

//          "Printing Allow ModifyAnnotations Allow ModifyContents"

//          "DegradedPrinting Allow ModifyAnnotations Allow ModifyContents"

//          "FillIn Allow ModifyAnnotations Allow ModifyContents"

//  nKeyLen: 128 or 40 bits

//  lpOutPDF: output PDF file

//Return value:

//  TRUE is success, FALSE is fail

EXTERN BOOL WINAPI PDFForm_EncryptPDF(LPCTSTR lpInPDF, LPCTSTR lpUserPwd, LPCTSTR lpOwnerPwd, LPCTSTR lpPermissions,

                                                  int nKeyLen, LPCTSTR lpOutPDF);

 

 

//PDFForm_Alloc

//Return value:

// 0 is an error, other values are valid ID.

EXTERN long WINAPI PDFForm_Alloc();

 

 

//PDFForm_Free

//Parameters:

//  id: a valid ID returned by PDFForm_Alloc() function

//

//Return value:

//  0 is success, other values are indicate an error

EXTERN long WINAPI PDFForm_Free(long id);

 

 

//PDFForm_SetTextField

//Parameters:

//  id: a valid ID returned by PDFForm_Alloc() function

//  lpFieldName: form field name

//  lpFieldValue: form field value

//

//Return value:

//  if return value less than zero, it is indicate an error,

//  if return value large than zero, it is the number of form fields in the list

EXTERN long WINAPI PDFForm_SetTextField(long id, LPCTSTR lpFieldName, LPCTSTR lpFieldValue);

 

 

//PDFForm_SetCheckBox

//Parameters:

//  id: a valid ID returned by PDFForm_Alloc() function

//  lpFieldName: form field name

//  lpFieldValue: form field value

//

//Return value:

//  if return value less than zero, it is indicate an error,

//  if return value large than zero, it is the number of form fields in the list

EXTERN long WINAPI PDFForm_SetCheckBox(long id, LPCTSTR lpFieldName, LPCTSTR lpFieldValue);

 

 

//PDFForm_Apply

//Parameters:

//  id: a valid ID returned by PDFForm_Alloc() function

//  lpInFile: input PDF file

//  lpOutFile: output PDF file

//  bFlatten: make the output file flatten or not

//

//Return value:

//  0 is success, other values are indicate an error

//  -6: create FDF file error

//  -7: import form data into PDF file error

//  -8: flatten filled PDF file error

EXTERN long WINAPI PDFForm_Apply(long id, LPCTSTR lpInFile, LPCTSTR lpOutFile, LONG bFlatten);

 

 

//PDFForm_ClearFields

//Parameters:

//  id: a valid ID returned by PDFForm_Alloc() function

//

//Return value:

//  0 is success, other values are indicate an error

EXTERN long WINAPI PDFForm_ClearFields(long id);

 

//PDFForm_RepairFormFonts

//Repair fonts layout in PDF forms

//Parameters:

//  lpInPDF: input PDF file

//  lpOutFDF: output FDF file

//Return value:

//  TRUE is success, FALSE is fail

EXTERN BOOL WINAPI PDFForm_RepairFormFonts(LPCTSTR lpInPDF, LPCTSTR lpOutPDF);

 

 

//PDFForm_InsertDataMatrixImageIntoPDF

//Insert DataMatrix Image Into PDF file

//Parameters:

//  lpInPDF: input PDF file

//  lpOutFDF: output FDF file

//  lpFormName: DataMatrix form name

//  lpFormType: DataMatrix type, it can one of following values: DataMatrix, GS1DataMatrix, default is: DataMatrix

//  lpBarcodeText: Barcode text

//Return value:

//  TRUE is success, FALSE is fail

//

//int bRet = PDFForm_InsertDataMatrixImageIntoPDF("C:\\test.pdf", "C:\\out.pdf", "Datamatrix", "01034009377771791712073110BXBWWW22");

EXTERN BOOL WINAPI PDFForm_InsertDataMatrixImageIntoPDF(LPCTSTR lpInFile, LPCTSTR lpOutFile, LPCTSTR lpFormName, LPCTSTR lpBarcodeText);

EXTERN BOOL WINAPI PDFForm_InsertDataMatrixImageIntoPDF2(LPCTSTR lpInFile, LPCTSTR lpOutFile, LPCTSTR lpFormName, LPCTSTR lpFormType, LPCTSTR lpBarcodeText);

 

//PDFForm_InsertBarcodeIntoPDF

//Insert Barcode into PDF file

//Parameters:

//  lpInPDF: input PDF file

//  lpOutFDF: output FDF file

//  lpFormName: Barcode form name

//  lpFormType: Barcode type, lpFormType supports following CodeType:

//              private enum CodeType

//              {

//                        Code128,

//                        Code39,

//                        Codabar,

//                        Datamatrix,

//                        EAN,

//                        Inter25,

//                        PDF417,

//                        Postnet

//              }

//  lpFormValue: Barcode text

//Return value:

//  TRUE is success, FALSE is fail

//

EXTERN BOOL WINAPI PDFForm_InsertBarcodeIntoPDF(LPCTSTR lpInFile, LPCTSTR lpOutFile, LPCTSTR lpFormName, LPCTSTR lpFormType, LPCTSTR lpFormValue);

 

//PDFForm_InsertBarcodeIntoPDF2

//Insert Barcode into PDF file

//Parameters:

//  lpInPDF: input PDF file

//  lpOutFDF: output FDF file

//  lpFormValues: Parameters FieldIdBarcode, TypeBarcode, FieldValueBarcode as a string-list (separated by for example newline).

//                         Then we would do ONE call instead of n-times calling the proc with

//                         the n as the number of special fields

//  Barcode type supports following CodeType:

//              private enum CodeType

//              {

//                        Code128,

//                        Code39,

//                        Codabar,

//                        Datamatrix,

//                        EAN,

//                        Inter25,

//                        PDF417,

//                        Postnet

//              }

//Return value:

//  TRUE is success, FALSE is fail

//

//e.g.,

//

//string strFormValues;

//strFormValues += "BarCode1[0]=>Code128=>1234567890";

//strFormValues += "\n";

//strFormValues += "BarCode2[0]=>Code39=>1234567890";

//strFormValues += "\n";

//strFormValues += "BarCode3[0]=>Codabar=>A1234567890A";

//PDFForm_InsertBarcodeIntoPDF2("C:\\test.pdf", "C:\\out.pdf", strFormValues.c_str());

//

EXTERN BOOL WINAPI PDFForm_InsertBarcodeIntoPDF2(LPCTSTR lpInFile, LPCTSTR lpOutFile, LPCTSTR lpFormValues);

 

 

//Return value:

//  0 is no such field, 1 is contain this field

EXTERN BOOL WINAPI PDFForm_IsContainsField(LPCTSTR lpInFile, LPCTSTR lpFormName);

 

//PDFForm_GetAllFields

//Get all form fields from a PDF file

//Parameters:

//  lpInPDF: input PDF file

//  lpOutBuffer: output buffer which contain all fields

//  nOutBufferLength: length of lpOutBuffer

//

//Return value:

//  returns the maximum number length of output buffer which need to store the form fields, 0 is failed to read form fileds.

EXTERN int WINAPI PDFForm_GetAllFields(LPCTSTR lpInFile, char *lpOutBuffer, int nOutBufferLength);

 

//

EXTERN int WINAPI PDFForm_GetAllFields_ToFile(LPCTSTR lpInFile, LPCTSTR lpOutFile);

 

#ifdef __cplusplus

}

#endif

 

#endif

 

An example to call PDF Form Filler SDK from VC++ source code,

 

void PDFFormFilling2()

{

         BOOL bRet = FALSE;

         char szInPDFFile[MAX_PATH];

         char szInFDFFile[MAX_PATH];

         char szOutPDFFile[MAX_PATH];

         char szOutFDFFile[MAX_PATH];

         char szFlattenPDFFile[MAX_PATH];

         char szEncryptPDFFile[MAX_PATH];

         char drive[_MAX_DRIVE];

         char dir[_MAX_DIR];

         char fname[_MAX_FNAME];

         char ext[_MAX_EXT];

         char szExePathName[MAX_PATH];

         GetModuleFileName(NULL,szExePathName,MAX_PATH);

         _splitpath(szExePathName, drive, dir, fname, ext);

         _makepath(szInPDFFile, drive, dir, "example-fw9", ".pdf");

         _makepath(szInFDFFile, drive, dir, "example-fw9", ".fdf");

         _makepath(szOutPDFFile, drive, dir, "out-filled", ".pdf");

         _makepath(szOutFDFFile, drive, dir, "out", ".fdf");

         _makepath(szFlattenPDFFile, drive, dir, "out-flatten", ".pdf");

         _makepath(szEncryptPDFFile, drive, dir, "out-encrypt", ".pdf");

        

         PDFForm_SetLicenseKey("XXXXXXXXXXXXXXX");

         bRet = PDFForm_MergeFDFIntoPDF(szInPDFFile, szInFDFFile, szOutPDFFile);

         bRet = PDFForm_ExtractFDFFromPDF(szOutPDFFile, szOutFDFFile);

         bRet = PDFForm_FlattenPDF(szOutPDFFile,szFlattenPDFFile);

         bRet = PDFForm_EncryptPDF(szOutPDFFile, "123", "456", "Printing",

                128, szEncryptPDFFile);

}

 

VN:F [1.9.20_1166]
Rating: 4.0/10 (1 vote cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)
PDF Form Filler C/C++ header file, Merge FDF, XFDF, XML into fillable PDF forms, Flatten PDF Forms, 4.0 out of 10 based on 1 rating

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *


Verify Code   If you cannot see the CheckCode image,please refresh the page again!