Txt to pdf conversion issue

When trying to convert txt file using below code snippet I get this exception:


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





using (var fileStream = new FileStream(@“c:\aa\test.txt”, FileMode.Open))


{


using (var sr = new StreamReader(fileStream, Encoding.UTF8))


{


string line;


var pdf = new Aspose.Pdf.Generator.Pdf();


pdf.PageSetup.PageHeight = Aspose.Pdf.Generator.PageSize.A4Height;


var section = pdf.Sections.Add();




while ((line = sr.ReadLine()) != null)


{


var paragraph = new Aspose.Pdf.Generator.Text(section, line);


section.Paragraphs.Add(paragraph);


}


var b = pdf.GetBuffer();


}


}





I’m using the latest Aspose dlls available for .NET 3.5 (17.1.0.0)



Edit: The same happens when converting tif, png, jpg, gif or bmp to pdf.





Best regards,

Bartek

Hi Joao,


Thanks for contacting support.

I used your code snippet to convert .txt File into PDF. I am sorry but I didn’t notice any issue. It generated correct output without throwing any exception. However I am afraid that you are using old Aspose.Pdf.Generator approach. That approach is going to be obsolete soon and we are not providing support or resolving issues regarding Aspose.Pdf.Generator. We strongly recommend to use new Document Object Model approach of Aspose.Pdf.

For document conversion using new DOM approach you can check our “Convert a File to PDF Format” example in API docs. In case if you still face any issue please share details along with your input file.

Best Regards,

Hi,

Thank you for your answer.

Please make sure you test it with .NET 3.5

I did a few tests and the issue occurs also for Aspose.Pdf.dll 16.12.0.0.

It works fine with Aspose 16.10.0.0 and before.



Best regards,
Bartek

Hi Bartek,



I am sorry but I used your code snippet with target framework set to 3.5 and it executed just fine. Moreover we always recommend to use latest version of our API. We will really appreciate if you run a test scenario using new DOM approach and latest version of our API. In case if you still face any issue please share details with us along with your input file(s). We will further investigate the issue and update you.

Best Regards,

Hi,





using new DOM approach also throws an exception. I noticed that when referencing dll from path and Aspose.Pdf.dll is not present in GAC it works fine. When it is deployed to GAC (the only Aspose dll) issue comes back.





/Bartek

Hi Bartek,


Thanks for sharing details. I have tested the scenario by adding Aspose.Pdf.dll from GAC but I am sorry I was still unable to replicate the issue at my side. I have used same code snippet you shared earlier and set the framework version to 3.5 as well. We will really appreciate if you please share a sample project so that we can try to replicate the issue in our environment. We are sorry for the inconvenience.

Best Regards,

DOM approach:



using (var tr = new StreamReader(@“c:\aa\test.txt”))


{


var doc = new Document();


Page page = doc.Pages.Add();


string line;


while ((line = tr.ReadLine()) != null)


{


var text = new TextFragment(line);


page.Paragraphs.Add(text);


}




doc.Save(@“c:\aa\TexttoPDF_out.pdf”);


}





gives similar exception:


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



We have verified that Aspose.Pdf.dll refers both: Aspose.HtmlOld.dll and Aspose.Font.dll.


Both issues occur only if Aspose.PDF.dll is deployed to GAC (if not and dll is taken from disc then conversion works fine).


Tested in LINQPad 2.45.05


Issue occurs also in web app (w3wp process .NET 3.5).


I enclose script used for tests.

Hi Bartek,


Thanks for sharing the details.

I have tested the scenario in Visual Studio 2015 web application with target framework as 3.5 running over Windows 10(x64) and I am unable to notice any issue. For your reference, I have also attached the sample project. Can you please share some further details regarding your operating system and any information which can help us in reproducing this issue in our environment. We are sorry for this inconvenience.

I got the same exception using your project (VS2010).


Reproduced on 2 different boxes.


I attach system information of our boxes.

Hi Joao,


Thanks for your patience and sharing more details.

I tried your scenario by adding Aspose.Pdf reference from GAC in VS2010 with target framework version 3.5 and noticed that it threw exception. Please note that I have tested the scenario using new DOM approach as previously shared that we are not resolving issue regarding old (Aspose.Pdf.Generator) approach.

Therefore for the purpose of further investigation I have generated a ticket as PDFNET-42259 in our issue tracking system. We will further look into the details of the issue and keep you updated on the status of its resolution. Please be patient and give us a little time. We are sorry for the inconvenience.

Best Regards,

Hi,


Is release date with the fix already known? I’d like to inform client about delivery time.



Best regards,

Bartłomiej Chojnowski

Hi Bartłomiej,


Thanks for contacting support.

I have checked the status of the logged issue and I am sorry that it is still pending for a fix. I would like to share that there are other reported issues in the queue prior to this. I am sure that Product Team will definitely plan to provide a fix according to their schedule. However I am afraid that we cannot provide any release date with the fix at this time. We really appreciate your patience in this regard. We will keep you updated when we have any definite update about the fix.

We are sorry for the delay and inconvenience.

Best Regards,

Hi Asad,


We’re having the same issue and we’re very interested in a resolution, but there’s been no updates to this thread forfour months now. Are you any closer to providing a fix?

Hi Jonas,


Thanks for your inquiry.

I have tested the scenario using latest version of the API which is Aspose.Pdf for .NET 17.6 and was unable to observe the earlier mentioned issue. I believe that issue has been resolved in latest release of the API, so please try using latest version of the API and in case if you still face any issue please feel free to contact us.


Best Regards,