Free Support Forum - aspose.com

Error when merging pdf documents

Hi,
When I merge pdf files using firstpdf.Pages.Add(secondpdf.Pages) I get this error:

can not read the file or assembly Aspose.Font, Version = 17.1.0.0, Culture = neutral, PublicKeyToken = 716fcc553a201e56 or one of its dependencies. The system can not find the specified file.

Thanks in advance.

Hi Per,


Thanks for contacting support.

We will really appreciate if you please share the input file(s) and code snippet you are using so that we can test the scenario in our environment.

We are sorry for the inconvenience.

Hi,
Let me give you some more information.

The problem happens in a web application (ASP.NET).
I convert Word and Excel files to PDF using Aspose.Words and Aspose.Cells, and then I merge them with Aspose.Pdf

But now I tried the same code but in an console application with no errors.

Attached is the PDF files and this is the method that merges the files.

private void MergeDocuments()
{
string[] files = Directory.GetFiles( outputDir );
int i = 0;
Aspose.Pdf.Document pdf = new Aspose.Pdf.Document( files[ 0 ] );

foreach ( string file in files )
{

if ( i == 0 )
{
i++;
continue;
}

Aspose.Pdf.Document addPdf = new Aspose.Pdf.Document( file );

try
{
LoggerUtility.WriteInfo("", “”, “Adding " + addPdf.Pages.Count.ToString() + " pages”);
pdf.Pages.Add( addPdf.Pages );
LoggerUtility.WriteInfo("", “”, “Adding " + file);
}
catch ( Exception ex )
{
LoggerUtility.WriteError(“Pages.Add”, “”, ex, LoggerUtility.LogType.Error);
}
}

LoggerUtility.WriteInfo(”", “”, "Pages: " + pdf.Pages.Count.ToString());

pdf.Save( Path.Combine( outputDir, “KMA Pärm.pdf” ) );
}

Hi Per,


Thanks for sharing details and input file(s). I used your code and input file(s) in web application (ASP.NET) but I am sorry I was unable to get any exception. It generated the output file without throwing any exception. You may check the following code snippet which I used and attached output file.

private void MergeDocuments()<o:p></o:p>

{

string[] files = Directory.GetFiles(Server.MapPath("Data/Test/"));

int i = 0;

Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(files[0]);

foreach (string file in files)

{

if (i == 0)

{

i++;

continue;

}

Aspose.Pdf.Document addPdf = new Aspose.Pdf.Document(file);

pdf.Pages.Add(addPdf.Pages);

}

pdf.Save(Path.Combine(Server.MapPath("Data/Test/"), "KMA Pärm.pdf"));

}


Moreover, please make sure that you are using valid license and double check that all necessary dll(s) are present in the bin folder of the web application. In case if you still face issue please share details with us i.e OS Version you are running application on, Target Framework of the Application.

Best Regards,

Hi again,

Thanks for investigating this.

I have a valid license, bought it a week ago.
All dlls are present in bin folder.
OS in my dev. environment is Windows 7 64 bit.
Application is targeting .Net framework 3.5, and I have tested to use both Aspose.Pdf 2.0 and 3.5 with the same error.

Best regards,
Per

Hi Per,


Thanks for your patience and sharing details with us. I tested the scenario with your code snippet and input file(s) in an ASP.NET web application (Framework Version 3.5) and I managed to replicate the issue at my side. Therefore, I have logged this issue as PDFNET-42202 in our issue tracking system. We will further investigate the issue and keep you updated on status. Please have patience and spare us a little time. We are sorry for the inconvenience.

Best Regards,

Good to hear that you could replicate the issue.
Looking forward to hear from you as I have a deadline approaching.

Per

Hi Per,


Thanks for contacting support.

As soon as we have some definite updates regarding earlier reported issue, we will let you know. Please be patient and spare us little time.

Hi,
Sorry if I nag, but do you have any information regarding the issue PDFNET-42202?
If not, I need to know so I can look for another solution that works.

Best Regards,
Per

Hi Per,


Thanks for your patience.

I have tried to run the complete scenario with the latest version of Aspose.Pdf for .NET which is 17.2.0.0 and I did not face any issue in merging the documents. I have run the scenario in Web Application with target framework 3.5.

Please try merging the documents using latest version of our API which can be downloaded from here. In case if you still face any issue please feel free to contact us.


Best Regards,

Hi,
Thanks for your reply, but I’m still having the same error.
I have downloaded version 17.2.00 and target framework is 3.5.

Regards,
Per

Hi Per,


Thanks for contacting support.

As shared earlier I have tried the same scenario which was previously causing error but with latest version of the API and I did not face any issue at all. Please share that are you using the same file(s) for merging process which have been shared within this thread? I have processed the same file(s) and generated the output.

Please check the attached file which I have generated at my end after merging. If you are using different files to merge then we will really appreciate if you share them so that we can try to test the scenario in our environment. We are sorry for this inconvenience.


Best Regards,

Hi,

Yes, I have tested with the files that I shared earlier in this thread.

Strange that I still have the same error when you successfully merged the files now after having the same error before.
And as you can see in the error message I have version 17.2.0.0 now.

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

I will be working the weekend to see if I can find out why it throws the error, but I don’t know what I can try that I haven’t already tested. If you have any suggestions on what I can try, please do, because I was running out of ideas and time is running out for me.

Regards,
Per

Hi Per,


Thanks for your patience. I have again tested the whole scenario with ASP.NET Web Application (Framework 3.5) in both Visual Studio 2010 and 2015 and I am afraid that I still did not observe any issue. Moreover, we will really appreciate if you please share a sample project (web application) with us. It may help us reproducing the issue in our environment and share our findings with you accordingly.

We are sorry for the inconvenience.


Best Regards,

Hi,
It’s hard for me to share more code than I already did as the web application is a major project management system with connections between several other systems.

As you does not appear to be able to solve my problem, I have to solve it in another way. Either by creating a Windows Service to make the merging or buy another solution.

Seems like I should have evaluated it more before buying our Aspose.Total license.

Regards,
Per

Hi Per,


Thanks for your patience. I have created a sample project for merging the documentation. Please check the attached web application (target framework 3.5). The attached application is running fine and merging documents without generating any issue at my side. Please try running the project in your environment and you may place your license file into Data folder of the project directory. In case if you still face any issue please feel free to let us know. We are sorry for the inconvenience.


Best Regards.

Hi,

Thanks for sharing your code that works in your environment.

But I’m sorry to inform you that I get the same error when using your web application.

I added my license file to the Data folder and run your code, but it throws the same error on row 38 where you call pdf.Pages.Add(addPdf.Pages)

Per

Hi Per,


Thanks for your feedback. I am testing the scenario on other operating systems and will get back to you shortly.


Best Regards,

Hi Per,


Thanks for your patience.

I have tested the scenario on different operating systems i.e Windows 10 64-bit and Windows 7 64-bit and I am afraid that I was unable to notice any issue. It seems your environment specific issue. It would be kind of you if you please try to test the shared project on any other machine or in different environment and share details with us. It will really help us in understanding the problem and address it accordingly. We are sorry for the inconvenience.


Best Regards,

Hi,

I have seen that I’m not the only one with the same error, see PDFNET-42288.

I have tested on Win 7 Enterprise SP1 64-bit and Win Server 2008 R2 Standard SP1 64-bit.
IIS 7 on both machines.

We are also running SharePoint 2010 sites on the machines, can that cause the issue?

// Edit
Now I tested on a Win 2008 R2 machine that doesn’t have SharePoint installed, and on that machine it works.

Per