Hello
for an application, we must convert files pdf in pptx with slides as images, so use the property PptxSaveOptions.SlidesAsImages at true. When we try to convert, get the follow error:
Call Stack: System.ArgumentException:
Message: #=z0kjuHklPVx1p7MyE071VPC0= : #=z0kjuHklPVx1p7MyE071VPC0= : #=zKCMc633_JHL014AUdvLQ4MQ= : The given key ‘-1’ was not present in the dictionary.[ at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at #=zIVglVMlQ8dYPsDPKj2g5CKY=.#=zbQqByrI=(String #=zoBE15hw=, #=zQzxK6fA8bKaD2PjSq42lvb_Rqk93 #=zEmMxCZY=, #=zx5qFH06RVQz30_779do0KhSomxZI #=zAotEZvY=, #=z7C3s3X7XZGZKwDWPDHDn9oeJINk7 #=zpywnD1A=)
at #=zMPxL4_b4ynWaRY$afxePwdhKs0WmWoNmXg==.#=zGS1B9iYfi2ux(#=zKCMc633_JHL014AUdvLQ4MQ= #=zhkuRsPsFXJs_, Int32 #=zfc2Fig0=, #=z8CTYAuVkYMdzxjRTP8bT3hsAeSD7 #=zI4zSSWQ=)
at #=zMPxL4_b4ynWaRY$afxePwdhKs0WmWoNmXg==.#=zGS1B9iYfi2ux(#=zKCMc633_JHL014AUdvLQ4MQ= #=zhkuRsPsFXJs_, Int32 #=zfc2Fig0=)
at #=zyZwhf2c4IgZbjYM0JZTyWOW1Z6be.#=zqx1IlKk=(#=zKCMc633_JHL014AUdvLQ4MQ= #=zhkuRsPsFXJs_)
at #=zKCMc633_JHL014AUdvLQ4MQ=.#=zxyX4WjI=(#=zht7tAI$e7xIBUGgZYBHFHZu_P2yN #=z5nEKl5k=)
at #=zBWNUMPVMS9GUvnQcfdyEvHCWilEh.#=zxyX4WjI=(#=zht7tAI$e7xIBUGgZYBHFHZu_P2yN #=z5nEKl5k=)][ at #=zBWNUMPVMS9GUvnQcfdyEvHCWilEh.#=zxyX4WjI=(#=zht7tAI$e7xIBUGgZYBHFHZu_P2yN #=z5nEKl5k=)
at #=z0kjuHklPVx1p7MyE071VPC0=.#=zxyX4WjI=(#=zht7tAI$e7xIBUGgZYBHFHZu_P2yN #=z5nEKl5k=)
at #=zBWNUMPVMS9GUvnQcfdyEvHCWilEh.#=zxyX4WjI=(#=zht7tAI$e7xIBUGgZYBHFHZu_P2yN #=z5nEKl5k=)][ at #=zBWNUMPVMS9GUvnQcfdyEvHCWilEh.#=zxyX4WjI=(#=zht7tAI$e7xIBUGgZYBHFHZu_P2yN #=z5nEKl5k=)
at #=z0kjuHklPVx1p7MyE071VPC0=.#=zxyX4WjI=(#=zht7tAI$e7xIBUGgZYBHFHZu_P2yN #=z5nEKl5k=)
at #=zBWNUMPVMS9GUvnQcfdyEvHCWilEh.#=zxyX4WjI=(#=zht7tAI$e7xIBUGgZYBHFHZu_P2yN #=z5nEKl5k=)]
We are using Aspose.Pdf Version=25.1.0.0 with the follow code:
using var document = new Document(pdfStream);
var msPptx = new MemoryStream();
var pptxOptions = new PptxSaveOptions
{
SlidesAsImages = true,
IsMultiThreading = true,
};
document.Save(msPptx, pptxOptions); // here throw the exception
@ABeghini
It seems you are encountering an ArgumentException
when trying to convert a PDF to PPTX format with slides saved as images using Aspose.PDF. This error typically indicates that there is an issue with the data being processed, possibly related to the specific content of the PDF or the configuration of the conversion options.
Here are a few steps you can take to troubleshoot and potentially resolve the issue:
-
Check PDF Content: Ensure that the PDF you are trying to convert does not contain any unsupported elements or corrupted data. Sometimes, specific content types can cause issues during conversion.
-
Update Aspose.PDF Version: You are using version 25.1.0.0. It might be beneficial to update to the latest version of Aspose.PDF, as newer versions often include bug fixes and improvements that could resolve your issue.
-
Simplify the Conversion: Try converting a simpler PDF file to see if the issue persists. This can help determine if the problem is with the specific PDF you are using or with the conversion process itself.
-
Use Basic Conversion Options: Temporarily remove the SlidesAsImages
option and see if the conversion works without it. This can help isolate whether the issue is related to that specific setting.
-
Review Example Code: You can refer to example code provided in the Aspose documentation for converting PDF to PPTX. Here’s a simplified version of how to set up the conversion:
using System.IO;
using Aspose.Pdf;
// Load PDF document
using var document = new Document("path/to/your/input.pdf");
var pptxOptions = new PptxSaveOptions
{
SlidesAsImages = true,
IsMultiThreading = true,
};
using var msPptx = new MemoryStream();
document.Save(msPptx, pptxOptions);
If the problem persists after trying these steps, consider reaching out to Aspose support with details about the PDF file and the exact error message for further assistance.
Sources:
[1]: PDFToPPT.cs
The problem occurs only on specific files, to be more accurate attach an file that present the problem.
Moreover if i remove or set the property SlidesAsImages to false, the new file pptx is converted.
I’am using the last version of Aspose.PDF, 25.1.0.0
RACI Responsibility Charting_exercise.pdf (1,5 MB)
@ABeghini
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-59162
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.