locked
How to covert c library to c sharp library RRS feed

  • Question

  • User1867032655 posted

    Hi:

    I meet a problem and hope to fix it. I hope to using WkHtmlToPdf to covert html to pdf, 

    however it is write in c, and it is opensource. 

    I hope to write a project to cover c function to c sharp, that means i hope to 

    write a c sharp library and it enclosed the WkHtmlToPdf , and when I want to use it 

    in asp.net, just use using WkHtmlToPdfInCsharpNameSpace;

    it may be like 

    C sharp function:

    HtmltoPdf(docutment html, location pdf)

    {

    }

    c function:

    wkthmltopdf()

    {

    }

    I know some infors about managed code, but don't know to do that,

    is anyone knows how to do that, any instruction is highly appreciate,

    thanks a lot. 

    Friday, February 17, 2017 4:13 AM

Answers

  • User-821857111 posted

    There are no tools available for converting C into C#.  Therefore if you want a C# version, you will have to write it yourself. The good news however is that there is already a .NET wrapper for WkHtmlToPDF available here: https://github.com/gmanny/Pechkin

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 17, 2017 7:51 AM

All replies

  • User-821857111 posted

    There are no tools available for converting C into C#.  Therefore if you want a C# version, you will have to write it yourself. The good news however is that there is already a .NET wrapper for WkHtmlToPDF available here: https://github.com/gmanny/Pechkin

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 17, 2017 7:51 AM
  • User1867032655 posted

    why we can't use cli to cover c into managed codes, and using this dll to write the c #. 

    I found some codes like following:

    https://www.codeproject.com/Tips/695387/Calling-Csharp-NET-methods-from-unmanaged-C-Cplusp

    that is great, but i need the inverse way to meet, 

    I believe this can be made, since this is the managed codes issue.

    is there other example or some data can help to do that, thanks.

    Saturday, February 18, 2017 2:30 AM
  • User-821857111 posted

    i need the inverse way to meet, 

    I believe this can be made

    Yes - I posted a link to a C# library that enables calls to be made to WkHtmlToPdf. Did you look at it?

    Saturday, February 18, 2017 6:35 PM
  • User1867032655 posted

    I download Pechkin-master, but can not open Pechkin.sln directly by vs2012, 

    and there seems no manual and other instructions about that.

    It becomes difficult to analyse it. Is there any way can help to make that, 

    thanks a lot.

    Monday, February 20, 2017 5:17 AM
  • User753101303 posted

    Hi,

    Another option is to call DLL functions from C# rather than to fully rewrite the library in C#. Try maybe https://github.com/pruiz/WkHtmlToXSharp

    Monday, February 20, 2017 8:55 AM
  • User1867032655 posted

    I read the its CURRENT STATUS & LIMITATIONS, and found it may not suitable to 64bit.

    My environment is 64 bit, and many people may use this function on web at the same time.

    In this situation, is the package still can run well?

    Also, I checking and searching some info about pechkin,  since wkhtmtopdf library are 

    still in improved, but pechkin is stopped from 5 years ago, is it still suitable to download that, 

    and then replace the latest dll of wkhtmtopdf, 

    thanks a lot.

    Wednesday, February 22, 2017 2:02 AM
  • User-707554951 posted

    Hi abramhum,

    The first answer in this thread (from Mike, a MVP) is a good answer. There is no tools can convert C to C# automatically. But you could reference the library which write by C, and call the methods in it by C#. You can find answers in here:

    http://stackoverflow.com/questions/9093292

    Best regards

    Cathy

    Tuesday, March 7, 2017 9:06 AM