public void CreatePdfFiles(PdfConverter pdfConverter, string htmlString) { string pdfWorkFilePath = System.Configuration.ConfigurationManager.AppSettings["pdfWorkFilePath"]; MergeEx merger = new MergeEx(); string existingpdf = pdfWorkFilePath + this.OutputFileName.ToString() + ".pdf"; string[] Files = System.IO.Directory.GetFiles(pdfWorkFilePath); int count = 0; string filename = this.OutputFileName.ToString() + ".pdf"; string finalfilename = this.OutputFileName.ToString() + "MergedDocs.pdf"; pdfConverter.SavePdfFromHtmlStringToFile(htmlString, pdfWorkFilePath + filename); merger.DestinationFile = pdfWorkFilePath + this.PartID.ToString() + "Merged.pdf"; merger.SourceFolder = pdfWorkFilePath + filename; if (this.NumofCopies > 0) { //save html for CC Card string htmlCC = htmlString; htmlCC = htmlString.Replace("<SPAN id=FRONTPAGEBEGIN></SPAN>", "<H2>CONTINUATION TRAVEL CARD for " + this.PartID + "</H2>"); htmlCC = htmlCC.Replace("<SPAN id=ccMessage></SPAN>", "<SPAN id=ccMessage> CONTINUATION CARD</SPAN>"); htmlCC = htmlCC.Replace("<SPAN id=ccMessage2></SPAN>", "<SPAN id=ccMessage> CONTINUATION CARD</SPAN>"); string ccfilename = this.OutputFileName.ToString() + "Continuation.pdf"; PdfConverter ccPdf = new PdfConverter(this.Width, this.Height); ccPdf.PdfDocumentOptions.PdfPageSize = Winnovative.WnvHtmlConvert.PdfPageSize.Letter; //NOTE: Users did not want the front page of the travel card to printing out on continuation card. I was able to blank out the content on the first page could not figure out to eliminate //the first page. It is probably possible and may be a good thing to refactor in the future. ccPdf.HtmlExcludedRegionsOptions.HtmlElementIds = new string[] { "CONTENTONFRONT", "BREAKFIRSTPAGE", "FRONTCONTENT" }; if (System.Configuration.ConfigurationManager.AppSettings["htmltopdf.licensekey"] != String.Empty) { ccPdf.LicenseKey = System.Configuration.ConfigurationManager.AppSettings["htmltopdf.licensekey"]; } ccPdf.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.NoCompression; ccPdf.PdfDocumentOptions.PdfPageOrientation = Winnovative.WnvHtmlConvert.PDFPageOrientation.Landscape; ccPdf.PdfDocumentOptions.ShowHeader = false; ccPdf.PdfDocumentOptions.ShowFooter = false; ccPdf.PdfDocumentOptions.InternalLinksEnabled = false; ccPdf.PdfDocumentOptions.JpegCompressionEnabled = false; ccPdf.PdfDocumentOptions.StretchToFit = true; ccPdf.OptimizeMemoryUsage = false; ccPdf.PdfDocumentOptions.LiveUrlsEnabled = true; ccPdf.PdfDocumentOptions.LeftMargin = 9; ccPdf.PdfDocumentOptions.RightMargin = 9; ccPdf.PdfDocumentOptions.TopMargin = 9; ccPdf.PdfDocumentOptions.BottomMargin = 9; ccPdf.SavePdfFromHtmlStringToFile(htmlCC, pdfWorkFilePath + ccfilename); merger.AddFile(pdfWorkFilePath + filename); int counter = 0; do { counter++; if (counter > 5) { //don't get stuck in a loop. //users agreed at 5 cards printed at a time would be enough 1/2012 break; } merger.AddFile(pdfWorkFilePath + ccfilename); } while (counter < this.NumofCopies + 1); } else { merger.AddFile(pdfWorkFilePath + filename); } if (this.DrawingFilePath != null || this.DrawingFilePath != String.Empty) { HandleDrawingFile(merger); } if (this.DeviationFile1Path != null || this.DeviationFile1Path != String.Empty) { HandleDeviation1File(merger); } if (this.DeviationFile2Path != null || this.DeviationFile2Path != String.Empty) { HandleDeviation2File(merger); } if (this.QualityAlert1File != null || this.QualityAlert1File != String.Empty) { HandleQualityAlert1File(merger); } if (this.QualityAlert2File != null || this.QualityAlert2File != String.Empty) { HandleQualityAlert2File(merger); } if (this.MachineSetUpFile != null || this.MachineSetUpFile != String.Empty) { HandleMachineSetUpFile(merger); } if (this.AdditionalFilePath != null || this.AdditionalFilePath != String.Empty) { HandleAdditionalFile(merger); } if (this.DieSetUpFilePath != null || this.DieSetUpFilePath != String.Empty) { HandleDieSetUpInstructions(merger); } count++; merger.Execute(); }