You are not logged in.
Hello,
I would like to position (rotate) the JPG always in Horizontal (with choice), I would like to know the code?
prong the 300dpi JPG always, if it is 100 dpi, 300 dpi to increase.
Offline
hi, below code used.
pdfDoc :TPdfDocument;
pdfpage :TPdfpage;
JpegImage:TJpegImage;
pdfImage :TPdfImage;
//=======
pdfDoc := TPdfDocument.Create;
pdfDoc.Info.Author := 'Sergio';
pdfDoc.Info.Creator := 'Brazil';
pdfDoc.NewDoc;
for i:=0 to frmPdf.listview1.items.count-1 do
begin
JpegImage := TJpegImage.Create;
JpegImage.LoadFromFile(caminhoJPG);
pdfpage.PageWidth := Round(JpegImage.Width * 0.24001); // for image 300dpi
pdfpage.PageHeight:= Round(JpegImage.Height * 0.24001);
pdfImage := TPdfImage.Create(pdfDoc, JpegImage,true);
pdfDoc.AddXObject('image'+ inttostr(contador+1), pdfimage);
pdfDoc.Canvas.DrawXObject(0,0,pdfpage.PageWidth,pdfpage.PageHeight,'image'+inttostr(contador+1));
JpegImage.Free;
end;
pdfDoc.SaveToFile(caminhoSalva+'\'+ copiaNome + '.pdf');
pdfDoc.Free;
Last edited by serginho99 (2014-10-25 13:03:12)
Offline
can someone help?
Offline
Take a look at DrawXObject:
procedure TPdfCanvas.DrawXObject(X, Y, AWidth, AHeight: Single;
const AXObjectName: PDFString);
begin
DrawXObjectPrepare(AXObjectName);
GSave;
ConcatToCTM(AWidth, 0, 0, AHeight, X, Y);
ExecuteXObject(AXObjectName);
GRestore;
end;
I guess you can change the rotation by changing the ConcatToCTM default parameters.
See http://stackoverflow.com/a/19909409/458259
If you find out how to rotate the image.
Perhaps http://stackoverflow.com/a/17288854/458259 may help, as well as Section 4.2.1, “Coordinate Spaces” of the PDF reference manual.
This is how we do text rotation in TPdfEnum.TextOut:
a := font.spec.angle*(PI/180);
acos := cos(a);
asin := sin(a);
PosX := 0;
PosY := 0;
Canvas.SetTextMatrix(acos, asin, -asin, acos,
Canvas.I2X(Posi.X-Round(W*acos+H*asin)),
Canvas.I2Y(Posi.Y-Round(H*acos-W*asin)));
You can use the same kind of parameters.
Offline