Skip to main content
Solved

Need help to resolve "Could not load file or assembly itextsharp" dll error

  • September 30, 2024
  • 4 replies
  • 166 views

Forum|alt.badge.img

Hello,

we are receiving a pdf of 2 pages from external application, so we would like to import only first page of it, so we are trying to use itext sharp to achieve this. we added reference using Nuget manger, we are getting below error when we trying to process it.
 

Could not load file or assembly 'itextsharp, Version=5.5.13.4, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' or one of its dependencies. The system cannot find the file specified.


Please have a look at below code.

using (MemoryStream memoryStream = new MemoryStream(data))
{
    PdfReader reader = new PdfReader(memoryStream);

    using (MemoryStream outputStream = new MemoryStream())
    {
        Document document = new Document(reader.GetPageSizeWithRotation(1));
        PdfCopy writer = new PdfCopy(document, outputStream);

        document.Open();
        PdfImportedPage page = writer.GetImportedPage(reader, 1);
        writer.AddPage(page);
        document.Close();
        
        PX.SM.FileInfo info = new PX.SM.FileInfo("file.pdf", (string)null, outputStream.ToArray());
        instance.SaveFile(info, FileExistsAction.CreateVersion);
        PXNoteAttribute.SetFileNotes(Graph.Document.Cache, Graph.Document.Current, info.UID.Value);    
    }
}

Best answer by hdussa

Hello @ckwiat46 ,

 

Try installing the BouncyCastle v 2.4.0 or greater dll and check if it works.

View original
Did this topic help you find an answer to your question?

4 replies

hdussa
Jr Varsity I
Forum|alt.badge.img
  • Jr Varsity I
  • 99 replies
  • September 30, 2024

Hello @ckwiat46 ,

 

See if the dependent DLL BouncyCastle.Cryptography available in the BIN directory.
 

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 44 replies
  • October 1, 2024

Hello @hdussa, we don’t have BouncyCastle.Cryptography dll in BIN folder.


hdussa
Jr Varsity I
Forum|alt.badge.img
  • Jr Varsity I
  • 99 replies
  • Answer
  • October 1, 2024

Hello @ckwiat46 ,

 

Try installing the BouncyCastle v 2.4.0 or greater dll and check if it works.


hdussa
Jr Varsity I
Forum|alt.badge.img
  • Jr Varsity I
  • 99 replies
  • October 9, 2024

@ckwiat46 , hope it worked after installing the mentioned dependencies.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings