Hyperlinks Rendering Performance

Last post 07-06-2011, 11:45 AM by aspose.notifier. 7 replies.
Sort Posts: Previous Next
  •  05-06-2011, 4:31 PM 301870

    Hyperlinks Rendering Performance .NET

    Hi Aspose team!


    Recently I did a lot of performance testing of Aspose.Pdf 5.2 and found a serious bottleneck related to hyperlinks.


    So the generated document is based on 6k data records which are rendered to approximately 2000 pages (40-70MB), also is contains ToC, Index and embedded hyperlinks which provide just another way to navigate the content.


    After numerous tests, it appears that Aspose.Pdf is not able to handle huge amounts of hyperlinks, e.g.: index consists of approx. 100 pages and contains 6k+ hyperlinks linked to different paragraphs. The code which creates PDF DOM runs pretty fast, but delay happens during Pdf.Save(memoryStream) method. Here are details:


    6k data set, no hyperlinks

    • Data access and DOM generation – 1min
    • Aspose.Pdf save to stream – 1min

    Same but index hyperlinks on

    • Data access and DOM generation – 1min
    • Aspose.Pdf save to stream – 10min (+9min with ToC/embedded hyperlinks on)

     Here is the way I add hyperlinks to text segments:


            private void AddIndexItem(Section section, string titleText, Rect frame, IEnumerable<SectionLink> sectionLinks)

            {

                const string indexSep = ", ";

                var root = section.GetRoot();

                var itemStyle = new TextInfo

                                    {

                                        FontName = “Arial”,

                                        FontSize =10,

                                        Color = new Color("Black"),

                                        IsUnicode = true,                                   

                                    };

                // Assemble and measure segments: title, indexes and elipsis

                var titleWidth = TextMeasure.GetStringWidth(titleText, itemStyle);                                  

                var indexesText = string.Join(indexSep,

                    sectionLinks.Select(sl => sl.Index.ToString()));

                var indexesWidth = TextMeasure.GetStringWidth(indexesText, itemStyle);

                var ellipsisWidth = TextMeasure.GetStringWidth(ChartDocument.Elipsis, itemStyle);

                var ellipsisCount = (int)Math.Truncate((frame.Width - titleWidth - indexesWidth) / ellipsisWidth);

                var ellipsisText = ellipsisCount > 0

                    ? new string(ChartDocument.Elipsis[0], ellipsisCount) : "";


                // Add title with a link to first index item

                var firstLink = new Hyperlink

                                    {

                                        LinkType = HyperlinkType.Local,

                                        TargetID = sectionLinks.First().SectionId,

                                    };

                var firstIndexItem = new Text(section)

                                    {

                                        Segments =

                                            {

                                                new Segment(titleText)

                                                    {

                                                        IsSymbolReplaceable = false,

                                                        Hyperlink = firstLink,

                                                    },

                                                new Segment(ellipsisText)

                                                    {

                                                        Hyperlink = firstLink

                                                    },

                                            },

     

                                        PositioningType = PositioningType.ParagraphRelative,

                                        ReferenceParagraphID = root.ID,

     

                                        Left = frame.Left.ToFloat(),

                                        Top = frame.Top.ToFloat() + 1,

                                        TextInfo = itemStyle,

                                        WrapLines = 1,                                   

                                    };

                section.Paragraphs.Add(firstIndexItem);     

         

                // Add indexes with the corresponding links                                 

                var indexItems = new Text(section)

                                            {

                                                PositioningType = PositioningType.ParagraphRelative,

                                                ReferenceParagraphID = root.ID,

     

                                                Left = (frame.Right - indexesWidth).ToFloat(),

                                                Top = frame.Top.ToFloat() + 1,

                                                TextInfo = itemStyle,

                                                WrapLines = 1,

                                            };

                sectionLinks.ToList()

                    .ForEach(sl =>

                        {

                            indexItems.Segments.Add(); // walkaround 1

                            indexItems.Segments.Add(

                                new Segment(

                                    sl.Index == sectionLinks.Last().Index

                                        ? sl.Index.ToString()

                                        : string.Concat(sl.Index, indexSep))

                                    {

                                        TextInfo = { FontName = “Arial” }, // walkaround 2

                                        Hyperlink =

                                            {

                                                LinkType = HyperlinkType.Local,

                                                TargetID = sl.SectionId,

                                            }

                                    });                       

                        });

                section.Paragraphs.Add(indexItems);

            }


            private struct SectionLink

            {

                public int Index;

                public string SectionId;           

            }


    Any suggestions or ideas how to avoid the performance degradation? Ideally I wish hyperlinks overhead to be 30 sec max instead of 9 min. The issue is urgent, because product going to release in a few months


    Thanks in advance,

    Alex

     
  •  05-08-2011, 4:26 PM 301944 in reply to 301870

    Re: Hyperlinks Rendering Performance

    Hello Alex,

    Thanks for using our products and sorry for replying you late.

    We are working over this query and will get back to you soon. We apologize for your inconvenience.


    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
  •  05-16-2011, 2:01 PM 303717 in reply to 301944

    Re: Hyperlinks Rendering Performance .NET

    Hello Nayyer,

    Any updates on the case?

    Alex
     
  •  05-17-2011, 3:09 PM 304113 in reply to 303717

    Re: Hyperlinks Rendering Performance

    Hello Alex,

    Sorry for replying you late. I am still trying to replicate this problem over my end. Soon you will be updated with the status of correction. Once again, please accept our humble apologies for this inconvenience.


    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
  •  05-18-2011, 4:39 AM 304222 in reply to 301870

    Re: Hyperlinks Rendering Performance

    Hello Alex,

    Thanks for your patience.

    I have tested the scenario in details and I am able to notice that when large number of Hyperlinks are added to TOC, the document generation time is drastically increasing. For the sake of correction, I have logged this problem as PDFNET-27284 in our issue tracking system. We will further look into the details of this problem and will keep you updated on the status of correction. Please be patient and spare us little time. We apologize for your inconvenience.


    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
  •  05-18-2011, 1:14 PM 304380 in reply to 304222

    Re: Hyperlinks Rendering Performance .NET

    Attachment: Present (inaccessible)
    Thanks a lot, Nayyer,

    Here are the test application I used to test hyperlinks performance and the metrics (attached). As far as I understand, performance depends on number of hyperlinks, number of pages and sections - which IMHO is natural. DOM generation time mostly stays the same.

    Hope this will help,
    Alex

     
  •  05-19-2011, 4:51 AM 304534 in reply to 304380

    Re: Hyperlinks Rendering Performance

    Hello Alex,

    Thanks for sharing the resource files.

    I have tested the project that you have shared and as per my observations over Windows7 64Bit Professional where my system is Intel Core i5 2.80GHz with 8GB RAM, following are the results.

    DOM generated in : 26.6240692 sec
    PDF   generated in : 358.0625772 sec
    Total                      : 384.6866464 sec

    Anyways, we will definitely consider the information that you have shared during the resolution of this problem and as soon as we have some updates, we will let you know. Please be patient and spare us little time.


    Nayyer Shahbaz
    Support Developer, Aspose Sialkot Team
    About Us
    Contact Us

    Keep in touch! We're on Twitter and Facebook
     
  •  07-06-2011, 11:45 AM 314889 in reply to 301870

    Re: Hyperlinks Rendering Performance

    The issues you have found earlier (filed as 27284 ) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by aspose.notifier.
     
View as RSS news feed in XML