Archive your project files safely and securely. See how easy it is to develop a powerful PDF Converter that combines your project documents into a single PDF.
Here we are going to show you how to develop an application that combines and converts multiple files to PDF. Most companies need a tool to convert their artifacts to a single PDF for ease of record keeping and archival. Since a PDF document cannot be tampered, it is the most popular format for archival, and is widely supported. When you finish a project, you would want to transfer all the documents to one file in portable document format. This file then is safely and securely stored in your knowledge database.Let’s suppose we want to build an app that does the following operations:
- Combine all files in different format inside the project folder together;
- Convert those files to a single PDF file (that to be used as an archive);
- Add date and time of the operation (conversion) at the top of each page, as a header;
- Add a watermark (as an example: "Archive") on every page in the document.
The coding process uses three core methods. We will begin with the core Method, that will make reference to two other specialized Methods as well, that will be discussed later.
First, this block below is primarily involved with preparation work: to get the file directory we are using, check to make sure it exists, and set up some information to sort through input files. In this case, we have restricted it to some general file types.
string iDIR = "";
List<string> iFILs = new List<string>();
List<string> mFILs = new List<string>();
List<string> fFILs = new List<string>();
List<string> cFILs = new List<string>() { ".doc", ".docx", ".rtf", ".txt", ".xls", ".xlsx", ".htm", ".html" };
if (args.Length >= 1) { iDIR = args[0]; }
if(Directory.Exists(iDIR))
Next, we get the list of files in the directory and sort through it to only convert files included in the list of cFILs which lists the File Extensions the application will happen.
string[] tiFILs = Directory.GetFiles(iDIR);
foreach(string s in tiFILs)
{
string ext = Path.GetExtension(s).ToLower();
if (cFILs.Contains(ext)) { iFILs.Add(s); }
}
After that, we convert each file. If it is successful, we add the output file's name to the mFILs Array to get a single list of filenames for merging later.
foreach(string s in iFILs)
{
string cvr = Convert(s);
if (File.Exists(cvr)) { mFILs.Add(cvr); }
else { fFILs.Add(s + ":" + cvr); }
}
Once the files are all converted, Merge the array of files into a single PDF. This DOES NOT Delete the Intermediary Files because this is just a demo. In a Production Application they would probably want to delete these files eventually, or even just convert them into memory, but that's more advanced.
if (mFILs.Count > 0)
{
res = Merge(mFILs.ToArray(), iDIR);
}
From here we need to look at the Convert Method. This is a very important Method because it not only converts the file, but takes advantage of PDFSetting Object to apply both the ‘ARCHIVE’ Watermark and the Conversion Heading in one single method call that automatically applies these to all pages in the PDF. Fortunately easyPDF SDK can apply multiple Watermarks which can each have their own settings.
Printer oPRIN = new Printer();
PrintJob oPJOB = oPRIN.PrintJob;
try
{
PDFSetting oPSET = oPJOB.PDFSetting;
oPSET.set_Watermark(0, true);
oPSET.set_WatermarkText(0, "ARCHIVE");
oPSET.set_WatermarkFirstPageOnly(0, false);
oPSET.set_WatermarkHPosition(0, prnWmarkHPosition.PRN_WMARK_HPOS_CENTER);
oPSET.set_WatermarkVPosition(0, prnWmarkVPosition.PRN_WMARK_VPOS_CENTER);
oPSET.set_WatermarkZOrder(0, prnWmarkZOrder.PRN_WMARK_ZORDER_TOP);
oPSET.set_WatermarkTextAlignment(0, prnWmarkAlignment.PRN_WMARK_ALIGN_LEFT);
oPSET.set_WatermarkHOffset(0, 0);
oPSET.set_WatermarkVOffset(0, 0);
oPSET.set_WatermarkFontName(0, "Arial");
oPSET.set_WatermarkFontSize(0, 100);
oPSET.set_WatermarkAngle(0, 60);
oPSET.set_WatermarkOutlineOnly(0, true);
oPSET.set_WatermarkColor(0, 0x0);
oPSET.set_WatermarkOpacity(0, 40);
oPSET.set_Watermark(1, true);
oPSET.set_WatermarkText(1, "Archived On :: " + DateTime.Now);
oPSET.set_WatermarkFirstPageOnly(1, false);
oPSET.set_WatermarkHPosition(1, prnWmarkHPosition.PRN_WMARK_HPOS_LEFT);
oPSET.set_WatermarkVPosition(1, prnWmarkVPosition.PRN_WMARK_VPOS_TOP);
oPSET.set_WatermarkZOrder(1, prnWmarkZOrder.PRN_WMARK_ZORDER_TOP);
oPSET.set_WatermarkTextAlignment(1, prnWmarkAlignment.PRN_WMARK_ALIGN_LEFT);
oPSET.set_WatermarkHOffset(1, 1);
oPSET.set_WatermarkVOffset(1, 0.5);
oPSET.set_WatermarkFontName(1, "Arial");
oPSET.set_WatermarkFontSize(1, 8);
oPSET.set_WatermarkAngle(1, 0);
oPSET.set_WatermarkOutlineOnly(1, false);
oPSET.set_WatermarkColor(1, 0x0);
oPSET.set_WatermarkOpacity(1, 100);
oPJOB.PrintOut(iFile, iFile + ".pdf");
res = iFile + ".pdf";
}
catch(PrinterException ex)
{
res = "ERROR : " + iFile + " : " + ex.Message;
res += @"\n" + " CRM : " + oPJOB.ConversionResultMessage;
res += @"\n" + " PRM : " + oPJOB.PrinterResultMessage;
}
finally
{
oPRIN.Dispose();
}
Since we are done with converting and processing PDF files, now we need to merge all of them together. The Merging Method is far simpler, because since we have the Array List of Files, easy PDF SDK has a Method basically built to do this right out of the box. Namely, MergeBatch.
PDFProcessor oPROC = new PDFProcessor();
try
{
oPROC.OptimizeAfterEachProcess = true;
oPROC.MergeBatch(iFiles, iDIR + "Output.pdf");
oPROC.Optimize(iDIR + "Output.pdf", iDIR + "Output.pdf", "");
res = "SUCCESS" + " :: Output File :: " + iDIR + "Output.pdf";
}
catch(PDFProcessorException ex)
{
res = "ERROR : " + ex.Message;
}
That is it! We did it. At the end of the process you will get a powerful application that can combine and convert multiple files to PDF and add additional information to it. Keep your project data safe and secure, accessible with a mouse click, and eliminate any anxiety of losing it.
Read more about our PDF SDK features on our website. Do not hesitate to check how it performs all PDF operations in a variety of programing languages. Download it now and start a free trial today.
DXA Converter is also a wonderful DXA File Converter that can convert DXA files to any audio formats like convert DXA to MP3, FLAC, M4A, AIFF, ALAC, AU, RA, AC3, ACC, WMA and more with fast speed.
ReplyDeletewww.anyconv.com
DXA Converter is also a wonderful DXA File Converter that can convert DXA files to any audio formats like convert DXA to MP3, FLAC, M4A, AIFF, ALAC, AU, RA, AC3, ACC, WMA and more with fast speed.
Deleteمیثم ابراهیمی
DXA Converter is also a wonderful DXA File Converter that can convert DXA files to any audio formats like convert DXA to MP3, FLAC, M4A, AIFF, ALAC, AU, RA, AC3, ACC, WMA and more with fast speed.
علی خدابنده
راغب
دانلود آهنگ جدید
ReplyDeleteدانلود آهنگ جدید
دانلود آهنگ جدید
پدرام پالیز دوست دارم
ReplyDelete
ReplyDeleteحجت اشرف زاده مهربان منی
ماکان بند دلمو دزدید
tnx
ReplyDeleteدانلود آهنگ
دانلود نوحه
آهنگ بی کلام
آموزش شرط بندی
ReplyDeleteسایت شرط بندی خارجی
سایت شرط بندی ایرانی
معرفی سایت شرط بندی بتکارت BetCart
معرفی سایت شرط بندی PinBahis
I recommend you use iDealshare VideoGo to convert DXA to MP4, WMV, 3GP, MPG, MOV, FLV, MKV, RMVB and etc.
ReplyDeleteبروز ترین اخبار ایران و جهان
ReplyDeleteExcellent and very exciting site. Love to watch. Keep Rocking. Judi Meja kasino
ReplyDeleteI've always thought of myself as a top gaypornmoviestube. Ever since I came out, I'd only hooked up with clean-shaven guys who were more pretty than butch. So, I didn't think anything about it when I first met Corey. We were both at the same club, and we saw each other from across the room. He nodded to me, and I nodded back. I slowly walked toward him, and we started dancing together. He grinded on me for a while and then turned around. I thought he wanted me to dance on him, so I went along with it. I didn't really know what I was doing, but he seemed to be getting into it. I could feel him getting more excited, so I turned my head back to kiss him. He grabbed my head and kissed back thefreegaysex.com. I don't remember how long it lasted, but the next thing I knew, he was pulling my hand to move off the dance floor.
ReplyDeletefuck u
DeleteWhat is hair transplant ? کاشت مو
ReplyDeleteچیست؟
What a great information u got there. Hope all this information can be usefull for everyone.
ReplyDeletehl8
دانلود آهنگ جدید
ReplyDeleteتیک موزیک
what a great information u got there. hope all this information can be usefull for everyone.
ReplyDeletemurniqq
سایت شرط بندی معتبر
ReplyDeleteبت فوروارد
رومابت
سایت هتریک
سایت دنیا جهانبخت
بت فا
سایت شرط بندی abt90 bet
پین باهیس
گیم کده انفجار
سایت تک بت
ReplyDeleteسایت بازی انفجار با درگاه مستقیم
پورتوبت
سایت شرط بندی 5000 تومان
نیلی افشار کیست
آموزش بازی تخته نرد
سایت شرط بندی لایو بت
سایت شرط بندی معتبر
ReplyDeleteبت فوروارد
رومابت
سایت هتریک
سایت دنیا جهانبخت
بت فا
سایت شرط بندی abt90 bet
پین باهیس
گیم کده انفجار
Ace90bet ثبت نام
ReplyDeletetakbet
تتل بت
جم بت 90
سایت پیش بینی فوتبال هافبک
جت بت 90
پارس 90
Thank you for the new information, quality, to understand more, is a good knowledge and is very useful. OGYOUTUBE Apk
ReplyDeleteسنگین بت
ReplyDeleteشارک بت
بت اسپات
تاک تیک بت
بت برو
سایت شرط بندی معتبر با درگاه بانکی
لاتی بت
ReplyDeleteکینگ بت
ولف بت
گاد بت
تاس وگاس
ادرس جدید سایت پین باهیس
ReplyDeleteیک بت
هیس بت
1xbet فارسی
لایو 90 بت
پین باهیس
ReplyDeleteسایت شرط بندی با درگاه بانکی
یک بت
سایت شرط بندی تک بت
شرط کده
ReplyDeleteولف بت
ReplyDeleteسایت حضرات
تک بت
تتل بت
shartwin
سایت شرط بندی با درگاه بانکی
ReplyDeleteسئو