Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Fri May 31, 2024 4:41 pm

Hello,

I am encountering an issue when trying to save a PowerPoint presentation with more than 200 slides using Spire.Presentation. The following exception is thrown:

System.ArgumentException: 'item has already been added. key in dictionary'

This exception occurs at the point of saving the file. Below is a code snippet that demonstrates the problem:

if (_saveSlides && !cancelInd)
{
Spire.Presentation.Presentation pptxDoc = new();
pptxDoc.LoadFromFile(_savepptName);
AddSlides(_saveTerrs, _saveViews, _saveFolder,
_savepptHeader, pptxDoc, _savepptMapPtLeft, _savepptMapPtTop, _savepptMapPtWidth,
_savepptMapPtHeight, _savepptCrop, _savepptShpnumTitle, _savepptShpnumMap);
pptxDoc.DocumentProperty["_MarkAsFinal"] = true;
pptxDoc.SaveToFile(_savepptFinalName, FileFormat.Auto);
}

sivalasanthosh
 
Posts: 5
Joined: Fri Mar 22, 2024 1:07 pm

Mon Jun 03, 2024 2:45 am

Hello,

Thanks for your inquiry.
Hello, according to your description, I used Spire.Presentationto create a presentation file with more than 200 slides, but I did not encounter the issue you mentioned. To help us investigate further, please provide us with your full test code and input file. You can upload it here as an attachment or send it to this email: support@e-iceblue.com. Thanks in advance.

Sincerely
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Mon Jun 03, 2024 1:57 pm

Ticket Title: Issue with Setting Document Property "_MarkAsFinal" on Protected Presentation

Description: I encountered an issue when using Spire.Presentation with an existing protected PowerPoint template. The code breaks when setting `pptxDoc.DocumentProperty["_MarkAsFinal"] = true`. Below is a detailed description and sample code to reproduce the issue.

Steps to Reproduce:
1. Load an existing protected PowerPoint presentation.
2. Add a new slide to the presentation.
3. Optionally, add content to the new slide.
4. Set the document property `_MarkAsFinal` to `true`.
5. Save the updated presentation.


Sample Code:
// Load the existing PowerPoint presentation
string pptFilePath = @"C:\Clients\SpirePresentation\SpirePresentation\WpfApp1\bin\Debug\net8.0-windows\2g56.pptx";
Presentation pptxDoc = new Presentation();
pptxDoc.LoadFromFile(pptFilePath);

// Add a new slide to the presentation
ISlide newSlide = pptxDoc.Slides.Append();

// Optionally, you can add content to the new slide
IAutoShape shape = newSlide.Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 50, 500, 150));
shape.Fill.FillType = FillFormatType.None;
shape.TextFrame.Text = "This is a new slide";

// Set the document property "_MarkAsFinal" to true
pptxDoc.DocumentProperty["_MarkAsFinal"] = true;

// Save the updated presentation
pptxDoc.SaveToFile(@"C:\Clients\SpirePresentation\SpirePresentation\WpfApp1\bin\Debug\net8.0-windows\UpdatedPresentation.pptx", FileFormat.Auto);


Root Cause: The code breaks when setting the `_MarkAsFinal` property to `true` on a protected PowerPoint template. This issue does not occur with unprotected templates.

Questions:
1. Is there a workaround or additional steps required to set the `_MarkAsFinal` property on a protected template?
2. Are there any updates or patches available that address this issue?
3. Is there a recommended way to handle protected presentations when setting properties like `_MarkAsFinal`?
4. What is the purpose of setting `_MarkAsFinal` to `true` in a PowerPoint presentation?
5. How can we check programmatically if an existing PowerPoint presentation is protected?

Additional Context: I previously raised a ticket with a different context but have now identified the exact root cause.

sivalasanthosh
 
Posts: 5
Joined: Fri Mar 22, 2024 1:07 pm

Tue Jun 04, 2024 3:42 am

Hello,

Thanks for your feedback.
I simulated a protected PowerPoint file and tested the code you provided with our latest Spire.Presentation Pack Hotfix Version:9.5.3, but still couldn't reproduce the issue you mentioned. If you are not using the latest version, please upgrade and retest. If your issue still exists after trying. Please provide us with your test file and region setting (E.g. China, Chinese) of your System. You can upload it here as an attachment or send it to this email: support@e-iceblue.com. Thanks in advance.

Sincerely
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Tue Jun 04, 2024 10:45 am

Dear Support Team,

Thank you for your prompt response and for testing the code with the latest Spire.Presentation Pack Hotfix Version: 9.5.3.

I would like to clarify that the issue persists only with a specific file. Despite using the latest version, the problem remains unresolved. For your reference, I have attached the test file in question.

Please investigate this further and let me know if you require any additional information to resolve the issue.

sivalasanthosh
 
Posts: 5
Joined: Fri Mar 22, 2024 1:07 pm

Wed Jun 05, 2024 3:26 am

Hello,

Thanks for your reply.
I'm sorry, I have checked the forum and email, and did not find the test file you provided. There may be some problems with the network or system. Could you please try to send it again? I will check it immediately. Thank you very much for your understanding and cooperation.

Sincerely
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Wed Jun 05, 2024 6:47 am

Hi William,

Thank you for your prompt response.

I apologize for any inconvenience. I have just sent the test file to the support email at support@e-iceblue.com. Please check and let me know if you encounter any further issues.

Thank you for your understanding and cooperation.

Best regards,

sivalasanthosh
 
Posts: 5
Joined: Fri Mar 22, 2024 1:07 pm

Wed Jun 05, 2024 6:57 am

Hello,

Thanks for your file.
I used the file you provided to test and reproduce the issue you mentioned. I have logged this problem in our tracking system with the ticket SPIREPPT-2534. Our dev team will further investigate and fix it. If there is any progress, I will inform you as soon as possible. Sorry for the inconvenience caused to you.

Sincerely
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Thu Jul 11, 2024 1:30 am

Hello,

Thank you for your patience.
Glad to inform that we just released Spire.Presentation Pack Hotfix Version:9.7.4 which fixed the issue of SPIREPPT-2534, welcome to test it.
Website link: https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link: https://www.nuget.org/packages/Spire.Presentation/

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.Presentation

cron