I am trying to get ImageEn to generate a single page PDF with layout attached to this post.
I am using following code but am not getting expected result so it seems that I am making some mistake in coding.
procedure CreateAndSavePDF;
var
PDFFileName: string;
I, Col: Integer;
FileComment: String;
FileName: String;
LL, LT, LW, LH, NewW, NewH: Integer;
ieTemp: TImageEnView;
NewLayerNum: Integer;
Row: Integer;
begin
// Initiate PDF file creation
PDFFileName := IncludeTrailingBackslash(ProjectFolderPath) +
'projectdetails.pdf';
ieMain.Background := clWhite;
ieMain.Clear;
ieMain.Proc.ImageResize(816, 1056);//Resize canvas/image size to A4 size @96 DPI
ieMain.SetDPI(96, 96);
ieMain.IO.AutoAdjustDPI := True;
ieMain.IO.Params.JPEG_EnableAdjustOrientation := True;
Col := 1;
Row := 1;
ieMain.IO.CreatePDFFile(PDFFileName);
// Code to add the image to PDF
for I := 0 to iemComments.ImageCount - 1 do
begin
FileComment := Comments[I];
FileName := iemComments.ImageFileName[I];
ieTemp := TImageEnView.Create(Application);
ieTemp.LayersAdd;
ieTemp.IO.Params.JPEG_EnableAdjustOrientation := True;
ieTemp.IO.LoadFromFile(FileName);
LW := ieTemp.CurrentLayer.Width;
LH := ieTemp.CurrentLayer.Height;
NewH := 100;
NewW := 100;
if LW > LH then
ieTemp.Proc.Resample(NewW, -1, TResampleFilter(0))
else
ieTemp.Proc.Resample(-1, NewH, TResampleFilter(0));
if Col > 5 then
Col := 1; //Reset Col to 1
if Col = 1 then
LL := 100
else
LL := Col * 163;
LT := Row * 163;
NewLayerNum := ieMain.LayersAdd;
ieMain.Layers[NewLayerNum].PosX := LL;
ieMain.Layers[NewLayerNum].PosY := LT;
ieMain.Layers[NewLayerNum].Width := NewW;
ieMain.Layers[NewLayerNum].Height := NewH;
ieMain.Layers[NewLayerNum].Assign(ieTemp.CurrentLayer);
ieTemp.Free;
Row := Row + 1;
Col := Col + 1;
ieMain.IO.Params.PDF_Compression := ioPDF_JPEG;
ieMain.IO.SaveToPDF;
end;
ieMain.IO.ClosePDFFile;
end;
Can someone please guide me here.
Note: In the code I have not included the part that will add text to keep the code short and simple.
TIA
Yogi Yang