Skip to main content

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);    
    }
}

Hello @ckwiat46 ,

 

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

 


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


Hello @ckwiat46 ,

 

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


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


Reply