Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Printing data to a pdf document using win32 sdk c++

Printing data to a pdf document using win32 sdk c++

Scheduled Pinned Locked Moved C / C++ / MFC
helpc++tutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raesa
    wrote on last edited by
    #1

    Hi..... I have a small problem, i have to print my part files of a CAD software to a pdf document.When i try printing to a pdf format, the resultant pdf is blank.Can someone tell me how to print data(current window image) to a pdf document using win32 sdk.Plse do help me out. Thnx in advance. :)

    R 1 Reply Last reply
    0
    • R raesa

      Hi..... I have a small problem, i have to print my part files of a CAD software to a pdf document.When i try printing to a pdf format, the resultant pdf is blank.Can someone tell me how to print data(current window image) to a pdf document using win32 sdk.Plse do help me out. Thnx in advance. :)

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      raesa wrote:

      When i try printing to a pdf format, the resultant pdf is blank.

      How are you currently creating a PDF?

      raesa wrote:

      Can someone tell me how to print data(current window image) to a pdf document using win32 sdk.

      You cannot print to a PDF with WIN32 SDK alone.

      raesa wrote:

      Plse do help me out.

      Unless you give a clue, nobody can help you out.

      It is a crappy thing, but it's life -^ Carlo Pallini

      R 1 Reply Last reply
      0
      • R Rajesh R Subramanian

        raesa wrote:

        When i try printing to a pdf format, the resultant pdf is blank.

        How are you currently creating a PDF?

        raesa wrote:

        Can someone tell me how to print data(current window image) to a pdf document using win32 sdk.

        You cannot print to a PDF with WIN32 SDK alone.

        raesa wrote:

        Plse do help me out.

        Unless you give a clue, nobody can help you out.

        It is a crappy thing, but it's life -^ Carlo Pallini

        R Offline
        R Offline
        raesa
        wrote on last edited by
        #3

        FIrstly, thnx for the reply.I'll explain the problem clearly below: I have a CAD environtment, UGNX(Unigraphicd NX) and i have a part displayed on the current opened window.I have to capure the contents of the current opened window(i.e., the image of the current opend window) of my UGNX session and put it into a PDF file.This is am trying to do, the file printing option which has PDF complete as one of the printing formats using PrintDLg function in win32 sdk.The result that i am getting is a blank pdf file.I dont seem to undertnd the problem.Can you plse have a look at my code below and tell me where i am going wrong.Plse do reply. Thnk You. Sample Code: HDC GetPrinterDC(HWND hWndParent) { PRINTDLG pdlg; // Initialize the PRINTDLG structure. memset( &pdlg, 0, sizeof( PRINTDLG ) ); pdlg.lStructSize = sizeof( PRINTDLG ); DEVMODE hDevMode; // Set the flag to return printer DC. pdlg.Flags = PD_RETURNDEFAULT | PD_RETURNDC; pdlg.hwndOwner = hWndParent; DEVMODE hDmode; PrintDlg( &pdlg ); // hDC member of the PRINTDLG structure contains // the printer DC. return pdlg.hDC; } void InitDocStruct( DOCINFO* di, char* docname) { // Always zero it before using it. memset( di, 0, sizeof( DOCINFO ) ); // Fill in the required members. di->cbSize = sizeof( DOCINFO ); di->lpszDocName = "test"; } HINSTANCE hInstance; BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { hInstance = (HINSTANCE)hModule; return TRUE; } extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen ) { int nErr = 0; HWND hWnd = NULL; HDC hDC; DOCINFO di; nErr = UF_initialize(); if (nErr != 0) { uc1601 ("Failed to initialise UG session", 1); return; } hWnd = GetActiveWindow(); if (hWnd != NULL) { hDC = GetPrinterDC(hWnd); if( !hDC) { MessageBox(NULL, "Error creating DC", "Error", MB_APPLMODAL | MB_OK ); } InitDocStruct( &di, "Test"); StartDoc( hDC, &di ); //// Print one page. StartPage( hDC ); //DrawStuff( hDC ); EndPage( hDC ); //// Indicate end of document. EndDoc( hDC ); // Clean up DeleteDC( hDC ); } nErr = UF_terminate(); }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups