In this article, I will show you how to insert text to PDF by COM software. Meanwhile this method can also be used to append text file to an existing PDF. COM software allows you to run the conversion together with VB, VC, C# etc. The software I will use is VeryDOC Doc Converter COM, by which you can also integrate the corresponding SOFTWARE into your developed software and redistribute it with royalty-free. You have the right to modify and use the SOFTWARE source codes. Please check more information of this software on homepage. In the following part, let us check how to use this software.
Step 1. Free download Doc Converter COM
- When downloading finishes, there will be a zip file. Please extract it to some folder then you can use this software.
- In the extracted package, you will find the following elements:
pdfout.dll:This is the DocConverter COM Component, you must register it into your system prior to use the HTML2PDF.exe application, "install_as_exe.bat" and "install_as_service.bat" files will install and register pdfout.dll file into your system automatically.
install_as_service.bat: It will copy all necessary files to system32 folder and install "doc2pdf_service.exe" as a System Service, the Service Name is "VeryPDF DocConverter COM Service", you can start, stop, restart this Service from Windows System Service Management Application.
install_as_exe.bat: It will copy all necessary files to system32 folder and install "doc2pdf_service.exe" as a Normal Windows Application.
uninstall.bat:It will uninstall DocConverter COM from your Windows System.
Step 2. Insert text to PDF by this COM software.
- When you use this software, please refer to the usage and code templates.
- Here are some functions code examples, please have a check.
- When you need to insert "C:/test.txt" file at the first page of an existing PDF file, please refer to the following command line template.
"html2pdf.exe" "C:/test.txt" "C:/output.pdf" "AutomaticValue=3,Overwrite=yes"
"html2pdf.exe" "C:/test.doc" "C:/output.pdf" "AutomaticValue=3,Overwrite=yes"
"html2pdf.exe" "C:/test.html" "C:/output.pdf" "AutomaticValue=3,Overwrite=yes" - When you need to append "one text file at the end of PDF file, please refer to the following command line templates:
"html2pdf.exe" "C:/test.txt" "C:/output.pdf" "AutomaticValue=4,Overwrite=yes"
"html2pdf.exe" "C:/test.doc" "C:/output.pdf" "AutomaticValue=4,Overwrite=yes"
"html2pdf.exe" "C:/test.html" "C:/output.pdf" "AutomaticValue=4,Overwrite=yes" - By this software, you can specify output PDF file name template by the following command line templates:
- You can also specify output PDF file paper size like the following output paper formats:
Set output pdf filename,For Example,Doc2PDFCOM.fileName = "C:/html2pdf.pdf"
Set page type, the value is from 0 to 9,
0 "Letter [8.5 x 11 in]",
1 "Legal [8.5 x 14 in]",
2 "Executive [7.25 x 10.5 in]",
3 "Ledger [355.6 x 215.9 mm]",
4 "Tabloid [11 x 17 in]",
5 "Screen [10 x 7.5 in]",
6 "A3 [297 x 420 mm]",
7 "A4 [210 x 297 mm]",
8 "A5 [148 x 210 mm]",
9 Custom page size
For Example,
Doc2PDFCOM.paperType = 7;
So by those parameters, you can insert text to PDF easily. Please check more functions of this software on user manual. During the using, if you have any question, please contact us as soon as possible.