Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Nov 29, 2017 3:45 pm

We generate PDFs and send them to our customers. We've been getting more and more complaints that the users can't open our PDFs in Microsoft Edge. After talking to them they are able to open the files in Adobe, Google Chrome and other viewers, but not Edge. The customers also tell us that all other PDFs they have open fine in Edge, just the ones that come from us have problems.

The error they get is:
Couldn’t open PDF
Something’s keeping this PDF from opening.

Attached sample PDF
26325789.zip
that is exhibiting this issue.

Is there some issue in the way the PDF file is generated that could be causing this?

I was using 3.9.109 but installed 3.9.493 hotfix with no difference.

Bill.Schalck
 
Posts: 14
Joined: Fri Jul 15, 2016 2:35 pm

Thu Nov 30, 2017 4:41 am

Hi Bill,

Thanks for your post. How did you generate the PDF? To help us investigate further, please share your full code and input document. You could attach them here or send to our email(support@e-iceblue.com).

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Thu Dec 07, 2017 9:47 am

Hello,

Greeting from E-iceblue.
How is issue going?
We will appreciate it if you could give us some feedback.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Wed Dec 13, 2017 11:14 pm

The code is quite complicated. I'm not sure I'd be able to simplify it any to send to you, so here it is...
Code: Select all
        PdfDocument orderPdf;
        PdfDocument blankPdf;
        PdfFont textFont;
        PdfSolidBrush textBrush;
        PdfStringFormat leftTop, rightTop, leftBottom, rightBottom;

        PdfTrueTypeFont bigHead, medHead, smallHead, smallText;
        PdfFont normText, bodyText;
        PdfSolidBrush whiteBrush, blackBrush;

        float maxy;

        public PdfPageBase AddPdfPage()
        {
            orderPdf.AppendPage(blankPdf);
            return orderPdf.Pages[orderPdf.Pages.Count - 1];
        }

        public void AddDefaultPdfLogo(PdfPageBase page, ref float x, ref float y)
        {
            x = (GlobalInfo.Customizations() == Customizations.cdw) ? 56.25f : 12.5f;
            y = 12.5f;
            AddPdfLogo(page, 1.25f, "ReUpB2B.Resources." + this.Dealer.ToLower() + ".png", ref x, ref y);
        }

        public void AddPdfLogo(PdfPageBase page, float height, ref float x, ref float y)
        {
            AddPdfLogo(page, height, null, ref x, ref y);
        }

        public void AddPdfLogo(PdfPageBase page, float height, String resource, ref float x, ref float y)
        {
            PdfImage pdfLogo = null;
            var assembly = Assembly.GetExecutingAssembly();
            List<String> resources = assembly.GetManifestResourceNames().ToList();
            String logo = resource;
            if (String.IsNullOrEmpty(logo) || !resources.Contains(logo))
            {
                logo = "ReUpB2B.Resources." + this.Provider + ".png";
                if (!resources.Contains(logo))
                    logo = "ReUpB2B.Resources.reupdevices.png";
            }

            using (Stream stream = assembly.GetManifestResourceStream(logo))
            {
                using (Bitmap bitmap = new Bitmap(stream))
                {
                    // Scale image to specified high
                    if (bitmap.Height / bitmap.VerticalResolution > height)
                    {
                        float scale = bitmap.Height / bitmap.VerticalResolution / height;
                        bitmap.SetResolution(bitmap.HorizontalResolution * scale, bitmap.VerticalResolution * scale);
                    }
                    // Store scaled images into logo object
                    pdfLogo = PdfImage.FromImage(bitmap);
                    if (pdfLogo != null)
                    {
                        if (x == float.MaxValue)
                            x = page.Size.Width - pdfLogo.PhysicalDimension.Width-56.25f;
                        if (y == float.MaxValue)
                            y = page.Size.Height - pdfLogo.PhysicalDimension.Height;
                        page.Canvas.DrawImage(pdfLogo, new PointF(x, y));
                        x = x + pdfLogo.Width / pdfLogo.HorizontalResolution * 72 + 7;
                    }
                }
            }
        }

        public void AddDocumentAddress(PdfPageBase page, ref float x, ref float y)
        {
            if (GlobalInfo.Customizations() != Customizations.cdw)
            {
                page.Canvas.DrawString(GlobalInfo.SiteSearch("DocumentCompany").ToString(), bigHead, blackBrush, x, y += 12, leftBottom);
                page.Canvas.DrawString(GlobalInfo.SiteSearch("DocumentAddress1").ToString(), smallHead, blackBrush, x, y += 10, leftBottom);
                if (GlobalInfo.SiteSearch("DocumentAddress2").ToString() != "")
                    page.Canvas.DrawString(GlobalInfo.SiteSearch("DocumentAddress2").ToString(), smallHead, blackBrush, x, y += 10, leftBottom);
                page.Canvas.DrawString(GlobalInfo.SiteSearch("DocumentCity").ToString() + ", " +
                    GlobalInfo.SiteSearch("DocumentState").ToString() + " " +
                    GlobalInfo.SiteSearch("DocumentZip").ToString(), smallHead, blackBrush, x, y += 10, leftBottom);
                page.Canvas.DrawString(GlobalInfo.SiteSearch("DocumentVoice").ToString(), smallHead, blackBrush, x, y += 15, leftBottom);
                page.Canvas.DrawString("Fax " + GlobalInfo.SiteSearch("DocumentFax").ToString(), smallHead, blackBrush, x, y += 10, leftBottom);
                String webSite = GlobalInfo.SiteSearch("DocumentWeb").ToString();
                if (String.IsNullOrEmpty(webSite))
                    webSite = "www." + GlobalInfo.Domain();
                page.Canvas.DrawString(webSite, smallHead, blackBrush, x, y += 15, leftBottom);
            }
        }

        public void DrawTestLines(PdfPageBase page)
        {
            PdfPen dashLinePen = new PdfPen(Color.Red, 1);
            dashLinePen.DashStyle = PdfDashStyle.Custom;
            float[] dashValues = { 7, 3, 15, 3 };
            dashLinePen.DashPattern = dashValues;
            dashLinePen.Width = 1;

            float x = 0;
            float y = 0;
            while (y < page.Canvas.ClientSize.Height)
            {
                page.Canvas.DrawLine(dashLinePen, 0, y, page.Canvas.ClientSize.Width, y);
                page.Canvas.DrawString(y.ToString(), textFont, textBrush, 0, y, leftTop);
                page.Canvas.DrawString(y.ToString(), textFont, textBrush, page.Canvas.ClientSize.Width, y, rightTop);
                y += 72;
            }
            while (x < page.Canvas.ClientSize.Width)
            {
                page.Canvas.DrawLine(dashLinePen, x, 0, x, page.Canvas.ClientSize.Height);
                page.Canvas.DrawString(x.ToString(), textFont, textBrush, x, 0, leftTop);
                page.Canvas.DrawString(x.ToString(), textFont, textBrush, x, page.Canvas.ClientSize.Height, leftBottom);
                x += 72;
            }
        }

        public void AddUpperRightBlock(PdfPageBase page, ref float x, ref float y)
        {
            // Upper Right Block
            y = 67;
            PdfSmallCaps(page.Canvas, this.OrderTypeDisplay + "#", medHead, whiteBrush, 400, y - 1);
            page.Canvas.DrawString(this.orderNumber, medHead, whiteBrush, 470, y, leftBottom);
            y += 13;
            PdfSmallCaps(page.Canvas, "Date", medHead, whiteBrush, 400, y - 1);
            page.Canvas.DrawString(this.orderDate.ToString("d"), normText, blackBrush, 470, y, leftBottom);
            if (GlobalInfo.Customizations() != Customizations.cdw)
            {
                y += 13;
                PdfSmallCaps(page.Canvas, "Account", medHead, whiteBrush, 400, y - 1);
                page.Canvas.DrawString(this.customer.BillingNumber, normText, blackBrush, 470, y, leftBottom);
            }
            //y += 13;
            //PdfSmallCaps(page.Canvas, "Lorem", medFont, whiteBrush, 400, y);
            //page.Canvas.DrawString("Ipsum", normalFont, blackBrush, 470, y, leftBottom);
        }

        public void AddBillToBlock(PdfPageBase page, ref float x, ref float y)
        {
            // Bill To Block
            x = 72;
            y = 148;
            PdfSmallCaps(page.Canvas, this.BillToPayToDisplay, bigHead, whiteBrush, x, y);
            y += 6;
            if (GlobalInfo.Customizations() == Customizations.cdw)
            {
                page.Canvas.DrawString(GlobalInfo.SiteSearch("DocumentCompany").ToString(), normText, blackBrush, x, y += 11, leftBottom);
                page.Canvas.DrawString(this.Customer.AccountManager.FullName, normText, blackBrush, x, y += 11, leftBottom);
                page.Canvas.DrawString(GlobalInfo.SiteSearch("DocumentAddress1").ToString(), normText, blackBrush, x, y += 11, leftBottom);
                if (GlobalInfo.SiteSearch("DocumentAddress2").ToString() != "")
                    page.Canvas.DrawString(GlobalInfo.SiteSearch("DocumentAddress2").ToString(), normText, blackBrush, x, y += 11, leftBottom);
                page.Canvas.DrawString(GlobalInfo.SiteSearch("DocumentCity").ToString() + ", " +
                    GlobalInfo.SiteSearch("DocumentState").ToString() + " " +
                    GlobalInfo.SiteSearch("DocumentZip").ToString(), normText, blackBrush, x, y += 11, leftBottom);
                page.Canvas.DrawString(this.Customer.AccountManager.Email, normText, blackBrush, x, y += 15, leftBottom);
                page.Canvas.DrawString(this.Customer.AccountManager.Phone, normText, blackBrush, x, y += 11, leftBottom);
            }
            else
            {
                if (this.customer.BillingCompany != "")
                    page.Canvas.DrawString(this.customer.BillingCompany, normText, blackBrush, x, y += 12, leftBottom);
                if (this.customer.BillingContact != "")
                    page.Canvas.DrawString(this.customer.BillingContact, normText, blackBrush, x, y += 12, leftBottom);
                if (this.customer.BillingAddress.Line1 != "")
                    page.Canvas.DrawString(this.customer.BillingAddress.Line1, normText, blackBrush, x, y += 12, leftBottom);
                if (this.customer.BillingAddress.Line2 != "")
                    page.Canvas.DrawString(this.customer.BillingAddress.Line2, normText, blackBrush, x, y += 12, leftBottom);
                page.Canvas.DrawString(this.customer.BillingAddress.City + ", " + this.customer.BillingAddress.State + " " + this.customer.BillingAddress.Zip, normText, blackBrush, x, y += 12, leftBottom);
            }
        }

        public void AddShipToBlock(PdfPageBase page, ref float x, ref float y)
        {
            // Ship To Block
            x = 342;
            y = 148;
            PdfSmallCaps(page.Canvas, this.ShipToPickupFromDisplay, bigHead, whiteBrush, x, y);
            y += 6;
            if (this.customer.ShippingCompany != "")
                page.Canvas.DrawString(this.customer.ShippingCompany, normText, blackBrush, x, y += 12, leftBottom);
            if (this.customer.ShippingContact != "")
                page.Canvas.DrawString(this.customer.ShippingContact, normText, blackBrush, x, y += 12, leftBottom);
            if (this.customer.ShippingAddress.Line1 != "")
                page.Canvas.DrawString(this.customer.ShippingAddress.Line1, normText, blackBrush, x, y += 12, leftBottom);
            if (this.customer.ShippingAddress.Line2 != "")
                page.Canvas.DrawString(this.customer.ShippingAddress.Line2, normText, blackBrush, x, y += 12, leftBottom);
            page.Canvas.DrawString(this.customer.ShippingAddress.City + ", " + this.customer.ShippingAddress.State + " " + this.customer.ShippingAddress.Zip, normText, blackBrush, x, y += 12, leftBottom);
        }

        public void AddReferenceBlock(PdfPageBase page, ref float x, ref float y)
        {
            // Reference Block
            x = 58;
            y = 256;
            if (GlobalInfo.Customizations() == Customizations.cdw)
            {
                PdfSmallCaps(page.Canvas, "Prepared For", medHead, whiteBrush, x, y);
                page.Canvas.DrawString(this.Customer.ShippingCompany, bodyText, blackBrush, new RectangleF(x, y + 7, 95, 12));
            }
            else
            {
                PdfSmallCaps(page.Canvas, "Account Manager", medHead, whiteBrush, x, y);
                page.Canvas.DrawString(this.Customer.AccountManager.FullName, bodyText, blackBrush, new RectangleF(x, y + 7, 95, 12));
            }
            x = 157;
            PdfSmallCaps(page.Canvas, GlobalInfo.POLabel(), medHead, whiteBrush, x, y);
            page.Canvas.DrawString(this.purchaseOrder, bodyText, blackBrush, new RectangleF(x, y + 7, 95, 12));
            //x = 258;
            //PdfSmallCaps(page.Canvas, x.ToString(), medHead, whiteBrush, x, y);
            //page.Canvas.DrawString(x.ToString(), bodyText, blackBrush, x, y + 7);
            x = 360;
            PdfSmallCaps(page.Canvas, GlobalInfo.RALabel(), medHead, whiteBrush, x, y);
            page.Canvas.DrawString(this.reference, bodyText, blackBrush, new RectangleF(x, y + 7, 95, 12));
            //x = 460;
            //PdfSmallCaps(page.Canvas, x.ToString(), medHead, whiteBrush, x, y);
            //page.Canvas.DrawString(x.ToString(), bodyText, blackBrush, x, y + 7);
        }

        public void AddPdfTop(PdfPageBase page)
        {
            if (1 == 2)
                DrawTestLines(page);

            float x=0, y=0;
            AddDefaultPdfLogo(page, ref x, ref y);
            y += 12;
            AddDocumentAddress(page, ref x, ref y);

            AddUpperRightBlock(page, ref x, ref y);
            AddBillToBlock(page, ref x, ref y);
            AddShipToBlock(page, ref x, ref y);

            AddReferenceBlock(page, ref x, ref y);
        }

        public void AddBullet(PdfPageBase p, Char c, String txt, PdfTrueTypeFont f, PdfBrush b, ref RectangleF r)
        {
            p.Canvas.DrawString(c.ToString(), f, b, r);
            RectangleF r2 = new RectangleF(r.Left + 10, r.Top, r.Width, r.Height);
            SizeF sz = f.MeasureString(txt, new SizeF(r2.Width, r2.Height));
            p.Canvas.DrawString(txt, f, b, r2);
            r = new RectangleF(r.Left, r.Top + sz.Height + f.Height / 2, r.Width, r.Height - sz.Height);
        }

        public void AddBullet(PdfPageBase p, String txt, PdfTrueTypeFont f, PdfBrush b, ref RectangleF r)
        {
            AddBullet(p, '\x2022', txt, f, b, ref r);
        }

        public void AddWhiteBullet(PdfPageBase p, String txt, PdfTrueTypeFont f, PdfBrush b, ref RectangleF r)
        {
            AddBullet(p, '\x25E6', txt, f, b, ref r);
        }

        public void AddPdfBottom(PdfPageBase page)
        {
            if (this.orderType == "TRADEIN")
                PdfGradeTable(page);

            PdfSmallCaps(page.Canvas, "Subtotal", medHead, whiteBrush, 430, 656);
            page.Canvas.DrawString(this.FormatDisplayPrices(this.GrandTotal(ShowDiscount.Discounted)), medHead, whiteBrush, 550, 656, rightBottom);
            if (GlobalInfo.Customizations() == Customizations.cdw)
            {
                PdfSmallCaps(page.Canvas, "Credit", medHead, whiteBrush, 430, 720);
                PdfSmallCaps(page.Canvas, " Estimate", medHead, whiteBrush, 430, 730);
            }
            else
                PdfSmallCaps(page.Canvas, "Total", medHead, whiteBrush, 430, 723);
            page.Canvas.DrawString(this.FormatDisplayPrices(this.GrandTotal(ShowDiscount.Discounted)), bigHead, whiteBrush, 550, 725, rightBottom);

            // "Important" block
            PdfSmallCaps(page.Canvas, "Important", medHead, whiteBrush, 58, 664);
            RectangleF important = new RectangleF(58, 670, 350, 84);
            AddBullet(page, "Prices are valid for 30 days from date of quote and subject to acceptance of UEG terms and conditions", smallText, blackBrush, ref important);

            if (GlobalInfo.Customizations() == Customizations.cdw)
            {
                AddBullet(page, "To execute your buy-back contact your CDW·G account manager.", smallText, blackBrush, ref important);
                RectangleF important2 = new RectangleF(important.Left + 10, important.Top, important.Width - 10, important.Height);
                AddWhiteBullet(page, "You will receive an Email to confirm all details and to accept UEG terms and conditions.", smallText, blackBrush, ref important2);
                AddWhiteBullet(page, "Any earned credit will be placed on your CDW·G account upon inspection and completion by UEG.", smallText, blackBrush, ref important2);
                important = new RectangleF(important.Left, important2.Top, important.Width, important2.Height);
                AddBullet(page, "Contact your CDW·G account manager for any revision requests.", smallText, blackBrush, ref important);
            }
            SizeF tsandcsMax = new SizeF(360, 30);
            String tsandcs="Subject to " + GlobalInfo.DBAName() + " terms and conditions. Terms and conditions can be";
            SizeF tsandcsSize = smallText.MeasureString(tsandcs, tsandcsMax);
            RectangleF tsandcsRect = new RectangleF(58, 760, tsandcsSize.Width, tsandcsSize.Height);
            page.Canvas.DrawString(tsandcs, smallText, blackBrush, tsandcsRect);
           
            PdfTextWebLink link = new PdfTextWebLink();
            link.Text = "found here";
            link.Url = GlobalInfo.Site()+"/Public/TsAndCs";
            link.Font = smallText;
            link.Brush = blackBrush;
            link.Brush = PdfBrushes.Blue;
            link.DrawTextWebLink(page.Canvas, new PointF(tsandcsRect.Left + tsandcsSize.Width + 3.0f, tsandcsRect.Top));
            //page.Canvas.DrawString(link.Text, smallText, PdfBrushes.Brown, new PointF(tsandcsRect.Left, tsandcsRect.Top));

            tsandcsRect = new RectangleF(58, tsandcsRect.Top + tsandcsSize.Height, tsandcsMax.Width, tsandcsMax.Height - tsandcsSize.Height);
            tsandcs = "or you may contact your account manager.";
            page.Canvas.DrawString(tsandcs, smallText, blackBrush, tsandcsRect);
        }

        public PdfDocument ToPdf()
        {
            orderPdf = new PdfDocument();

            blankPdf = new PdfDocument();
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ReUpB2B.Resources.ReUp Blank Form.pdf"))
                blankPdf.LoadFromStream(stream);

            textFont = new PdfFont(PdfFontFamily.Helvetica, 10f);
            textBrush = new PdfSolidBrush(Color.Red);
            leftTop = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Top);
            rightTop = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Top);
            leftBottom = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Bottom);
            rightBottom = new PdfStringFormat(PdfTextAlignment.Right, PdfVerticalAlignment.Bottom);

            bigHead = new PdfTrueTypeFont(new Font("Century Gothic", 12f, FontStyle.Bold));
            medHead = new PdfTrueTypeFont(new Font("Century Gothic", 10f, FontStyle.Bold));
            smallHead = new PdfTrueTypeFont(new Font("Century Gothic", 9f, FontStyle.Regular));
            normText = new PdfFont(PdfFontFamily.TimesRoman, 11f);
            bodyText = new PdfFont(PdfFontFamily.TimesRoman, 9f);
            smallText = new PdfTrueTypeFont(new Font("Times New Roman", 8f, FontStyle.Regular), true);
            whiteBrush = new PdfSolidBrush(Color.White);
            blackBrush = new PdfSolidBrush(Color.Black);

            PdfPageBase page = AddPdfPage();
            AddPdfTop(page);

            // Items Block
            float top, x=0, y=0;
            top = 310f;
            y = top;
            SizeF noteSize = bodyText.MeasureString(this.Notes, new SizeF(215, 100));
            for (int q = 0; q < this.Items.Count; q++)
            {
                OrderItem i = this.items[q];
                i.UseDiscountedPricing = ShowDiscount.Discounted;

                if ((this.orderType == "TRADEIN") && (q == this.Items.Count - 1))
                    maxy = 527;
                else
                    maxy = 630;

                String description = i.Product.Description;
                SizeF sz;
                int di = 0, ds = 0, ldi = 0;
                while (di < description.Length)
                {
                    di = description.IndexOf(" - ", di + 1);
                    if (di == -1)
                        di = description.Length;
                    String qqq = description.Substring(ds, di - ds);
                    sz = bodyText.MeasureString(description.Substring(ds, di-ds), new SizeF(float.MaxValue, 100));
                    if ((sz.Width > 200) && (ldi > 0))
                    {
                        di = ldi;
                        description = description.Remove(di + 2, 1).Insert(di + 2, Environment.NewLine);
                        ds = di + 4;
                        di = ds;
                        ldi = 0;
                    }
                    else
                        ldi = di;
                }

                if (!String.IsNullOrEmpty(i.MfrPn))
                    description = description + Environment.NewLine + "Manufacturer Part# " + i.MfrPn;

                sz = bodyText.MeasureString(description, new SizeF(215, 100));

                if (y + sz.Height + noteSize.Height + 4.5f > maxy)
                {
                    PdfSmallCaps(page.Canvas, "Continued...", medHead, whiteBrush, 430, 723);
                    page = AddPdfPage();
                    AddPdfTop(page);
                    y = top;
                }

                x = 100;
                page.Canvas.DrawString(i.Quantity.ToString(), bodyText, blackBrush, x, y, rightTop);
                x = 110;
                page.Canvas.DrawString(i.Product.Part, bodyText, blackBrush, x, y);
                x = 200;
                page.Canvas.DrawString(description, bodyText, blackBrush, new RectangleF(x, y, sz.Width, sz.Height));
                x = 472;
                page.Canvas.DrawString(i.DisplayPrice, bodyText, blackBrush, x, y, rightTop);
                x = 550;
                page.Canvas.DrawString(i.DisplayExtension, bodyText, blackBrush, x, y, rightTop);
                y += sz.Height + 4.5f;
            }

            if (noteSize.Height > 0)
            {
                x = 200;
                page.Canvas.DrawString(this.notes, bodyText, blackBrush, new RectangleF(x, y, 215, noteSize.Height));
            }

            AddPdfBottom(page);

            for (int pn = 1; pn <= orderPdf.Pages.Count; pn++)
            {
                PdfPageBase p = orderPdf.Pages[pn - 1];
                p.Canvas.DrawString("Page " + pn.ToString() + " of " + orderPdf.Pages.Count.ToString(), bodyText, blackBrush, new PointF(p.Canvas.ClientSize.Width - 56.25f, p.Canvas.ClientSize.Height - 18.75f), rightBottom);
            }
            AddHtmlToPdf("TsAndCs.html");

            return orderPdf;
        }
        void AddHtmlToPdf(String template)
        {
            PdfDocument htmlPdf = new PdfDocument();
            PdfHtmlLayoutFormat htmlLayoutFormat = new PdfHtmlLayoutFormat();
            htmlLayoutFormat.Layout = PdfLayoutType.OnePage;
            htmlLayoutFormat.IsWaiting = false;
            PdfPageSettings setting = new PdfPageSettings();
            setting.Size = PdfPageSize.Letter;
            string htmlCode = this.ToHtml(template);
            htmlCode = "<span style='font-size:7pt'>" + htmlCode + "</span>";

            Thread thread = new Thread(() =>
           { htmlPdf.LoadFromHTML(htmlCode, false, setting, htmlLayoutFormat);});
            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            float top = 50;
            float bottom = 50;
            float left = 72;
            float right = 72;

            foreach (PdfPageBase page in htmlPdf.Pages)
            {
                PdfPageBase newPage = orderPdf.Pages.Add(page.Size, new PdfMargins(0));

                newPage.Canvas.ScaleTransform(page.ActualSize.Width / (page.ActualSize.Width + left + right),
                                   page.ActualSize.Height / (page.ActualSize.Height + top + bottom));
                newPage.Canvas.DrawTemplate(page.CreateTemplate(), new PointF(left, top));
            }

//            orderPdf.AppendPage(htmlPdf);
            //foreach (PdfPageBase p in htmlPdf.Pages)
            //    orderPdf.InsertPage(p,0);
        }
        void PdfSmallCaps(PdfCanvas c, String s, PdfTrueTypeFont f, PdfBrush b, float x, float y)
        {
            PdfStringFormat leftBottom = new PdfStringFormat(PdfTextAlignment.Left, PdfVerticalAlignment.Bottom);
            s = s.ToUpper();
            PdfTrueTypeFont f2 = new PdfTrueTypeFont(f, f.Size - 2);
            //Measures a string by using this font.
            SizeF s1 = f.MeasureString(s.Substring(0, 1));
            SizeF s2 = f2.MeasureString(s.Substring(1));
            c.DrawString(s.Substring(0, 1), f, b, x, y+0.5f, leftBottom);
            c.DrawString(s.Substring(1), f2, b, x + s1.Width, y, leftBottom);
        }

        void PdfGradeTable(PdfPageBase p)
        {
            String[][] dataSource= new String[2][];
            dataSource[0] = "Grade \"A\" Like New|Grade \"B\" Normal Wear|Grade \"C\" Damaged".Split('|');
            dataSource[1] =
              ("No significant wear and no missing parts" + Environment.NewLine +
              "Very light scratches" + Environment.NewLine +
              "No dents, cracks or engravings on casing" + Environment.NewLine +
              "No scratches on LCD|" +
              "No missing parts" + Environment.NewLine +
              "Moderate scratches" + Environment.NewLine +
              "No dents, cracks or engravings on casing" + Environment.NewLine +
              "No scratches on LCD|" +
              "Missing keys or buttons" + Environment.NewLine +
              "Significant scratches" + Environment.NewLine +
              "Dents, cracks or engravings on casing" + Environment.NewLine +
              "Scratches or cracks on LCD").Split('|');

            PdfTable table = new PdfTable();

            table.Style.HeaderStyle.StringFormat = new PdfStringFormat(PdfTextAlignment.Center);
            table.Style.HeaderStyle.TextBrush = whiteBrush;
            table.Style.HeaderStyle.Font = smallHead;
            table.Style.HeaderSource = PdfHeaderSource.Rows;
            table.Style.HeaderRowCount = 1;
            table.Style.ShowHeader = true;
            table.Style.HeaderStyle.BackgroundBrush = new PdfSolidBrush(new PdfRGBColor(110,191,75));
            table.DataSource = dataSource;
            table.Style.CellPadding = 0.5f;
            table.Style.DefaultStyle.Font = smallText;
            table.Style.AlternateStyle.Font = smallText;
            table.Style.BorderPen = new PdfPen(PdfBrushes.Black, 1f);
            foreach (PdfColumn column in table.Columns)
            {
                column.StringFormat = new PdfStringFormat(PdfTextAlignment.Center, PdfVerticalAlignment.Middle);
            }
            p.Canvas.DrawRectangle(new PdfSolidBrush(Color.White), new RectangleF(72, maxy, 468, 639-maxy));
            p.Canvas.DrawRectangle(table.Style.BorderPen, new RectangleF(72, maxy, 468, 635 - maxy));
            table.Draw(p, new RectangleF(72, maxy, 468, 640 - maxy));
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("To ensure full value ALL device grades should:");
            sb.AppendLine("\t• Be fully functional and power up to the home screen to allow data deletion.");
            sb.AppendLine("\t• Have a clean ESN if applicable (cannot have been reported lost/stolen).");
            sb.AppendLine("\t• Have lost-device locating features, such as Apple's Find My iPhone or Samsung's Find My Mobile, turned off.");
            sb.AppendLine("\t• Be deprovisioned with the carrier and have developer mode unlocked.");
            sb.AppendLine("\t• Include power cord, AC adapter and other available accessories.");
            p.Canvas.DrawString(sb.ToString(), smallText, blackBrush, new RectangleF(82, maxy, 458, 634 - maxy), leftBottom);
        }

