使用 Aspose.Net 保存 PDF 文件大小不断增大? - 我该如何防止这种情况发生?

发布于 2024-12-12 00:57:41 字数 866 浏览 0 评论 0原文

我正在评估 Aspose.Net - 到目前为止它非常适合我的需求。 (ITextSharp、PDFOne、CLPrint、Adobe 和 ABCPdf (WebSupergoo) 不能满足我的需求 - 不是这个问题的重点,所以请不要回答“您尝试过 X 了吗?”)

我想从文件加载 PDF一次,然后循环,设置一些表单字段,然后保存。效果很好,除了我注意到文件大小不断增长。我认为这是由于表单字段造成的,但事实并非如此...请注意这个令人不安的代码和结果:

代码

static void Main(string[] args)
{
    var form = new Aspose.Pdf.Facades.Form(@"c:\test.pdf");

    for (int i = 0; i < 100; i++)
    {
        using (var tempStream = new MemoryStream())
        {
            form.DestStream = tempStream;

            form.Save();

            Console.WriteLine("Size: " + tempStream.Length);
        }
    }
}

令人不安的结果

Aspose 不断增长的文件大小截图

你们中是否有人使用 Aspose 一次加载 PDF,然后多次保存,并以某种方式克服了文件大小不断增长的问题?

PS - 如果我每次都重新更新对象,文件大小会保持较低,但速度会较慢

I'm evaluating Aspose.Net - so far it's great for my needs. (ITextSharp, PDFOne, CLPrint, Adobe and ABCPdf (WebSupergoo) did not meet my needs - not the point of this question, so please don't answer with "have you tried X yet?")

I want to load a PDF from file once, then in a loop, set some form fields, then save it. Works great, except I noticed the file size constantly growing. I figured it was due to the form fields, but this isn't the case... notice this disturbing code and result:

The Code

static void Main(string[] args)
{
    var form = new Aspose.Pdf.Facades.Form(@"c:\test.pdf");

    for (int i = 0; i < 100; i++)
    {
        using (var tempStream = new MemoryStream())
        {
            form.DestStream = tempStream;

            form.Save();

            Console.WriteLine("Size: " + tempStream.Length);
        }
    }
}

The Disturbing Result

Aspose growing file size screenshot

Have any of you used Aspose to load a PDF once, and then save it multiple times, and somehow overcame the growing file-size issue?

P.S. - If I re-new-up the object every time, the file size stays low, but that's slower

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

剪不断理还乱 2024-12-19 00:57:41

输出文件大小随着每次迭代而增加,因为您在评估模式下使用该组件。在评估模式下工作时,它会在 PDF 文件中添加评估水印。此外,在评估模式下,由于评估检查和水印等原因,组件也会慢一些。

请使用带有许可证文件的组件。如果您只是进行评估,那么您可以获得 30 天的临时许可证 测试应用程序而没有任何此类限制。

另外,请确保您使用的是最新版本的组件 - Aspose.Pdf for .NET 6.3.0

如果您仍然发现任何其他疑问或问题,请与我们分享。

我还添加了我最后收到的带有许可证文件的输出的快照:

Output with Licensed Version

披露:我工作作为 Aspose 的开发人员传播者。

The output file size increases with each iteration because you're using the component in evaluation mode. When working in evaluation mode, it adds evaluation watermarks in the PDF file. Moreover, in evaluation mode, component is little slower too due to the evaluation checks and watermarks etc.

Please use the component with the license file. If you're just evaluating then you may get a temporary license for 30 days to test the application without any such limitations.

Also, please make sure that you're using the latest version of the component -- Aspose.Pdf for .NET 6.3.0.

If you still find any further questions or issues, please share with us.

I have also added a snapshot of the output received at my end with the license file:

Output with Licensed Version

Disclosure: I work as a developer evangelist at Aspose.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文