1

我是 Aspose PDF 的新手。我不明白为什么我会收到此交叉引用错误。将图像添加到 pdf 文件时会发生这种情况。

下面是代码示例。

// Gets the image file to be merged with the document
var b1 = GetDocumentFile(imageLayer.UNIQUE_ID);
if (b1.File.DocumentLayer?.PAGE_NUMBER != null)
{
    var i = b1.File.DocumentLayer.PAGE_NUMBER.Value;
    var pngBin = EFSUtil.ReadFileFromFileServer(b1.File.FullFilePathAndName, b1.Server);

    pngBin = CheckIfWebPAndProcess(pngBin);

    //open document based ont eh stream
    var pdfDocument = new Document(pdfMemoryStream);
    var rect = pdfDocument.Pages[i].GetPageRect(true);
    pdfDocument.Pages[i].AddImage(new MemoryStream(pngBin), rect); <-- Error hit here

    var bMemStrm = new MemoryStream();
    pdfDocument.Save(bMemStrm);
    pdfMemoryStream = bMemStrm;
}

我试图获取一些有价值的信息,说明为什么会发生错误,AddImage()并且我还尝试了解错误发生的原因以及如何解决它,但没有成功。我能找到的最近的是这些链接。

处理图像

页面类

我希望你能帮我解决这个问题。谢谢

更新

不确定这是否有帮助,但这是在 AddImage 中发生问题时的堆栈跟踪

   at   .   ​()
   at   .(Int32 , Int32& )
   at   .   ​(Int32 )
   at ​  .(Int32 )
   at Aspose.Pdf.OperatorCollection.79au5vc3bv4m9r8vf6tce224vh3rwyeh ​()
   at Aspose.Pdf.OperatorCollection.(IList )
   at Aspose.Pdf.OperatorCollection.(IList ,  )
   at Aspose.Pdf.OperatorCollection.(List`1 )
   at Aspose.Pdf.OperatorCollection.Add(ICollection ops)
   at Aspose.Pdf.Page.(Stream , Rectangle , Matrix , CompositingParameters , Boolean , Boolean ,   &amp; )
   at Aspose.Pdf.Page.(Stream , Rectangle , Matrix , CompositingParameters ,   &amp; )
   at Aspose.Pdf.Page.AddImage(Stream imageStream, Rectangle imageRect)
4

1 回答 1

1

我发现我的 PDF 确实有问题。我能够通过此链接验证这一点

3-HEIGHTS™ PDF 验证器在线工具

于 2017-08-02T07:21:49.980 回答