Here’s my program code.
public DataResult PDFToExcel(Stream pdfStream)
{
try
{
// For complete examples and data files, please go to GitHub - aspose-pdf/Aspose.PDF-for-.NET: Aspose.PDF for .NET examples, plugins and showcase projects
// Load PDF document
Document pdfDocument = new Document(pdfStream);
// Instantiate ExcelSave Option object
ExcelSaveOptions excelSave = new ExcelSaveOptions
{
Format = ExcelSaveOptions.ExcelFormat.XLSX
};
Stream memoryStream = new MemoryStream();
// Save the output in XLS format
pdfDocument.Save(memoryStream, excelSave);
memoryStream.Seek(0, SeekOrigin.Begin);
return Response("success", memoryStream);
}
catch (Exception ex)
{
var errorMsg = ex.InnerException?.Message ?? ex.Message;
_logger.LogError(ex, errorMsg);
return ResponseFail<Stream>(ResultCode.Failure, $"error:{errorMsg}");
}
}
The above code runs on .net core docker and my docker is running on k8s, this is the specific error:
System.InvalidCastException: Unable to cast object of type ‘#=zmWCn2hKA3CIXtZRU76vP1mvpmInP’ to type ‘#=ziOrDBLnvbbNgWmbJ1qAp6Yo10Cny’.
at #=zu2sxpv2fvNrD0Fcc1AziXgkFfZRCWHN2mmDZv3muUf1uSmDsdw==.#=zZ2_LFS4=(#=zEY_qrUhu7GgKflOaboPf_CxhPmMlGGOgTUD_3Rp1HnxY #=zx9_GDlA=, #=z_9ObQQ9GU3KJNKcr2VBtGVWkJHjRlNtxJ4tGzZoU7nje #=zEv23CvPwGgq_, #=zjH3VutoxAH1gxdWjdCYBTMnvMgR1GnWRuQ== #=zhElZpiw=)
at #=zpoCIzLoo22z6wbrgExMYb$KyvUklTErmx9ac$4IUb7IQeEYNwg==.#=zZ2_LFS4=(#=zEY_qrUhu7GgKflOaboPf_CxhPmMlGGOgTUD_3Rp1HnxY #=zx9_GDlA=, #=z_9ObQQ9GU3KJNKcr2VBtGVWkJHjRlNtxJ4tGzZoU7nje #=zEv23CvPwGgq_)
at #=zdiGXry6g1aGRA7ztT4ArNpOKjD5r06sOj64gzBdtiPYH.#=zVD4xjEqA7k39oF4$UA==(#=zEY_qrUhu7GgKflOaboPf_CxhPmMlGGOgTUD_3Rp1HnxY #=zx9_GDlA=, List`1 #=zX$TIQxw=)
at #=zdiGXry6g1aGRA7ztT4ArNpOKjD5r06sOj64gzBdtiPYH.#=zpjnTk6uYBh8SKFdjYw==(#=zEY_qrUhu7GgKflOaboPf_CxhPmMlGGOgTUD_3Rp1HnxY #=zx9_GDlA=, List`1 #=zX$TIQxw=)
at #=zdiGXry6g1aGRA7ztT4ArNpOKjD5r06sOj64gzBdtiPYH.#=zBtEHN5cF9Gnv(#=zEY_qrUhu7GgKflOaboPf_CxhPmMlGGOgTUD_3Rp1HnxY #=zx9_GDlA=, List`1 #=zKTK0QrGoLhFk)
at #=zdiGXry6g1aGRA7ztT4ArNpOKjD5r06sOj64gzBdtiPYH.#=zY33Rxf0=(#=zgmpzBr5E4mUNqQIChjjooO5$ASnb #=zy2FjaQI=, #=zx82ezowH0Xee1wDhSFKmcmCfG0MBUodzLQ== #=zi5nCRvI=, #=zEY_qrUhu7GgKflOaboPf_CxhPmMlGGOgTUD_3Rp1HnxY #=zx9_GDlA=)
at #=z3RSmZMrT5XqnhTdVTTcDT0y1_r4UT2h3vg==.#=z7EEB5Wo=(Int32 #=zQRstDHA=, IList`1 #=zw3Ls68$SaQXf5_Zp2g==, #=zptVjF6v5G6n5 #=z0va1Nhk=)
at #=z3RSmZMrT5XqnhTdVTTcDT0y1_r4UT2h3vg==.#=zY33Rxf0=()
at #=zT2Ow131pqzmsmw0e0PE38MbTBWQf.#=z0hdQ5OaYxfDM(Document #=zy2FjaQI=, #=zEY_qrUhu7GgKflOaboPf_CxhPmMlGGOgTUD_3Rp1HnxY& #=zXodTf2wofT5NbSXNDA==, UnifiedSaveOptions #=z5hrkyKQ=, Int32& #=zT3Djtd6Aig$L, Boolean #=z_XT3xy8=)
at (Object , Object[] )
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zCJr_MS9XhiKCsoWtyJ6v6OEM4V2sDFdgmp8pFJQG8EXr(MethodBase #=zKSoKMrk=, Object #=zOTPrY2g=, Object[] #=z9UUCT6k=, Boolean #=z9N7$HEg=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zK0ZVn3zSXS0kmTvhqTUn4uA=(MethodBase #=zKSoKMrk=, Boolean #=zOTPrY2g=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zzhyYsfNCca628nDn18SjFjP0v$ywkFT54A==(dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd #=zKSoKMrk=, #=qz9TAnh49TmacE35eCTCbqlJRURXx9QUfAf6SDvR92XY= #=zOTPrY2g=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zwEN0KP3LXfNoPrwGlZD5n98sQQ4Z()
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zUu2HFFG3i2IBHnBuLiLzIUOquzNu(Boolean #=zKSoKMrk=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zW2MPZUd7WbviYlDR5z7FutQCEiuW(Object #=zKSoKMrk=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zbfVQrBSmGLNfwe$HEXMhOgongv8x()
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zSbRF8PM$atNXB1aqD1geaN1aXV1MgZz2Sg==(dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd #=zKSoKMrk=, #=qz9TAnh49TmacE35eCTCbqlJRURXx9QUfAf6SDvR92XY= #=zOTPrY2g=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zwEN0KP3LXfNoPrwGlZD5n98sQQ4Z()
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zUu2HFFG3i2IBHnBuLiLzIUOquzNu(Boolean #=zKSoKMrk=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zW2MPZUd7WbviYlDR5z7FutQCEiuW(Object #=zKSoKMrk=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zbfVQrBSmGLNfwe$HEXMhOgongv8x()
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zHlvWQbr_2Pk4mBZ2GI__$d6yeaj2EraCvWCZV2Y=(Object #=zKSoKMrk=, UInt32 #=zOTPrY2g=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zUu2HFFG3i2IBHnBuLiLzIUOquzNu(Boolean #=zKSoKMrk=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zUu2HFFG3i2IBHnBuLiLzIUOquzNu(Boolean #=zKSoKMrk=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zl6jdZPlGZEs8qS8NIcRc_YP3Z_H85YfL9cEFaUooF1Ju(Object[] #=zKSoKMrk=, Type[] #=zOTPrY2g=, Type[] #=z9UUCT6k=, Object[] #=z9N7$HEg=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=zU_rum6gpZd7Z$BDGdGwtBXQ=(Stream #=zKSoKMrk=, String #=zOTPrY2g=, Object[] #=z9UUCT6k=)
at dje_q78LM69JS4CVSF2R6JL8KZGUUP7YP3DYBGW6V3M2KJACT78E8SYVQ_ejd.#=z2R_cVK$cpyvs17iCM_z33A98BsdQ(Stream #=zKSoKMrk=, String #=zOTPrY2g=, Object[] #=z9UUCT6k=)
at #=zlZ2ItNPSHOPMq4aJpmE1T7w=.#=zZOpnVCjHuSn2(Document #=zm297MmY=, Stream #=zuiqYUWVzqAV4, ExcelSaveOptions #=zpkt4alICPG0gZp1uew==, DocSaveOptions #=z5KrpuKZOc3bi)
at Aspose.Pdf.Document.#=zmvX$N7oYZDhQ(Stream #=z6BDSKp7qdcra, SaveOptions #=z5hrkyKQ=)
at Aspose.Pdf.Document.#=zsPmlSip57Sqk(Stream #=zLKKKe2xL3H3i, SaveOptions #=z5hrkyKQ=)
at Aspose.Pdf.Document.Save(Stream outputStream, SaveOptions options)
When using Aspose.PDF in Python and .net, I encountered the same error, which works fine on windows but occurs on linux, what is the reason and how to solve this problem?