I am working with the python code file shipped with Masshunter 12.1 entitled "CC_Avg.py". It is referenced by the xml document called "Env_CC_Avg.report.xml".
I am trying to get it to show peak resolution on the report as one of the requirements of EPA 8270E Semivolatiles analysis. The problem is that in the following code example, the cmpd.ResolutionFront attribute does not exist. I believe this is because it is bound to the compound information rather than the peak information.
How can I reference or extract the target peak information so that I can use the ResolutionFront attributes?
I tried to use something like the following without success:
peak = None if compound.IsPrimaryHitPeakIDNull() else DataProvider.GetPeak(istd.BatchID, istd.SampleID, cmpd.CompoundID, cmpd.PrimaryHitPeakID)
ResolutionValue = peak.ResolutionFront
I have also attached the python file itself as a .txt file, starting at line 292.
#CC_Avg.py, Aera% is calcuated against avg resp of the calibrators # #import os import System import System.IO import clr clr.AddReference("iTextSharp") import iTextSharp import iTextSharp.text import iTextSharp.text.pdf from iTextSharp.text import * from iTextSharp.text.pdf import * #----------------------------------------------------------------------------- # PageEvent #----------------------------------------------------------------------------- class PageEvent (PageEventBase): def __init__(self,font): PageEventBase.__init__(self,font) def GetTitle(self, writer): return resmgr.GetString("Title") def GetFooterCenterText(self, writer): format = resmgr.GetString("PageOf") return System.String.Format(format, writer.PageNumber) def GetFooterRightText(self, writer): format = resmgr.GetString("GeneratedAtOn") return System.String.Format(format, self.now.ToString("t"), self.now.ToString("d")) #----------------------------------------------------------------------------- # mid levels #----------------------------------------------------------------------------- def Mid(): ccExpC,avg,mid= ({} for i in range(3)) samples = DataProvider.SelectSamples("","AcqDateTime") if 0 < len(samples): sample = samples[-1] if not sample.IsCalibrationReferenceSampleIDNull(): sample = DataProvider.GetSample(sample.BatchID, sample.CalibrationReferenceSampleID) targets = DataProvider.SelectCompounds( System.String.Format( System.Globalization.CultureInfo.InvariantCulture, "BatchID={0} AND SampleID={1} AND Not ISTDFlag=True", sample.BatchID, sample.SampleID), "RetentionTime") CCsample = DataProvider.SelectSamples("SampleType='CC'","AcqDateTime")[0] for compound in DataProvider.SelectCompounds(System.String.Format( System.Globalization.CultureInfo.InvariantCulture, "BatchID={0} AND SampleID={1} AND Not ISTDFlag=True", CCsample.BatchID, CCsample.SampleID), "RetentionTime"): ccExpC[compound.CompoundName] = 0 if compound.IsExpectedConcentrationNull() else compound.ExpectedConcentration for t in targets: levelName, diffC, levelRes, ilevelRes = ([] for i in range(4)) ccExp = ccExpC.get(t.CompoundName, 0) istd = None if t.IsISTDCompoundIDNull() else DataProvider.GetCompound(sample.BatchID, sample.SampleID, t.ISTDCompoundID) for calibration in DataProvider.SelectCalibrations( System.String.Format( System.Globalization.CultureInfo.InvariantCulture, "BatchID={0} AND SampleID={1} AND CompoundID={2} AND CalibrationType='Calibration'", t.BatchID, t.SampleID, t.CompoundID), "LevelConcentration"): levelName += calibration.LevelName, levelRes += 0 if calibration.IsLevelResponseNull() else calibration.LevelResponse, diffC += abs(calibration.LevelConcentration - ccExp), n = diffC.index(min(diffC)) lName = levelName[n] avg[t.CompoundName] = sum(levelRes)/len(levelRes) mid[t.CompoundName] = levelRes[n] if istd is not None: for cal in DataProvider.SelectCalibrations( System.String.Format( System.Globalization.CultureInfo.InvariantCulture, "BatchID={0} AND SampleID={1} AND CompoundID={2} AND CalibrationType='Calibration'", istd.BatchID, istd.SampleID, istd.CompoundID), ""): ilevelRes += 0 if cal.IsLevelResponseNull() else cal.LevelResponse, if cal.LevelName==""+lName+"": mid[istd.CompoundName] = 0 if cal.IsLevelResponseNull() else cal.LevelResponse avg[istd.CompoundName] = 0 if len(ilevelRes)==0 else sum(ilevelRes)/len(ilevelRes) return avg, mid, ccExpC #----------------------------------------------------------------------------- # count cal levels #----------------------------------------------------------------------------- def CountCalLevels(compound): pathName,acqTime,levelName,CCFiles,CCAcqTime,CCLevel = ([] for i in range(6)) for calibration in DataProvider.SelectCalibrations( System.String.Format( System.Globalization.CultureInfo.InvariantCulture, "BatchID={0} AND SampleID={1} AND CompoundID={2} AND Not CalibrationType='Method'", compound.BatchID, compound.SampleID, compound.CompoundID), "LevelConcentration"): if calibration.CalibrationType == "CC": CCFiles += "" if calibration.IsCalibrationSTDPathNameNull() else calibration.CalibrationSTDPathName, CCAcqTime += "" if calibration.IsCalibrationSTDAcquisitionDateTimeNull() else calibration.CalibrationSTDAcquisitionDateTime, CCLevel += "" if calibration.IsLevelNameNull() else calibration.LevelName, if calibration.CalibrationType == "Calibration": pathName += "" if calibration.IsCalibrationSTDPathNameNull() else calibration.CalibrationSTDPathName, acqTime += "" if calibration.IsCalibrationSTDAcquisitionDateTimeNull() else calibration.CalibrationSTDAcquisitionDateTime, levelName += "" if calibration.IsLevelNameNull() else calibration.LevelName, return levelName,pathName,acqTime,CCFiles,CCAcqTime,CCLevel #----------------------------------------------------------------------------- # count max cal levels #----------------------------------------------------------------------------- def CountMaxCalLevels(sample): pathName,acqTime,levelName,CCFiles,CCAcqTime,CCLevel,levelList = ([] for i in range(7)) compounds = DataProvider.SelectCompounds( System.String.Format( System.Globalization.CultureInfo.InvariantCulture, "BatchID={0} AND SampleID={1}", sample.BatchID, sample.SampleID), "RetentionTime") for compound in compounds: levelName,pathName,acqTime,CCFiles,CCAcqTime,CCLevel = CountCalLevels(compound) levelList += len(levelName), cmpd = compounds[levelList.index(max(levelList))] levelName,pathName,acqTime,CCFiles,CCAcqTime,CCLevel = CountCalLevels(cmpd) return levelName,pathName,acqTime,CCFiles,CCAcqTime,CCLevel #----------------------------------------------------------------------------- # cal Info #----------------------------------------------------------------------------- def BatchInfo(sample): arr = System.Array[System.Single]([1.1,6]) table = PdfPTable(arr) table.WidthPercentage = 100 table.DefaultCell.Border = 0 table.HorizontalAlignment = Element.ALIGN_LEFT table.SpacingAfter = 8 table.AddCell(Phrase(resmgr.GetString("BatchName"), fontBold)) table.AddCell(Phrase(DataProvider.BatchAttributes.BatchDataPathFileName, font)) table.AddCell(Phrase(resmgr.GetString("MethodFile"), fontBold)) table.AddCell(Phrase("" if sample.IsDAMethodFileNameNull() else sample.DAMethodPathName + "\\"+ sample.DAMethodFileName, font)) table.AddCell(Phrase(resmgr.GetString("DailyCC"), fontBold)) table.AddCell(Phrase(sample.DataPathName.ToString()+"\\"+sample.DataFileName.ToString(), font)) document.Add(table) def ProcessSamples(): samples = DataProvider.SelectSamples("","AcqDateTime") if 0 < len(samples): sample = samples[-1] if not sample.IsCalibrationReferenceSampleIDNull(): sample = DataProvider.GetSample(sample.BatchID, sample.CalibrationReferenceSampleID) levelName,pathName,acqTime,CCFiles,CCAcqTime,CCLevel = CountMaxCalLevels(sample) CCsamples = DataProvider.SelectSamples("SampleType='CC'","AcqDateTime") if len(CCsamples)==0 or len(CCFiles) ==0: document.Add(Paragraph(resmgr.GetString("NoCC2"),fontBold)) else: CCsample = CCsamples[0] BatchInfo(CCsample) ## cal files section: arr = System.Array[System.Single]([1,1.3,4.7]) table1 = PdfPTable(arr) table1.WidthPercentage = 100 table1.DefaultCell.Border = 0 table1.HorizontalAlignment = Element.ALIGN_LEFT table1.SpacingAfter = 10 table1.AddCell(Phrase(resmgr.GetString("LevelName"), fontBold)) table1.AddCell(Phrase(resmgr.GetString("InjectionTime"), fontBold)) table1.AddCell(Phrase(resmgr.GetString("CalFile"), fontBold)) for i in range(len(levelName)): table1.AddCell(Phrase(levelName[i].ToString(), font)) table1.AddCell(Phrase(acqTime[i].ToString(), font)) table1.AddCell(Phrase(pathName[i], font)) if len(CCFiles)>0: table1.AddCell(Phrase(CCLevel[0].ToString(), font)) table1.AddCell(Phrase(CCAcqTime[0].ToString(), font)) #table1.AddCell(Phrase(CCFiles[0]+" <======", font)) table1.AddCell(Phrase(CCFiles[0], font)) document.Add(table1) avg, mid, ccExpC = Mid() targets = DataProvider.SelectCompounds( System.String.Format( System.Globalization.CultureInfo.InvariantCulture, "BatchID={0} AND SampleID={1} AND Not ISTDFlag=True", sample.BatchID, sample.SampleID), "RetentionTime") istdIDs, istds, ntargets, t = ([] for i in range(4)) for c in targets: if c.IsISTDCompoundIDNull(): ntargets += c, else: istdIDs += c.ISTDCompoundID, t += c, if istdIDs: istdIDs = sorted(set(istdIDs)) for i in istdIDs: istd = DataProvider.GetCompound(sample.BatchID, sample.SampleID, i) istds += istd, CCComps = DataProvider.GetAllCompounds(CCsample.BatchID, CCsample.SampleID) CCRespD,CCConcD,CCExpConcD,CCAccuracyD,CCAvgRF = ({} for i in range(5)) for CC in CCComps: CCPeak = None if CC.IsPrimaryHitPeakIDNull() else DataProvider.GetPeak( CC.BatchID, CC.SampleID, CC.CompoundID, CC.PrimaryHitPeakID) CCRespD[CC.CompoundName] = 0 if CCPeak is None or CCPeak.IsTargetResponseNull() else CCPeak.TargetResponse CCConcD[CC.CompoundName] = 0 if CCPeak is None or CCPeak.IsFinalConcentrationNull() else CCPeak.FinalConcentration CCAccuracyD[CC.CompoundName] = 0 if CCPeak is None or CCPeak.IsAccuracyNull() else CCPeak.Accuracy CCExpConcD[CC.CompoundName] = 0 if CC.IsExpectedConcentrationNull() else CC.ExpectedConcentration CCAvgRF[CC.CompoundName] = 0 if CC.IsAverageResponseFactorNull() else CC.AverageResponseFactor ## istd section: if istds: arr = System.Array[System.Single]([3,1,1,1,1,1]) table2 = PdfPTable(arr) table2.WidthPercentage = 100 table2.DefaultCell.Border = 0 table2.HorizontalAlignment = Element.ALIGN_LEFT table2.SpacingAfter = 10 table2.AddCell(Phrase(resmgr.GetString("ISTDCompound"), fontBold)) table2.AddCell(Phrase(resmgr.GetString("AvgResp"), fontBold)) table2.AddCell(Phrase(resmgr.GetString("MidResp"), fontBold)) table2.AddCell(Phrase(resmgr.GetString("CCResp"), fontBold)) table2.AddCell(Phrase(resmgr.GetString("Area%"), fontBold)) table2.AddCell(Phrase("A/M", fontBold)) for istd in istds: iavg = avg.get(istd.CompoundName, 0) imid = mid.get(istd.CompoundName, 0) area_A = 0 if iavg==0 else 100*CCRespD[istd.CompoundName]/imid table2.AddCell(Phrase("" if istd is None or istd.IsCompoundNameNull() else istd.CompoundName, font)) table2.AddCell(Phrase("" if iavg==0 else iavg.ToString("F0"),font)) table2.AddCell(Phrase(imid.ToString("F0"), font)) table2.AddCell(Phrase(CCRespD[istd.CompoundName].ToString("F0"), font)) if not istd.IsISTDResponseMinimumPercentDeviationNull() and CCRespD[istd.CompoundName] < imid*(istd.ISTDResponseMinimumPercentDeviation+100)/100: table2.AddCell(Phrase("" if area_A == 0 else area_A.ToString("F2")+" #", fontRed)) elif not istd.IsISTDResponseMaximumPercentDeviationNull() and CCRespD[istd.CompoundName] > imid*(istd.ISTDResponseMaximumPercentDeviation+100)/100: table2.AddCell(Phrase("" if area_A == 0 else area_A.ToString("F2")+" #", fontRed)) else: table2.AddCell(Phrase("" if area_A == 0 else area_A.ToString("F2"), font)) table2.AddCell(Phrase("M", font)) document.Add(table2) # Target section: arr = System.Array[System.Single]([2.5,0.9,0.9,1,0.9,0.9,0.9,1,0.8,1.2]) table3 = PdfPTable(arr) table3.WidthPercentage = 100 table3.DefaultCell.Border = 0 table3.HorizontalAlignment = Element.ALIGN_LEFT table3.SpacingAfter = 10 table3.HeaderRows = 1 table3.AddCell(Phrase(resmgr.GetString("TargetCompound"), fontBold)) table3.AddCell(Phrase("Type", fontBold)) table3.AddCell(Phrase("Resolution", fontBold)) table3.AddCell(Phrase(resmgr.GetString("AvgRF/R2"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("CCRF"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("ExpConc"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("CalcConc"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("%Dev"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("Area%"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("CurveFit"), fontBold)) for istd in istds: table3.AddCell(Phrase("" if istd is None or istd.IsCompoundNameNull() else istd.CompoundName, font)) cell = PdfPCell(Phrase("------------------------------------ISTD----------------------------------------",font)) cell.Colspan = 9 cell.Border = 0 table3.AddCell(cell) for cmpd in t: if istd.CompoundID == cmpd.ISTDCompoundID: rf = CCRespD[cmpd.CompoundName]*cmpd.ISTDConcentration/(CCRespD[istd.CompoundName]*CCExpConcD[cmpd.CompoundName]) rfDev = 0 if CCAvgRF[cmpd.CompoundName] is None else 100*(CCAvgRF[cmpd.CompoundName]-rf)/CCAvgRF[cmpd.CompoundName] table3.AddCell(Phrase("" if cmpd.IsCompoundNameNull() else cmpd.CompoundName,font)) #I added this code to add compound types for 8270C. Working fine try: if "CCC" in cmpd.CompoundGroup: table3.AddCell(Phrase("CCC", font)) elif "Performance Check" in cmpd.CompoundGroup: table3.AddCell(Phrase("P", font)) else: table3.AddCell(Phrase("")) except: table3.AddCell(Phrase("")) # # # # ##Code that runs but doesn't give me the information I need, just placeholder values ResolutionValue = "-" try: if cmpd.ResolutionLimit is not None: ResolutionValue = "ResolutionFront" except: pass try: if cmpd.ResolutionLimit is not None: ResolutionValue = "ResolutionRear" except: pass table3.AddCell(Phrase(ResolutionValue, font)) ##Code I would like to work if cmpd had the ResolutionFront and Rear attributes #ResolutionValue = "-" #try: # if cmpd.ResolutionFront is not None and cmpd.ResolutionFront > 0: # ResolutionValue = cmpd.ResolutionFront #except: # pass #try: # if cmpd.ResolutionRear is not None and cmpd.ResolutionRear > 0: # ResolutionValue = cmpd.ResolutionRear #except: # pass #table3.AddCell(Phrase(ResolutionValue, font)) # # # # if cmpd.CurveFit == 'fitAverageOfResponseFactors': table3.AddCell(Phrase("" if CCAvgRF[cmpd.CompoundName] is None else CCAvgRF[cmpd.CompoundName].ToString("F3"), font)) if not CC.IsMinimumCCRelativeResponseFactorNull() and CC.MinimumCCRelativeResponseFactor > rf: table3.AddCell(Phrase(rf.ToString("F3")+" #", fontBlue)) else: table3.AddCell(Phrase(rf.ToString("F3"), font)) table3.AddCell(Phrase("" if CCExpConcD[cmpd.CompoundName]==0 else CCExpConcD[cmpd.CompoundName].ToString("F2"), font)) if cmpd.IsCalibrationReferenceCompoundIDNull(): table3.AddCell(Phrase("" if CCConcD[cmpd.CompoundName]==0 else CCConcD[cmpd.CompoundName].ToString("F2"),font)) else: table3.DefaultCell.BackgroundColor = BaseColor(221,221,221) table3.AddCell(Phrase("" if CCConcD[cmpd.CompoundName]==0 else CCConcD[cmpd.CompoundName].ToString("F2"),font)) table3.DefaultCell.BackgroundColor = BaseColor(255,255,255) if not cmpd.IsMaximumCCResponseFactorDeviationNull() and CCAvgRF[cmpd.CompoundName] is not None and cmpd.MaximumCCResponseFactorDeviation< abs(rfDev): table3.AddCell(Phrase("" if rfDev == 0 else rfDev.ToString("F2")+" #",fontRed)) else: table3.AddCell(Phrase("" if rfDev == 0 else rfDev.ToString("F2"),font)) else: table3.AddCell(Phrase("" if cmpd.IsCurveFitR2Null() else cmpd.CurveFitR2.ToString("F4"), fontBlue)) table3.AddCell(Phrase(rf.ToString("F4") if rf<100 else rf.ToString("F0"), font)) table3.AddCell(Phrase("" if CCExpConcD[cmpd.CompoundName]==0 else CCExpConcD[cmpd.CompoundName].ToString("F2"), font)) if cmpd.IsCalibrationReferenceCompoundIDNull(): table3.AddCell(Phrase("" if CCConcD[cmpd.CompoundName]==0 else CCConcD[cmpd.CompoundName].ToString("F2"),font)) else: table3.DefaultCell.BackgroundColor = BaseColor(221,221,221) table3.AddCell(Phrase("" if CCConcD[cmpd.CompoundName]==0 else CCConcD[cmpd.CompoundName].ToString("F2"),font)) table3.DefaultCell.BackgroundColor = BaseColor(255,255,255) AcuracyDev = 100-CCAccuracyD[cmpd.CompoundName] if not cmpd.IsAccuracyMaximumPercentDeviationNull() and cmpd.AccuracyMaximumPercentDeviation< abs(AcuracyDev): table3.AddCell(Phrase(AcuracyDev.ToString("F2")+" #", fontRed)) else: table3.AddCell(Phrase(AcuracyDev.ToString("F2"), font)) if (100*CCRespD[cmpd.CompoundName]/mid[cmpd.CompoundName]) > 50 and (100*CCRespD[cmpd.CompoundName]/mid[cmpd.CompoundName]) < 200: table3.AddCell(Phrase((100*CCRespD[cmpd.CompoundName]/mid[cmpd.CompoundName]).ToString("F2"),font)) else: table3.AddCell(Phrase((100*CCRespD[cmpd.CompoundName]/mid[cmpd.CompoundName]).ToString("F2"),fontRed)) cf = DataProvider.TranslateEnumValue("TargetCompound","CurveFit",cmpd["CurveFit"]) #table3.AddCell(Phrase("" if cmpd.IsCurveFitNull() else "Avg RF" if cf=="Average of Response Factors" else cf,font)) if cmpd.IsCurveFitNull(): table3.AddCell(Phrase("",font)) elif cf=="Average of Response Factors": table3.AddCell(Phrase("Avg RF",font)) else: table3.AddCell(Phrase(cf,fontBlue)) document.Add(table3) document.Add(Paragraph(resmgr.GetString("Note"), fontBold)) ##for non-ISTD batch: if ntargets: arr = System.Array[System.Single]([3,1,0.9,0.9,0.9,1,0.8,1.2]) table3 = PdfPTable(arr) table3.WidthPercentage = 100 table3.DefaultCell.Border = 0 table3.HorizontalAlignment = Element.ALIGN_LEFT table3.SpacingAfter = 10 table3.SpacingBefore = 10 table3.HeaderRows = 1 table3.AddCell(Phrase(resmgr.GetString("TargetCompound"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("AvgRF/R2"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("CCRF"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("ExpConc"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("CalcConc"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("%Dev"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("Area%"), fontBold)) table3.AddCell(Phrase(resmgr.GetString("CurveFit"), fontBold)) for cmpd in ntargets: rf = CCRespD[cmpd.CompoundName]/CCExpConcD[cmpd.CompoundName] rfDev = 0 if CCAvgRF[cmpd.CompoundName] is None else 100*(CCAvgRF[cmpd.CompoundName]-rf)/CCAvgRF[cmpd.CompoundName] table3.AddCell(Phrase("" if cmpd.IsCompoundNameNull() else cmpd.CompoundName,font)) if cmpd.CurveFit == 'fitAverageOfResponseFactors': table3.AddCell(Phrase("" if CCAvgRF[cmpd.CompoundName] is None else CCAvgRF[cmpd.CompoundName].ToString("F4"), font)) if not CC.IsMinimumCCRelativeResponseFactorNull() and CC.MinimumCCRelativeResponseFactor > rf: table3.AddCell(Phrase((rf.ToString("F4") if rf<100 else rf.ToString("F0"))+" #", fontBlue)) else: table3.AddCell(Phrase(rf.ToString("F4") if rf<100 else rf.ToString("F0"), font)) table3.AddCell(Phrase("" if CCExpConcD[cmpd.CompoundName]==0 else CCExpConcD[cmpd.CompoundName].ToString("F2"), font)) if cmpd.IsCalibrationReferenceCompoundIDNull(): table3.AddCell(Phrase("" if CCConcD[cmpd.CompoundName]==0 else CCConcD[cmpd.CompoundName].ToString("F2"),font)) else: table3.DefaultCell.BackgroundColor = BaseColor(221,221,221) table3.AddCell(Phrase("" if CCConcD[cmpd.CompoundName]==0 else CCConcD[cmpd.CompoundName].ToString("F2"),font)) table3.DefaultCell.BackgroundColor = BaseColor(255,255,255) if not cmpd.IsMaximumCCResponseFactorDeviationNull() and CCAvgRF[cmpd.CompoundName] is not None and cmpd.MaximumCCResponseFactorDeviation< abs(rfDev): table3.AddCell(Phrase("" if rfDev == 0 else rfDev.ToString("F2")+" #",fontRed)) else: table3.AddCell(Phrase("" if rfDev == 0 else rfDev.ToString("F2"),font)) else: table3.AddCell(Phrase("" if cmpd.IsCurveFitR2Null() else cmpd.CurveFitR2.ToString("F4"), font)) table3.AddCell(Phrase(rf.ToString("F4") if rf<100 else rf.ToString("F0"), font)) table3.AddCell(Phrase("" if CCExpConcD[cmpd.CompoundName]==0 else CCExpConcD[cmpd.CompoundName].ToString("F2"), font)) if cmpd.IsCalibrationReferenceCompoundIDNull(): table3.AddCell(Phrase("" if CCConcD[cmpd.CompoundName]==0 else CCConcD[cmpd.CompoundName].ToString("F2"),font)) else: table3.DefaultCell.BackgroundColor = BaseColor(221,221,221) table3.AddCell(Phrase("" if CCConcD[cmpd.CompoundName]==0 else CCConcD[cmpd.CompoundName].ToString("F2"),font)) table3.DefaultCell.BackgroundColor = BaseColor(255,255,255) AcuracyDev = 100-CCAccuracyD[cmpd.CompoundName] if not cmpd.IsAccuracyMaximumPercentDeviationNull() and cmpd.AccuracyMaximumPercentDeviation< abs(AcuracyDev): table3.AddCell(Phrase(AcuracyDev.ToString("F2")+" #", fontRed)) else: table3.AddCell(Phrase(AcuracyDev.ToString("F2"), font)) table3.AddCell(Phrase((100*CCRespD[cmpd.CompoundName]/avg[cmpd.CompoundName]).ToString("F2"),font)) cf = DataProvider.TranslateEnumValue("TargetCompound","CurveFit",cmpd["CurveFit"]) table3.AddCell(Phrase("" if cmpd.IsCurveFitNull() else "Avg RF" if cf=="Average of Response Factors" else cf,font)) document.Add(table3) document.Add(Paragraph(resmgr.GetString("Note"), fontBold)) #----------------------------------------------------------------------------- # AddCell #----------------------------------------------------------------------------- def AddCell(table, phrase, align): cell = PdfPCell(phrase) cell.HorizontalAlignment = align cell.Border = table.DefaultCell.Border table.AddCell(cell) #----------------------------------------------------------------------------- # Font #----------------------------------------------------------------------------- fontname = GetDefaultFontNameByCulture(System.Globalization.CultureInfo.CurrentCulture) RegisterFont(fontname) defaultFont = FontFactory.GetFont(fontname, BaseFont.IDENTITY_H) fontBold = Font(defaultFont.BaseFont, 9, Font.BOLD) font = Font(defaultFont.BaseFont, 9) fontRed = Font(defaultFont.BaseFont, 9, Font.NORMAL, BaseColor.RED) fontBlue = Font(defaultFont.BaseFont, 9, Font.NORMAL, BaseColor.BLUE) #---------------------------------------------------------------------------- # Resource manager #----------------------------------------------------------------------------- # load resource assembly resasm = System.Reflection.Assembly.LoadFrom(ResourceAssemblyPath) # create resource manager resmgr = System.Resources.ResourceManager("CCal", resasm) #----------------------------------------------------------------------------- # Main #----------------------------------------------------------------------------- DataProvider.CheckAbortSignal() stream = System.IO.FileStream(OutputFilePath, System.IO.FileMode.Create, System.IO.FileAccess.ReadWrite) document = Document() writer = PdfWriter.GetInstance(document, stream) pageEvent = PageEvent(defaultFont) writer.PageEvent = pageEvent document.SetPageSize(PreferredPageSize) document.SetMargins(25,25,30,30) document.Open() ProcessSamples() pageEvent.ProcessTotalNumberOfPages(writer) document.Dispose() writer.Dispose()