Hello,
For one of our project requirements, We are merging files using PDF byte arrays. While performing this operation, we came across one exception by which file is not getting merge.
We are working on sensitive client data, so we are not able to share this file with you.
Please find the exception detail for your reference.
at Spire.Pdf.Widget.PdfChoiceWidgetFieldWidget.get_SelectedItem()
at Spire.Pdf.Widget.PdfComboBoxWidgetFieldWidget.GetFontHeight(PdfFontFamily family)
at Spire.Pdf.Widget.PdfStyledFieldWidget.ᜀ(String A_0, Boolean& A_1)
at Spire.Pdf.Widget.PdfStyledFieldWidget.get_Font()
at Spire.Pdf.Widget.PdfStyledFieldWidget.GraphicsProperties..ctor(PdfStyledFieldWidget fieldWidget)
at Spire.Pdf.Widget.PdfStyledFieldWidget.GetGraphicsProperties(GraphicsProperties& graphicsProperties, PdfFieldWidgetItem widgetItem)
at Spire.Pdf.Widget.PdfComboBoxWidgetFieldWidget.ᜀ(PdfCanvas A_0, PdfFieldWidgetItem A_1)
at Spire.Pdf.Widget.PdfComboBoxWidgetFieldWidget.ᜀ(spr A_0, PdfFieldWidgetItem A_1)
at Spire.Pdf.Widget.PdfComboBoxWidgetFieldWidget.BeginSave()
at Spire.Pdf.Fields.PdfForm.ᜀ()
at Spire.Pdf.Fields.PdfForm.Dictionary_BeginSave(Object sender, sprᤞ ars)
at spr .ᜀ(sprᤞ A_0)
at spr .ᜀ(sprᢅ A_0, Boolean A_1)
at spr .ᜀ(sprᢅ A_0)
at sprᴜ.ᜀ(sprᢺ A_0, sprᯆ A_1)
at spr.ᜁ(sprᢺ A_0, sprᯆ A_1, sprម A_2)
at spr.ᜀ(sprᢺ A_0, sprម A_1)
at spr.ᜄ(sprម A_0)
at spr.ᜅ(sprម A_0)
at Spire.Pdf.PdfNewDocument.Save(Stream stream)
at Spire.Pdf.PdfDocumentBase.Save(String filename)
at Spire.Pdf.PdfDocument.SaveToFile(String filename)
at MergeFilesInPDFApp.Program.MergePdfBytes(String strFilePath, Dictionary`2 sourceFiles)
Can you please let us know why this error occurred (root cause of this error) as we have checked this PDF file and it is opening without any error?
We have tried several other methods, but same error occurred.
Code Base
public static void MergePdfBytes(string strFilePath, Dictionary<string, byte[]> sourceFiles)
{
FileInfo licenseFile = null;
PdfDocument docs = null;
string SpireLicensePath = null;
try
{
SpireLicensePath = System.Reflection.Assembly.GetEntryAssembly().Location.Replace("MergeFilesInPDFApp.exe", "license.elic.xml");
licenseFile = new FileInfo(SpireLicensePath);
Spire.License.LicenseProvider.SetLicenseFile(licenseFile);
docs = new PdfDocument();
foreach (var file in sourceFiles)
{
try
{
docs.AppendPage(new PdfDocument(file.Key));
}
catch (System.ArgumentException exArgumentException)
{
throw exArgumentException;
}
catch (Spire.Pdf.Exceptions.PdfException exInvalidPdfException)
{
throw exInvalidPdfException;
}
catch (System.IO.FileNotFoundException exFileNotFoundException)
{
throw exFileNotFoundException;
}
catch (Exception exException)
{
throw exException;
}
}
docs.SaveToFile(strFilePath);
docs.Close();
}
catch (Exception exException)
{
throw exException;
}
}
Thanks in Advance