Wednesday, November 21, 2018

Archiving your project's files in PDF

    53

Archiving your projects files in PDF with easyPDF SDK

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.

Convert multiple files to PDF easy


Let’s suppose we want to build an app that does the following operations:

  1. Combine all files in different format inside the project folder together; 
  2. Convert those files to a single PDF file (that to be used as an archive); 
  3. Add date and time of the operation (conversion) at the top of each page, as a header; 
  4. Add a watermark (as an example: "Archive") on every page in the document. 
Let’s review how to do that with convert to PDF in-bulk application in C# with easy PDF SDK.

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.

53 comments:
Write comments
  1. 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.
    www.anyconv.com

    ReplyDelete
    Replies
    1. 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.

      میثم ابراهیمی
      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
  2. I recommend you use iDealshare VideoGo to convert DXA to MP4, WMV, 3GP, MPG, MOV, FLV, MKV, RMVB and etc.

    ReplyDelete
  3. Excellent and very exciting site. Love to watch. Keep Rocking. Judi Meja kasino

    ReplyDelete
  4. I'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.

    ReplyDelete
  5. What a great information u got there. Hope all this information can be usefull for everyone.
    hl8

    ReplyDelete
  6. what a great information u got there. hope all this information can be usefull for everyone.
    murniqq

    ReplyDelete
  7. Thank you for the new information, quality, to understand more, is a good knowledge and is very useful. OGYOUTUBE Apk

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Uses
    Buy Generic 100mg Viagra Online is using to treat male sexual capacity issues (ineptitude or ED). In mix with sexual incitement, vardenafil works by increasing blood flow to the penis to assist a man with getting and keep an erection. This doesn’t secure against sexually sent diseases. Practice “safe sex” like using latex condoms. Advise your care or PCP for more.
    Viagra Online
    Buy Viagra Online

    ReplyDelete
  10. How to use Sildenafil Viagra
    Read the Patient Data Leaflet given by your PCP before you begin taking vardenafil, and each time you get a top off. On the off chance that you have any inquiries, ask your PCP or drug specialist. Take this by mouth as by your PCP, usually depending on the situation. Take it with or without food, around 1 hour before sexual activity. Try not to take more than once every day. Dosages ought to be required in any event 24 hours separated. It depends on your ailment, reaction to treatment, and others you might be taking. Ensure to your care and PCP regarding every one of the items you use (medications, and homegrown items).
    Buy generic 100mg Viagra Online
    Viagra for sale

    ReplyDelete
  11. Buy Generic 100mg Viagra Online is using to treat male sexual capacity issues (ineptitude or ED). In mix with sexual incitement, vardenafil works by increasing blood flow to the penis to assist a man with getting and keep an erection. This doesn’t secure against sexually sent diseases. Practice “safe sex” like using latex condoms. Advise your care or PCP for more.

    How to use Sildenafil Viagra
    Read the Patient Data Leaflet given by your PCP before you begin taking vardenafil, and each time you get a top off. On the off chance that you have any inquiries, ask your PCP or drug specialist.
    Online Viagra
    generic Viagra Online

    ReplyDelete

  12. How to use Sildenafil Viagra
    Read the Patient Data Leaflet given by your PCP before you begin taking vardenafil, and each time you get a top off. On the off chance that you have any inquiries, ask your PCP or drug specialist. Take this by mouth as by your PCP, usually depending on the situation. Take it with or without food, around 1 hour before sexual activity. Try not to take more than once every day. Dosages ought to be required in any event 24 hours separated. It depends on your ailment, reaction to treatment, and others you might be taking. Ensure to your care and PCP regarding every one of the items you use (medications, and homegrown items).

    Side Effects of Buy Generic 100mg Viagra
    Canadian Pharmacy Viagra
    Canadian Viagra

    ReplyDelete
  13. I am very thankful for such a wonderful blog. It's very interesting to read and easy to understand. Thanks for sharing. I will visit your blog daily because I know. It may be very beneficial for me. If you want to Fix QuickBooks Bank Error 163 please contact our team for instant help.

    ReplyDelete
  14. Rb88 Casino - Best Bonus for UK Players
    Rb88 Casino. The クイーンカジノ best Rb88 Casino in the UK is a fantastic online casino where players 코인카지노 can bet on live games rb88 including video poker, sports betting and much more.

    ReplyDelete
  15. Comedy plays have been around for a long time and have a long and storied history behind them in the theatre – so long, in fact, that I might forget to mention some of the more important details about their history in this little blurb. Don't worry; I'll be sure to cover them at the presentation. You should visit my website for more tinyqube

    ReplyDelete
  16. สล็อตโจ๊กเกอร์ สล็อตออนไลน์ joker อันดับ 1 วันนี้จะมาแนะนำเกมส์ สล็อต ยอดนิยมอันดับ 1 จากค่าย Joker
    เกมสล็อตออนไลน์ ที่ได้มาตรฐานมีความนิยมเล่นมากที่สุด สามารเล่นได้หรือสามารถ ทดลองเล่นสล็อต ได้ฟรีทุกเกม

    ReplyDelete
  17. superslot เว็บไซต์เดิมพัน สล็อตออนไลน์ สายเกมสล็อตไม่ควรพลาด ทดลองเล่นสล็อต
    ลงทุนกับเกมสล็อต หลักการทำเงินที่ทำให้แก่ผู้เล่นมามากมายนักต่อนัก ไม่ว่าจะเป็นลงทุนน้อยหรือลงทุนมากก็ได้กำไรกลับคืนมากันยังนับไม่ถ้วน สมัครซุปเปอร์สล็อต

    ReplyDelete
  18. SUPERSLOT GAME PROMOTION SIGN UP TODAY AND GET A 10% BONUS ON EVERY DEPOSIT superslot Free Slot Games on Mobile ทดลองเล่นสล็อต PG Slot, Joker Game, Spade Gaming, Game Hall slot, SlotXO, EVOPLAY, AmbPoker, Jili. ทางเข้า superslot

    ReplyDelete
  19. We have brought the best, most advanced and fastest SUPERSLOT AUTO system for our customers to be fully satisfied. superslot There are slots from every game camp. ทดลองเล่นสล็อต PG SLOT , EVOPLAY , SLOT XO , PRAGMATIC PLAY , JILI GAME , RELAX GAMING , DAFABET , JOKER ทางเข้า superslot

    ReplyDelete
  20. Joker Gaming Slot Joker Slot The best of the mobile slot game industry or online slots joker Slots Update 2022 slot All members can easily access the Joker camp slots. ทางเข้า joker

    ReplyDelete
  21. I really need such information like this. thank you for this. www.vihvac.com/

    ReplyDelete
  22. Grerem is a general site in which you see top news, fashion tips, technology, and popular videos.

    ReplyDelete
  23. Nice Post. I have been reading here for about an hour. I am a newbie and your success is very much an inspiration for me. If you want to Fix Recover Forgot Spectrum Password please contact our team for instant help.

    ReplyDelete

© 1993 - , BCL Technologies. All other trademarks are the property of their respective owners. Privacy Policy