找回密码
 立即注册

QQ登录

只需一步,快速开始

sunyuanze

注册会员

21

主题

66

帖子

169

积分

注册会员

积分
169

活字格认证微信认证勋章

sunyuanze
注册会员   /  发表于:2017-2-8 10:42  /   查看:3488  /  回复:8
我们项目里需要用C1Report对象生成PDF文件。
文件里需要有C1Anchor和C1Hyperlink。

现在我们是按照如下方法设定的,但是发现有性能问题。
每多设置一个C1Anchor或C1Hyperlink,内存占用就会增加1.5M左右,
这样的话,只设置了几百个,内存占用就增加了很多。
请问是否有什么改善的方法?
        protected virtual void EditC1PrintDocument(C1Report report)
        {
            int idx = 0;
            string preMaruchi = string.Empty;
            for (int i = 0; i < report.C1Document.Body.Children.Count; i++)
            {
                var field = report.C1Document.Body.Children[i];
                if (field != null)
                {
                    if (field.GetType() == typeof(RenderText))
                    {
                        if (((RenderText)field).Text.IndexOf("Anchors:") == 0)
                        {
                            string[] currentMaruchi = ((RenderText)field).Text.Split(':');
                            if (!preMaruchi.Equals(currentMaruchi[1]))
                            {
                                preMaruchi = currentMaruchi[1];
                                string text = ((RenderText)field).Text.Replace("Anchors:", string.Empty);
                                ((RenderText)field).Text = string.Empty;
                                field.Anchors.Add(new C1Anchor(string.Format("Anchors{04}", (idx + 1))));
                                report.C1Document.Outlines.Add(text, field);
                                idx++;
                            }
                            else
                            {
                                ((RenderText)field).Text = string.Empty;
                            }
                        }

                        if (((RenderText)field).Text.Contains("HyperLink"))
                        {
                            var str = ((RenderText)field).Text.Split('-');
                            ((RenderText)field).Text = str[0];
                            field.Hyperlink = new C1Hyperlink(new C1LinkTargetAnchor(str[1].Replace("HyperLink", "Anchors")));
                        }
                    }
                }
            }
        }

8 个回复

倒序浏览
Alice
社区贡献组   /  发表于:2017-2-8 14:01:26
沙发
问题收到了,我先测试下您的代码,然后给您回复。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
sunyuanze
注册会员   /  发表于:2017-2-8 14:11:40
板凳
好的,多谢
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2017-2-8 17:34:58
地板
我使用随机安装示例进行保存到pdf的操作,没有重现性能问题。
路径:
\Documents\ComponentOne Samples\WinForms\C1Report\C1Report\Cs\CustomHyperlinks

有什么步骤能重现您的性能问题?
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
sunyuanze
注册会员   /  发表于:2017-2-8 17:43:13
5#
随机示例里生成的link比较少吧?你测定的是生成过程中内存占用没增加很多么?比如生成1000个link?生成pdf的过程中内存会持续增加,生成结束以后内存会被释放
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2017-2-9 09:35:07
6#
本帖最后由 Alice 于 2017-2-9 09:49 编辑
sunyuanze 发表于 2017-2-8 17:43
随机示例里生成的link比较少吧?你测定的是生成过程中内存占用没增加很多么?比如生成1000个link?生成pdf ...

那请您提供一个可以直接测试的Demo,我需要测试下您提到的问题。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
sunyuanze
注册会员   /  发表于:2017-2-9 09:39:40
7#
你好,可以提供一下邮箱地址么?我发到你邮箱里
回复 使用道具 举报
sunyuanze
注册会员   /  发表于:2017-2-9 09:40:18
8#
Alice 发表于 2017-2-9 09:35
那请您提供一个可以直接测试的Demo,我需要测试下您提到的前端问题。

你好,可以提供一下邮箱地址么?我发到你邮箱里
回复 使用道具 举报
Alice
社区贡献组   /  发表于:2017-2-9 10:09:59
9#
sunyuanze 发表于 2017-2-9 09:39
你好,可以提供一下邮箱地址么?我发到你邮箱里

不好意思,我们的邮箱只提供给金牌客户。
普通客户可以采用论坛的方式沟通问题。
请点击评分,对我的服务做出评价!  5分为非常满意!

葡萄城控件服务团队

官方网站: http://www.gcpowertools.com.cn
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部