Bill.Schalck
 
Posts: 14
Joined: Fri Jul 15, 2016 2:35 pm

Thu Dec 14, 2017 10:00 am

Hello Bill,

Thanks for your feedback. After investigation, I find the issue is caused by the code in foreach sentence of AddHtmlToPdf(String template), I have logged it into our bug tracking system, if there is any update, we will let you know.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Thu Dec 14, 2017 3:06 pm

Actually that routine was not involved in the production of the PDF in question. That is a work in progress for an addition to the program. So the problem must be elsewhere.

Bill.Schalck
 
Posts: 14
Joined: Fri Jul 15, 2016 2:35 pm

Fri Dec 15, 2017 8:33 am

Hello Bill,

Thanks for your feedback. I find that AppendPage(PdfDocument) method will make the PDF could not display in MS Edge also, it's "orderPdf.AppendPage(blankPdf)" in your code. I have forwarded the issue to our DEV team, if there is any update, we will inform you.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Dec 19, 2017 6:34 am

Hello Bill,

Hope you are doing fine.
With further investigation, our DEV team find the structure of PDF which is generated from Spire.Pdf is normative. The issue is caused by MS Edge itself, it can't parse out the data in that form. If you look through the forum of Microsoft, you can see the posts that MS Edge can't open some kinds of PDF.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Sep 18, 2018 6:54 am

Dear Bill,

Greetings from e-iceblue!
After our dev team's persistent efforts, we have improved the compatibility with Microsoft Edge and now your issue has been resolved.
Please download the hotfix Spire.PDF Pack(Hot Fix) Version:4.9.4.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.PDF