We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cannot load Aspose.Fonts.DLL

Hi,

we’ve find an issue in the method that concatenates streams into pdf:

public Stream MergeDocAndPdf()

{

MemoryStream[] ss = new MemoryStream[2];

MemoryStream output = new MemoryStream();

//test aspose merge between 1 doc and 1 pdf document

using (SPSite siteCollection = new SPSite(“http://webapp/sites/site”))

{

using (SPWeb web = siteCollection.OpenWeb())

{

SPDocumentLibrary lib = (SPDocumentLibrary)web.Lists[“doclib”];

if (lib != null)

{

SPFile fileDoc = lib.GetItemById(1).File;

SPFile filePdf = lib.GetItemById(2).File;

ss[0] = new MemoryStream();

ss[1] = new MemoryStream();

//load doc

using (var stream = fileDoc.OpenBinaryStream())

{

stream.CopyTo(ss[0]);

ss[0].Position = 0;

}

Aspose.Words.Document asposeDoc = new Aspose.Words.Document();

ss[0].Close();

ss[0] = new MemoryStream();

asposeDoc.Save(ss[0], Aspose.Words.SaveFormat.Pdf);

ss[0].Position = 0;

//load pdf

using (var stream = filePdf.OpenBinaryStream())

{

stream.CopyTo(ss[1]);

ss[1].Position = 0;

}

Aspose.Pdf.Document asposePdf = new Aspose.Pdf.Document(ss[1]);

ss[1].Position = 0;

PdfFileEditor pdfEditor = new PdfFileEditor();

pdfEditor.Concatenate(ss, output); //THE ERROR OCCURS HERE

}

}

}

String headerInfo = “attachment; filename=” + “MergeDocAndPdf.pdf”;

WebOperationContext.Current.OutgoingResponse.Headers[“Content-Disposition”] = headerInfo;

WebOperationContext.Current.OutgoingResponse.ContentType = “application/octet-stream”;

return output;

}

the output stream is empty and i see that, in the pdfEditor.LastException, there is an exception in loading Aspose.Font.dll:

Message “Could not load file or assembly ‘Aspose.Font, Version=17.4.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The system cannot find the file specified.”

how can we resolve this?

I’ve see that this errors is already reported in your forum but with no resolution.

Thanks

Hi lechter,


Thanks for contacting support.

I have tested the scenario and have managed to reproduce the issue. This issue has already been logged in our issue tracking system as PDFNET-42378. However currently there are two workarounds for this problem.

1.Do not use assembly.GetTypes(), use assembly.GetExportedTypes() instead.

System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(@“d:\MyApp\References\Aspose.Pdf.dll”);

var types = assembly.GetExportedTypes(); // <-- it works fine now and returns all public exported non-obfuscated classes.


2. Call assembly.CreateInstance(“Aspose.Pdf.Document”); after LoadFrom(), before GetTypes(). Something like this:

System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(@“d:\MyApp\References\Aspose.Pdf.dll”);

assembly.CreateInstance(“Aspose.Pdf.Document”);

var types = assembly.GetTypes(); // <-- it works fine now.


The product team is working on fixing this problem and we hope to get it resolved in next release versions of Aspose.Pdf for .NET. Please be patient and spare us little time.

We are sorry for this inconvenience.

Best Regards,


Hi,

how can i use it inside that code for solve the problem?
Thanks

Hi lechter,

Thanks for your inquiry. You need to implemented an AssemblyResolveHandler within the code. You may write your own AssemblyResolveHandler Event and call it after form load. This way you can ignore assemblies which will not be needed for the execution process of your application/program. As development team is resolving the issue and hopefully, a fix will be included in upcoming version of Aspose.Pdf for .NET, so you can implement this work around for now.

Please check following link for more details on how to implement AssemblyResolveHandler.

https://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve(v=vs.110).aspx

We are sorry for this inconvenience.

Best Regards,

Hi Fahad,

first of all i-m not sure that a link to the msdn is a good way to provide a solution for an issue with your product. By the way, is there a date when you plan to resolve this?

Thanks

Hi Lechter,


Thanks for contacting support.

The reason we have shared the link is to highlight the reasons behind this problem. However the team is working on fixing the issue and it will be resolved in upcoming release versions of Aspose.Pdf for .NET. As soon as the solution becomes available, we will let you know.

Hi Lechter,


Thanks for your patience.

We are pleased to share that the issue reported earlier as PDFNET-42378 is resolved in latest release of Aspose.Pdf for .NET 17.6. Please try using the latest release and in the event of any further query, please feel free to contact.