コード例 #1
0
        /// <summary>
        /// adds the header and footer details to the given pathTotempPdf, and creates the offical pdf location.
        /// </summary>
        public void AddHeaderAndFooter(string pathToTempPdfFile)
        {
            PdfFileStamp fileStamp = null;
            try
            {
                fileStamp = new PdfFileStamp();
                fileStamp.BindPdf(pathToTempPdfFile);
                FormattedText ftSubjectID = null;
                FormattedText ftMedrioID = null;
                System.Drawing.Color fontColor = System.Drawing.Color.Black;

                if (CustomSubjectID)
                {
                    ftSubjectID = new FormattedText(string.Format("Subject Identifier: {0}", SubjectIdentifier)
                                                    , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                }

                if (IsMedrioIDShown)
                {
                    ftMedrioID = new FormattedText(string.Format("Medrio ID: {0}", Subject.FormatMedrioSubjectID(MedrioSubjectID))
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                }

                FormattedText ftSite = new FormattedText(HeaderItemText("Site: ", SiteName, HEADER_LABELWIDTH)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftVisit = new FormattedText(HeaderItemText(Study.VisitLabelSingular + ": ", VisitName, HEADER_LABELWIDTH)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftGroup = new FormattedText(HeaderItemText("Group: ", GroupName, HEADER_LABELWIDTH)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftForm = new FormattedText(HeaderItemText("Form: ", FormName, HEADER_LABELWIDTH)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftStudy = new FormattedText(string.Format("{0}", StudyTitle)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);

                //add header
                int medrioIdTopMargin = 20;
                if (null != ftSubjectID)
                {
                    fileStamp.AddHeader(ftSubjectID, 20, 25, 0);
                    medrioIdTopMargin = 30;
                }
                if (null != ftMedrioID)
                {
                    fileStamp.AddHeader(ftMedrioID, medrioIdTopMargin, 25, 0);
                }
                fileStamp.AddHeader(ftSite, 20, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddHeader(ftVisit, 30, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddHeader(ftGroup, 20, 0, 50);
                fileStamp.AddHeader(ftForm, 30, 0, 50);

                TimeZoneInfo tzi = null;
                try
                {
                    tzi = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneFormatForCurrentUser);
                }
                catch
                {
                    tzi = TimeZoneInfo.Local;
                }

                DateTime dt = TimeZoneInfo.ConvertTime(DateTime.UtcNow, tzi);

                FormattedText ftDatetime = new FormattedText(string.Format("{0} {1:HH:mm} ({2})", dt.ToString(ExportDateFormat), dt, TimeZoneFormatForCurrentUser)
                        , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);

                // add footer
                fileStamp.AddFooter(ftStudy, 20, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddFooter(ftDatetime, 20, 25, 0);
                fileStamp.Save(PathToPdf);
            }
            finally
            {
                if (fileStamp != null)
                {
                    //close
                    fileStamp.Dispose();
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// adds the header and footer details to the given pathTotempPdf, and creates the offical pdf location.
        /// </summary>
        public void AddHeaderAndFooter(string pathToTempPdfFile)
        {
            PdfFileStamp fileStamp = null;

            try
            {
                fileStamp = new PdfFileStamp();
                fileStamp.BindPdf(pathToTempPdfFile);
                FormattedText        ftSubjectID = null;
                FormattedText        ftMedrioID  = null;
                System.Drawing.Color fontColor   = System.Drawing.Color.Black;

                if (CustomSubjectID)
                {
                    ftSubjectID = new FormattedText(string.Format("Subject Identifier: {0}", SubjectIdentifier)
                                                    , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                }

                if (IsMedrioIDShown)
                {
                    ftMedrioID = new FormattedText(string.Format("Medrio ID: {0}", Subject.FormatMedrioSubjectID(MedrioSubjectID))
                                                   , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                }

                FormattedText ftSite = new FormattedText(HeaderItemText("Site: ", SiteName, HEADER_LABELWIDTH)
                                                         , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftVisit = new FormattedText(HeaderItemText(Study.VisitLabelSingular + ": ", VisitName, HEADER_LABELWIDTH)
                                                          , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftGroup = new FormattedText(HeaderItemText("Group: ", GroupName, HEADER_LABELWIDTH)
                                                          , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftForm = new FormattedText(HeaderItemText("Form: ", FormName, HEADER_LABELWIDTH)
                                                         , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);
                FormattedText ftStudy = new FormattedText(string.Format("{0}", StudyTitle)
                                                          , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);

                //add header
                int medrioIdTopMargin = 20;
                if (null != ftSubjectID)
                {
                    fileStamp.AddHeader(ftSubjectID, 20, 25, 0);
                    medrioIdTopMargin = 30;
                }
                if (null != ftMedrioID)
                {
                    fileStamp.AddHeader(ftMedrioID, medrioIdTopMargin, 25, 0);
                }
                fileStamp.AddHeader(ftSite, 20, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddHeader(ftVisit, 30, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddHeader(ftGroup, 20, 0, 50);
                fileStamp.AddHeader(ftForm, 30, 0, 50);

                TimeZoneInfo tzi = null;
                try
                {
                    tzi = TimeZoneInfo.FindSystemTimeZoneById(TimeZoneFormatForCurrentUser);
                }
                catch
                {
                    tzi = TimeZoneInfo.Local;
                }

                DateTime dt = TimeZoneInfo.ConvertTime(DateTime.UtcNow, tzi);

                FormattedText ftDatetime = new FormattedText(string.Format("{0} {1:HH:mm} ({2})", dt.ToString(ExportDateFormat), dt, TimeZoneFormatForCurrentUser)
                                                             , fontColor, FONT_STYLE, FONT_ENCODING, FONT_EMBEDED, FONT_SIZE);

                // add footer
                fileStamp.AddFooter(ftStudy, 20, fileStamp.PageWidth / 2, fileStamp.PageWidth / 2);
                fileStamp.AddFooter(ftDatetime, 20, 25, 0);
                fileStamp.Save(PathToPdf);
            }
            finally
            {
                if (fileStamp != null)
                {
                    //close
                    fileStamp.Dispose();
                }
            }
        }