Question:I've scoured the Web looking for examples on how to do this. I've found a few that seem to be a little more involved then they need to be. So my question is, using some VeryPDF application, is there a fairly concise way to append one PDF or doc file to another one? Optimally this would NOT involve a third file. Just open the first PDF and doc, append it to second PDF.
Answer: According to your understanding, you need to add attachment to PDF using C++, as you can not append doc document, PDF file together to another PDF file unless convert doc to PDF and them merge them all together. For adding attachment to PDF using C++, maybe you can have a free trial of software VeryPDF Advanced PDF Tools, by which you can call it together with with programming language like C#, VB .NET, MS Visual Basic, Borland Delphi, VBA (MS Office products such as Access) and C++ via COM, C and C++ via native C. Please check more information of this software on homepage, in the following part, I will show you how to use this software.
Step 1. Free download Advanced PDF Tools SDK
- This software has been packaged to zip file. When downloading finishes,please unpack it to folder then you can check elements in it.
- This software is Windows application, for now it can not be called from other platforms.
Step 2. Add attachment of PDF, word to another PDF using C++.
- When you use this software, please refer to its usage, code template and other files.
- Here are some parameters and code templates for adding attachment to PDF, please have a check.
- When you need to run the process using C++, please refer to the following code template:
-S "attachfiles=file1|file2|file3|file4" : Attach files into PDF file
e.g. -S "attachfiles=C:\1.txt|C:\2.jpg|C:\3.pdf"
-S "attachfiles=C:\filelist.lst" : Retrieve files from a .txt file
-S "collection=true" : Enable collection feature for attachments
-S "collection=false" : Disable collection feature for attachments
Attach various files to PDF files:
pdftools -S "attachfiles=C:\1.txt|C:\2.jpg|C:\3.pdf" -i C:\in.pdf -o C:\out.pdf
pdftools -S "attachfiles=C:\*.*" -i C:\in.pdf -o C:\out.pdf
pdftools -S "attachfiles=C:\filelist.lst" -i C:\in.pdf -o C:\out.pdf
pdftools -S collection=true -S "attachfiles=C:\filelist.lst" -i C:\in.pdf -oC:\out.pdf
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <io.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <conio.h>
#include <ctype.h>
#include <windows.h>
__declspec(dllexport)
int WINAPI VeryPDF_PDFTools(LPCTSTR lpCommand);
void main()
{
char szCommandLine[1024];
char *lpLicenseKey = "XXXXXXXXXXXXXX";
sprintf(szCommandLine,""pdftools.exe \"-$\" \"%s\" -S\"attachfiles=C:\1.pdf|C:\2.doc|
\" -i \"%s\" -o \"%s\"",
lpLicenseKey, "C:\\test.pdf", "C:\\_test.pdf");
int nRet = VeryPDF_PDFTools(szCommandLine);
}
By this software and this method, you can solve your problem. During the using, if you have any question, please contact us as soon as possible.