Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri May 23, 2014 11:06 am

Hello

The printout of the attached document with a footer causes the final page of the document to have a large header space, page 3.

If I print out this document after printing, the printed document does not have this large space on page 3. However I have noticed that the footer within the printed document and the saved document is also different, one has a border and the other does not.

I have given you sample code to generate this issue.


Code: Select all
        private void runTest()
        {
            string tempfilename = @"c:\fail_rtf.doc";
            string text = System.IO.File.ReadAllText(tempfilename, Encoding.GetEncoding(1252)); 
            try
            {
                using (Document doc = new Document(tempfilename, FileFormat.Rtf))
                {
                    renderPrint(doc,  new PatientReportDetails("nhsnumber","mrn", "dob", "surname", "forename", "gppractice" , 12345));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
              //  System.IO.File.Delete(tempfilename);
            }
        }

private void renderPrint(Document doc, PatientReportDetails patientDetails)
        {
            try
            {
                int i = doc.Sections.Count - 1;
                Section lastSection = doc.Sections[0];

                lastSection.PageSetup.FooterDistance = 10;

                //Add Footer
                HeaderFooter footer = lastSection.HeadersFooters.Footer;


                Table table = footer.AddTable(true);
                table.ResetCells(2, 1);

                Paragraph FParagraph = table.Rows[0].Cells[0].AddParagraph();

                FParagraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
                FParagraph.Format.Borders.BorderType = Spire.Doc.Documents.BorderStyle.None;
                FParagraph.Format.Borders.Top.Space = 0.15f;
                FParagraph.Format.Borders.Color = System.Drawing.Color.Black;
                FParagraph.Format.Borders.Space = 4.0f;


                TextRange FormattedNHS = FParagraph.AppendText(patientDetails.getFormattedNHS() + "\t");
                TextRange FormattedMRN = FParagraph.AppendText(patientDetails.getFormattedMRN() + "\t");
                TextRange FormattedPatientName = FParagraph.AppendText(patientDetails.getFormattedPatientName() + "\t");
                TextRange FormattedDOB = FParagraph.AppendText(patientDetails.getFormattedDOB());

                //insert page number
                FParagraph = table.Rows[1].Cells[0].AddParagraph();

                TextRange FormattedUniqueId = FParagraph.AppendText(patientDetails.getFormattedUniqueID() + "\t");

                TextRange FPageInfo = FParagraph.AppendText("Page: ");
                TextRange FPageInfo1 = FParagraph.AppendField("page number", FieldType.FieldPage);
                TextRange FPageInfo2 = FParagraph.AppendText(" of ");
                TextRange FPageInfo3 = FParagraph.AppendField("number of pages", FieldType.FieldNumPages);

                TextRange FPageInfo4 = FParagraph.AppendText("\t Printed ");
                TextRange FPrintedDetails = FParagraph.AppendText(DateTime.Now.ToLocalTime().ToString());

                FPageInfo.CharacterFormat.FontName = "Calibri";
                FPageInfo.CharacterFormat.FontSize = 8;
                FPageInfo.CharacterFormat.Bold = true;
                FPageInfo.CharacterFormat.TextColor = System.Drawing.Color.Black;

                FPageInfo1.CharacterFormat.FontName = "Calibri";
                FPageInfo1.CharacterFormat.FontSize = 8;
                FPageInfo1.CharacterFormat.Bold = true;
                FPageInfo1.CharacterFormat.TextColor = System.Drawing.Color.Black;

                FPageInfo2.CharacterFormat.FontName = "Calibri";
                FPageInfo2.CharacterFormat.FontSize = 8;
                FPageInfo2.CharacterFormat.Bold = true;
                FPageInfo2.CharacterFormat.TextColor = System.Drawing.Color.Black;

                FPageInfo3.CharacterFormat.FontName = "Calibri";
                FPageInfo3.CharacterFormat.FontSize = 8;
                FPageInfo3.CharacterFormat.Bold = true;
                FPageInfo3.CharacterFormat.TextColor = System.Drawing.Color.Black;


                FPageInfo4.CharacterFormat.FontName = "Calibri";
                FPageInfo4.CharacterFormat.FontSize = 8;
                FPageInfo4.CharacterFormat.Bold = true;
                FPageInfo4.CharacterFormat.TextColor = System.Drawing.Color.Black;

                FPrintedDetails.CharacterFormat.FontName = "Calibri";
                FPrintedDetails.CharacterFormat.FontSize = 8;
                FPrintedDetails.CharacterFormat.Bold = true;
                FPrintedDetails.CharacterFormat.TextColor = System.Drawing.Color.Black;

                FormattedNHS.CharacterFormat.FontName = "Calibri";
                FormattedNHS.CharacterFormat.FontSize = 8;
                FormattedNHS.CharacterFormat.Bold = true;
                FormattedNHS.CharacterFormat.TextColor = System.Drawing.Color.Black;

                FormattedPatientName.CharacterFormat.FontName = "Calibri";
                FormattedPatientName.CharacterFormat.FontSize = 8;
                FormattedPatientName.CharacterFormat.Bold = true;
                FormattedPatientName.CharacterFormat.TextColor = System.Drawing.Color.Black;

                FormattedMRN.CharacterFormat.FontName = "Calibri";
                FormattedMRN.CharacterFormat.FontSize = 8;
                FormattedMRN.CharacterFormat.Bold = true;
                FormattedMRN.CharacterFormat.TextColor = System.Drawing.Color.Black;

                FormattedDOB.CharacterFormat.FontName = "Calibri";
                FormattedDOB.CharacterFormat.FontSize = 8;
                FormattedDOB.CharacterFormat.Bold = true;
                FormattedDOB.CharacterFormat.TextColor = System.Drawing.Color.Black;

                FormattedUniqueId.CharacterFormat.FontName = "Calibri";
                FormattedUniqueId.CharacterFormat.FontSize = 8;
                FormattedUniqueId.CharacterFormat.Bold = true;
                FormattedUniqueId.CharacterFormat.TextColor = System.Drawing.Color.Black;

                //Set Footer Paragrah Format

                FParagraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Center;
                FParagraph.Format.Borders.BorderType = Spire.Doc.Documents.BorderStyle.None;
                FParagraph.Format.Borders.Top.Space = 0.15f;
                FParagraph.Format.Borders.Color = System.Drawing.Color.Black;
                FParagraph.Format.Borders.Space = 4.0f;


                using (PrintDialog dialog = new PrintDialog())
                {
                    doc.PrintDialog = dialog;
                    PrintDocument printDoc = doc.PrintDocument;
                    printDoc.PrintController = new StandardPrintController();
                    printDoc.Print();
                }
                doc.SaveToFile(@"c:\printed_doc.rtf");
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {

            }
        }

public class PatientReportDetails
    {
        private string _mrn;
        private string _surname;
        private string _forename;
        private string _nhsNumber;
        private string _dob;
        private Int64 _uniqueID;
        private string _gppractice;

        public PatientReportDetails()
        {
        }

        public PatientReportDetails(string nhsnumber, string mrn ,string dob, string surname,string forename, string gppractice )
        {
            this._gppractice = gppractice;
            this._mrn = mrn;
            this._nhsNumber = nhsnumber;
            this._surname = surname;
            this._forename = forename;
            this._dob = dob;
        }

        public PatientReportDetails(string nhsnumber, string mrn, string dob, string surname, string forename, string gppractice , Int64 uniqueId)
        {
            this._gppractice = gppractice;
            this._mrn = mrn;
            this._nhsNumber = nhsnumber;
            this._surname = surname;
            this._forename = forename;
            this._dob = dob;
            this._uniqueID = uniqueId;
        }

        public string GPpractice
        {
            get { return _gppractice; }
            set { _gppractice = value; }
        }

        public Int64 UniqueID
        {
            get { return _uniqueID; }
            set { _uniqueID = value; }
        }

        public string Surname
        {
            get { return _surname; }
            set { _surname = value; }
        }

        public string Forename
        {
            get { return _forename; }
            set { _forename = value; }
        }

        public string DOB
        {
            get
            {
                if (string.IsNullOrEmpty(_dob))
                {
                    return "";
                }
                else
                {
                    return _dob;
                }
            }
            set { _dob = value; }
        }

        public string NHSNumber
        {
            get
            {
                if (string.IsNullOrEmpty(this._nhsNumber))
                {
                    return "";
                }
                else
                {
                    return _nhsNumber;
                }
            }
            set { _nhsNumber = value; }
        }

        public string MRN
        {
            get
            {
                if (string.IsNullOrEmpty(_mrn))
                {
                    return "";
                }
                else
                {
                    return _mrn;
                }
            }
            set { _mrn = value; }
        }

        public string getFormattedDOB()
        {
            if (this.DOB.Length >= 8)
            {
                return "DOB: " + this.DOB.Substring(0, 4) + '/' + this.DOB.Substring(4, 2) + '/' + this.DOB.Substring(6, 2);
            }
            else
            {
                return "DOB: ";
            }
        }

        public string getFormattedNHS()
        {
            return "NHS: " + this.NHSNumber;
        }

        public string getFormattedMRN()
        {
            return "MRN: " + MRN;
        }

        public string getFormattedGPPractice()
        {
            return "GP: " + this.GPpractice;
        }

        public string getFormattedPatientName()
        {
            return "Name: " + this.Surname + " ," + this.Forename;
        }

        public string getFormattedUniqueID()
        {
            return "Print UniqueID: " + this.UniqueID;
        }

    }


shaun
 
Posts: 16
Joined: Fri Mar 14, 2014 2:58 pm

Mon May 26, 2014 6:55 am

Hello,

Sorry for late reply as weekend.
Thanks for your feedback. And there is no attachment(fail_rtf.doc), please attach it again or send it to our Email(support@e-iceblue.com);
kindly note that please zip it before attaching.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Jun 03, 2014 1:31 pm

Hi Gary,

Do you have any update regarding the files I sent by email. Where you able to reproduce the error and if so where you able to address the issue?

shaun
 
Posts: 16
Joined: Fri Mar 14, 2014 2:58 pm

Wed Jun 04, 2014 1:55 am

Hello,

Sorry for long silence.
The issue has been resolved, once the hotfix is released, we will let you know immediately.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Jun 17, 2014 7:02 am

Hello,

Do we have an idea when the hotfix is likely to be released?

Shaun

shaun
 
Posts: 16
Joined: Fri Mar 14, 2014 2:58 pm

Tue Jun 17, 2014 8:34 am

Hello,

Sorry for inconvenience. There is a temporary hotfix you can test. Once the hotfix is officially released, we will let you know immediately.
If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Jun 20, 2014 9:37 am

Hello,

The official hotfix has been released, you can download and test Spire.Doc Pack(hot fix) Version:5.1.23.

If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.Doc

cron