hi,
setworldtransform is just supported under win2000 and xp. but for this project this will no problem
i will test your code. thank you for your efforts.
tom
hi,
setworldtransform is just supported under win2000 and xp. but for this project this will no problem
i will test your code. thank you for your efforts.
tom
Hi,
You can use SetWorldTransform - that rotates an EMF to any degree and does NOT create a bitmap.
This code will do it: It draws an EMF to the wPDF. I also tested it with Text - that rotates and stays searchable text in the PDF, too.
procedure TForm1.Button2Click(Sender: TObject);
var x,y,w,h : Integer;
DC : HDC;
q : Single;
saved : Integer;
matrix : TXForm;
begin
WPPDFPrinter1.FontMode := wpEmbedSubsetTrueType_UsedChar;
WPPDFPrinter1.BeginDoc;
try
WPPDFPrinter1.StartPage(Image1.Picture.Graphic.Width, Image1.Picture.Graphic.Height,
Screen.PixelsPerInch, Screen.PixelsPerInch, 0);
w := Image1.Picture.Graphic.Width div 3;
h := Image1.Picture.Graphic.Height div 3;
x := w;
y := h;
DC := WPPDFPrinter1.Canvas.Handle;
SetGraphicsMode(DC, GM_ADVANCED );
q := (2*pi) * (TrackBar1.Position/360);
// Draw rotated - q is the angle (0..2pi)
saved := SaveDC(DC);
matrix.eM11 := cos(q);
matrix.eM12 := sin(q);
matrix.eM21 := -sin(q);
matrix.eM22 := cos(q);
matrix.eDx:=x -cos(q)*(w/2)+sin(q)*(h/2);
matrix.eDy:=y -cos(q)*(h/2)-sin(q)*(w/2);
SetWorldTransform(DC, matrix);
WPPDFPrinter1.Canvas.StretchDraw(Rect(0,0,w,h),Image1.Picture.Graphic);
RestoreDC(DC,saved);
WPPDFPrinter1.EndPage;
finally
WPPDFPrinter1.EndDoc;
end;
end;
The formula
matrix.eDx:=x -cos(q)(w/2)+sin(q)(h/2);
matrix.eDy:=y -cos(q)(h/2)-sin(q)(w/2);
makes sure the center point for the rotation is the middle of the image.
Julian
Hello,
We are looking for a PDF lib for our printing software. We need
the ability to create PDFs with rotated EMF (rtf text) in it. The
EMF ist created from a TRichEdit via EM_FORMATRANGE. We did some
test with your trial version and a simple DrawMetaFile brings out
perfect results. But is it possible to rotate the Metafile when doing
a DrawMetaFile?
Best regards