How to call html to pdf asp.net library from a C++ Native Windows Application.

This is a discussion on How to call html to pdf asp.net library from a C++ Native Windows Application. within the Windows Programming forums, part of the Platform Specific Boards category; First you should register the HiQPdf classes for COM clients and produce a type library file by executing the following ...

  1. #1
    Registered User
    Join Date
    Jul 2012
    Posts
    1

    How to call html to pdf asp.net library from a C++ Native Windows Application.

    First you should register the HiQPdf classes for COM clients and produce a type library file by executing the following command in an Administrator command prompt:

    regasm HiQPdf.dll /tlb:HiQPdf.tlb

    The HiQPdf.tlb will be included in the C++ application code to offer the prototypes for HiQPdf classes and methods. The compiler will produce a C++ header file named HiQPdf.tlh from the TLB file, containing the HiQPdf library types and methods prototypes.

    The HiQPdf.dll and HiQPdf.dep files must be copied near the application executable or otherwise you have to install the HiQPdf.dll in GAC to make it available for COM infrastructure. The C++ code of a simple console application which converts an URL and saves the resulted PDF document to a file on disk looks like below:

    Code:
    #include <windows.h>
    #include <iostream>
    #import "HiQPdf.tlb" raw_interfaces_only
    using namespace HiQPdf;
    int main()
    {
        CoInitialize(0);
    
    
        {
            // create the HTML to PDF converter
            _HtmlToPdfPtr htmlToPdfConverter(__uuidof(HtmlToPdf));
            // get a reference to the PDF document control object from converter
            _PdfDocumentControl * pdfDocumentControl;
            htmlToPdfConverter->get_Document(&pdfDocumentControl);
            // set PDF page orientation
            pdfDocumentControl->put_PageOrientation(PdfPageOrientation_Portrait);
            // set PDF page margins
            _PdfMargins* pdfMargins;
            pdfDocumentControl->get_Margins(&pdfMargins);
            pdfMargins->put_Left(10);
            pdfMargins->put_Right(10);
            pdfMargins->put_Top(10);
            pdfMargins->put_Bottom(10);
            // create the URL to convert and output PDF file name strings
            BSTR urlToConvert = SysAllocString(L"http://www.google.com");
            BSTR outPdfFile = SysAllocString(L"out.pdf");
            // call the converter to convert the HTML document to a PDF file
            htmlToPdfConverter->ConvertUrlToFile(urlToConvert, outPdfFile);      
            // free the allocated strings
            SysFreeString(urlToConvert);
            SysFreeString(outPdfFile);
        }
    
    
        CoUninitialize();
    
    
        return 0;
    }
    here are the html to pdf demo applications for HiQPDF Library with source code in C# and VB

  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    612
    Spamming goes super-liminal, LT Smash would be proud.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,822
    Code copied from How can I use the HiQPdf Library from a C++ Native Windows Application?

    Code pasted all over the place
    How to call html to pdf asp.net library - C++ Forum
    How can I use a HTML to PDF .NET Library from a C++ Native Windows Application

    Now, do you have an ACTUAL question to ask, as opposed to merely being able to use ctrl-c and ctrl-v ?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Application in Nt Native Api
    By sousasamir in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 01-30-2009, 06:41 PM
  2. [C] Displaying HTML in an application.
    By pc2-brazil in forum Windows Programming
    Replies: 2
    Last Post: 12-17-2008, 01:45 AM
  3. What is a native call?
    By satya_nemana in forum C Programming
    Replies: 1
    Last Post: 06-18-2007, 07:26 AM
  4. Keyboard input in Windows NT/2K/XP native application
    By kcahcn in forum Windows Programming
    Replies: 3
    Last Post: 11-18-2002, 02:24 AM
  5. C system call and library call
    By Coconut in forum C Programming
    Replies: 6
    Last Post: 08-22-2002, 12:20 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21