Problems scaling on printing

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Morfio
Experienced Solver
Experienced Solver
Posts: 67
Joined: Thu Jul 07, 2005 4:35 pm

Problems scaling on printing

Post by Morfio » Fri Apr 13, 2007 7:18 am

Hi,

I've got some little problems by scaling my printouts. As you can see in the attachment, my print preview is correct, but the printout is not. On printing I use this code for scaling:

Code: Select all

void LRmlDrucken::skalieren(wxDC *dc) {
	// Scaling - Quelle: Buch - Cross-Platform GUI Programming with wxWidgets - Seite 166 f.
	int ppiScreenX, ppiScreenY;
	GetPPIScreen(&ppiScreenX, &ppiScreenY);
	int ppiPrinterX, ppiPrinterY;
	GetPPIPrinter(&ppiPrinterX, &ppiPrinterY);
	float scale = (float) ((float) ppiPrinterX/(float)ppiScreenX);
	int pageWidth, pageHeight;
	int w, h;
	dc->GetSize(&w, &h);
	GetPageSizePixels(&pageWidth, &pageHeight);
	float overallScale = scale * (float) (w/(float) pageWidth);
	dc->SetUserScale(overallScale, overallScale);
}
And I call this method here:

Code: Select all

bool LRmlDrucken::OnPrintPage(int pageNum) {
	if(HasPage(pageNum)) {
		wxDC *dc = GetDC();
		skalieren(dc);

		TSeite *seite = seiten->hole(pageNum);
		TDruckenTabelle *druck = NULL;
		if(seite != NULL) {
			druckePrimitiven(dc, seite);
			for(int i = 0; i < seite->anzahl(); i++) {
				druck = seite->hole(i);
				if(druck != NULL) {
					druck->drucken(dc);
				}
			}
			return true;
		}
	}
	return false;
}
I don't know, where the problem is. I tried to don't scale on printing but it's the same effect.

Another problem is on scaling the preview. The proportions seems to go wrong.

How can I fix these problems?

Thank you, Morfio ...
Attachments
original.png
Print preview
original.png (35.4 KiB) Viewed 562 times
druck.png
Printout
druck.png (27.95 KiB) Viewed 562 times

Morfio
Experienced Solver
Experienced Solver
Posts: 67
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio » Fri Apr 13, 2007 9:48 am

It seems that the printout is correct, the pixels are at the right position. The preview is wrong...

Morfio
Experienced Solver
Experienced Solver
Posts: 67
Joined: Thu Jul 07, 2005 4:35 pm

Post by Morfio » Fri Apr 13, 2007 10:23 am

Now I realized that the only problem are the fonts. They are not scaled well. Is there any possibility to scale the fonts to the right size?

Post Reply