Generate Barcode and Insert Barcode into PDF file, Barcode to PDF

Product Name: VeryPDF Form Filler SDK

https://www.verypdf.com/app/pdf-form-filler/pdf-form-filler-sdk-manual.html

VeryPDF Form Filler SDK product has ability to generate Barcode image and insert Barcode Image into PDF document, VeryPDF Form Filler SDK is support following barcode types,

//             Code128,
//             Code39,
//             Codabar,
//             Datamatrix,
//             EAN,
//             Inter25,
//             PDF417,
//             Postnet

Here is the definition for the Barcode relevant functions,

#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

//  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);

 

#ifdef __cplusplus

}

#endif

 

#endif

 

 

Here is the VC++ example to insert Barcode Image into PDF file,

 

void main(int argc, char *argv[])

{

    char szBarcodeTemp[MAX_PATH];

    GetModulePath(szBarcodeTemp, "Barcode-temp.pdf");

    char szBarcodeNew[MAX_PATH];

    GetModulePath(szBarcodeNew, "_Barcode-out.pdf");

    CopyFile(szBarcodeTemp, szBarcodeNew, FALSE);

 

    BOOL bRet = FALSE;

    PDFForm_SetLicenseKey("XXXXXXXXXXXXXXXXXXXXX");

    bRet = PDFForm_InsertBarcodeIntoPDF(szBarcodeNew, szBarcodeNew, "BarCode1[0]", "Code128", "1234567890");

    bRet = PDFForm_InsertBarcodeIntoPDF(szBarcodeNew, szBarcodeNew, "BarCode2[0]", "Code39", "1234567890");

    bRet = PDFForm_InsertBarcodeIntoPDF(szBarcodeNew, szBarcodeNew, "BarCode3[0]", "Codabar", "A1234567890A");

    bRet = PDFForm_InsertBarcodeIntoPDF(szBarcodeNew, szBarcodeNew, "BarCode4[0]", "Datamatrix", "01034009377771791712073110BXBWWW22");

    bRet = PDFForm_InsertBarcodeIntoPDF(szBarcodeNew, szBarcodeNew, "BarCode5[0]", "EAN", "01234567890100");

    bRet = PDFForm_InsertBarcodeIntoPDF(szBarcodeNew, szBarcodeNew, "BarCode6[0]", "Inter25", "123456789");

    bRet = PDFForm_InsertBarcodeIntoPDF(szBarcodeNew, szBarcodeNew, "BarCode7[0]", "PDF417", "1234567890");

    bRet = PDFForm_InsertBarcodeIntoPDF(szBarcodeNew, szBarcodeNew, "BarCode8[0]", "Postnet", "1234567890");

    printf("Return value is: %d\n", bRet);

    return;

}

 

void main(int argc, char *argv[])

{

 

    {

    char szBarcodeTemp[MAX_PATH];

    GetModulePath(szBarcodeTemp, "Barcode-temp.pdf");

    char szBarcodeNew[MAX_PATH];

    GetModulePath(szBarcodeNew, "_Barcode-temp-out.pdf");

 

    BOOL bRet = FALSE;

    PDFForm_SetLicenseKey("XXXXXXXXXXXXXXXXXXXXX");

                               

    string strFormValues;

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

    strFormValues += "\n";

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

    strFormValues += "\n";

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

    strFormValues += "\n";

    strFormValues += "BarCode4[0]=>Datamatrix=>01034009377771791712073110BXBWWW22";

    strFormValues += "\n";

    strFormValues += "BarCode5[0]=>EAN=>01234567890100";

    strFormValues += "\n";

    strFormValues += "BarCode6[0]=>Inter25=>123456789";

    strFormValues += "\n";

    strFormValues += "BarCode7[0]=>PDF417=>1234567890";

    strFormValues += "\n";

    strFormValues += "BarCode8[0]=>Postnet=>1234567890";

    strFormValues += "\n";

    strFormValues += "DataMatrixBarCode1=>GS1DataMatrix=>(1)12345678901234(17)BX123456CrLfHumanReadablePosition";

    bRet = PDFForm_InsertBarcodeIntoPDF2(szBarcodeTemp, szBarcodeNew, strFormValues.c_str());

 

    printf("Return value is: %d\n", bRet);

    }

 

    {

    char szBarcodeTemp[MAX_PATH];

    GetModulePath(szBarcodeTemp, "Barcode-temp2.pdf");

    char szBarcodeNew[MAX_PATH];

    GetModulePath(szBarcodeNew, "_Barcode-temp2-out.pdf");

                               

    BOOL bRet = FALSE;

    PDFForm_SetLicenseKey("XXXXXXXXXXXXXXXXXXXXX");

                               

    string strFormValues;

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

    strFormValues += "\n";

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

    strFormValues += "\n";

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

    strFormValues += "\n";

    strFormValues += "BarCode4[0]=>Datamatrix=>01034009377771791712073110BXBWWW22";

    strFormValues += "\n";

    strFormValues += "BarCode5[0]=>EAN=>01234567890100";

    strFormValues += "\n";

    strFormValues += "BarCode6[0]=>Inter25=>123456789";

    strFormValues += "\n";

    strFormValues += "BarCode7[0]=>PDF417=>1234567890";

    strFormValues += "\n";

    strFormValues += "BarCode8[0]=>Postnet=>1234567890";

    strFormValues += "\n";

    strFormValues += "BarCode10[0]=>GS1DataMatrix=>(1)12345678901234(17)BX123456CrLfHumanReadablePosition";

    bRet = PDFForm_InsertBarcodeIntoPDF2(szBarcodeTemp, szBarcodeNew, strFormValues.c_str());

                               

    printf("Return value is: %d\n", bRet);

    }

    return;

}

 

This is a sample Barcode PDF file,

image

VN:F [1.9.20_1166]
Rating: 4.0/10 (1 vote cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)
Generate Barcode and Insert Barcode into PDF file, Barcode to PDF, 4.0 out of 10 based on 1 rating

Related Posts

One Reply to “Generate Barcode and Insert Barcode into PDF file, Barcode to PDF”

  1. Hi,

    Just an inquiry on PDF Stamp. I have a Visual Foxpro 9.0 project that requires adding a barcode to the lower right corner of every page of an existing pdf file. The barcode value will depend on the Member No. of the owner of the pdf file so I plan to stamp the barcode as a font, not an image. Do you have a product that can support this requirement?

    Best Regards,
    Customer
    ——————————————–
    Thanks for your message, PDFStamp Command Line application does support barcode stamping, please look at following web page,

    http://www.verypdf.com/wordpress/201109/pdf-stamp-command-line-is-support-barcode-now-2395.html

    You can run following command line to stamp barcode to your PDF files,

    pdfstamp.exe -pdf pdftest.pdf -o pdftest-out.pdf -at 1234567890 -ft “Free 3 of 9”

    VeryPDF

    VN:F [1.9.20_1166]
    Rating: 0.0/5 (0 votes cast)
    VN:F [1.9.20_1166]
    Rating: 0 (from 0 votes)

Leave a Reply to VeryPDF Cancel 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!