SetPixel () problem part II (Visual C++), simple example

The Amyuni PDF Converter is our Printer Driver that enables you to convert any documents to PDF format. If you have any questions about installing and using the Amyuni PDF Converter please post them here.
Post Reply
tiagog
Posts: 3
Joined: Tue May 06 2003
Location: Brazil

SetPixel () problem part II (Visual C++), simple example

Post by tiagog » Wed May 07 2003

Hi,

just to complement my previous message (posted yesterday in this forum) I made a simple console application that reproduces the problem that I mentionded. It works fine on Windows NT/2000/XP, but generates a blank PDF in Windows 95/98 (using driver version 2.07).
This is the code:

Code: Select all

// pdftest.cpp : Defines the entry point for the console application.
//


#include <windows.h>
#import "cdintf.dll" no_namespace

#define PDF_NOPROMPT 1 // do not prompt for file name
#define PDF_USEFILENAME 2 // use file name set by SetDefaultFileName else use document name
#define PDF_CONCATENATE 4 // concatenate files, do not overwrite
#define PDF_DISABLECOMPRESSION 8 // disable page content compression
#define PDF_EMBEDFONTS 16// embed fonts used in the input document
#define PDF_256COLORCOMPRESSION 800000


int main(int argc, char* argv[])
{
	try
	{
		CoInitialize (NULL);

		ICDIntfPtr ptrPdf;
		HRESULT hr = ptrPdf.CreateInstance (__uuidof (CDIntf));
		if (FAILED(hr))
		{
			return 1;
		}

		ptrPdf->DriverInit (L"PDF Compatible Printer Driver");
		

		ptrPdf->PutResolution (600);
		ptrPdf->PutFileNameOptions (PDF_NOPROMPT | PDF_USEFILENAME | PDF_256COLORCOMPRESSION);
		ptrPdf->PutDefaultFileName (L"c:\\test.pdf");		
				
		HDC hImp = (HDC)ptrPdf->CreateDC ();		
		SetBkColor (hImp, RGB(255,255,255));
		RECT rect;
		GetClipBox (hImp, &rect);
		
		DOCINFO di;                             
		::ZeroMemory (&di, sizeof (DOCINFO));
		di.cbSize = sizeof (DOCINFO);
		di.lpszDocName = "Test";
		
		StartDoc (hImp, &di);
		StartPage (hImp);

		HPEN hPen = CreatePen (PS_SOLID, 0, RGB (0,0,0));
		SelectObject (hImp, hPen);

		for (int i = 0 ; i < abs (rect.right - rect.left) / 2; i+=50)
		{
			for (int j = 0; j < abs (rect.bottom - rect.top) / 2; j += 50)
			{
				SetPixel (hImp, i, j, RGB (0,0,0)); //if I draw a line insted it works fine, both on windows NT/2000 and 9x..
			}
		}
		
		EndPage (hImp);
		EndDoc (hImp);
		DeleteDC( hImp );
		DeleteObject (hPen);
		
		return 0;
	}
	catch (_com_error & e)
	{
		MessageBox (NULL, (LPCTSTR)e.Description (), "Error", MB_ICONSTOP);
		return 1;
	}
}


Any suggestions?

Thanks,

Tiago Gehring
tiagog@weg.com.br

Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan » Thu May 08 2003

Hello,

If you wish to complement on the same subject, please post your new message to the same post, there is no need to open a new post for this otherwise the data will be spread in multiple threads which makes it hard to follow it up.

As you have version 2.07, please download an update to version 2.08e from: http://www.amyuni.com/en/support/updates.html

Hope this helps 8)
Last edited by Joan on Fri May 09 2003, edited 1 time in total.

tiagog
Posts: 3
Joined: Tue May 06 2003
Location: Brazil

Post by tiagog » Thu May 08 2003

Ok, sorry for creating two threads... I now tested the same example using PDF Converter 2.10, but the I get the same problem. The files generated in Windows 95/98 are just blank, but fine in Windows 2000. If I change the code to draw lines insted pixels all works fine... Very strange, I really need help with this..

Thanks,

Tiago Gehring

Post Reply