Itthen convert the IIXC_Page into a TBitmap in Delphi followed by a TBitmap.SaveTo File and then TBitmap.Free;
So I'm freeing the TBitmap before a go to the next page.
However, looping through the code below for each page in the PDF starts to Bloat my application. It appears that DrawToIXPage is the culprit. The only thing that seems to free all the memory bloat is when I close the IPXC_Document document from which I got the IPXC_Page.
Is there anything that can be done about the memory bloat when using DrawToIXPage?
Code: Select all
function PDF_CreateIXCPageFromPage(APage: IPXC_Page; ASize: Integer; var ADPI: Integer): IIXC_Page;
var
AWidth, AHeight: Double;
W, H: Cardinal;
ADestRect: tagRECT;
APageMatrix: PXC_Matrix;
AFlags: Integer;
ARenderParams: IPXC_PageRenderParams;
AOCContext: IPXC_OCContext;
begin
//Get Page dimensions in Points
APage.GetDimension(AWidth, AHeight);
//Make Sure the Image is not Too Big
if (AHeight > AWidth) then
begin
if (P2X(AHeight, 100) > 4400) or (P2X(AWidth, 100) > 3400) then ADPI := 100;
end else
begin
if (P2X(AWidth, 100) > 4400) or (P2X(AHeight, 100) > 3400) then ADPI := 100;
end;
//Convert to Pixes
ADPI := Max(100, ADPI);
W := Round(P2X(AWidth, ADPI));
H := Round(P2X(AHeight, ADPI));
if (ASize <= 0) then ASize := Max(H, W);
if (H > W) then
begin
W := Ceil(ASize * (W / H));
H := ASize;
end else
begin
H := Ceil(ASize * (H / W));
W := ASize;
end;
with ADestRect do
begin
Left := 0;
Top := 0;
Right := W;
Bottom := H;
end;
//Defaults
AFlags := DDF_AsVector;
ARenderParams := nil;
AOCContext := nil;
APageMatrix := PDF_GetPageMatrix(APage, ADestRect);
INST_IXC.Page_CreateEmpty(W, H, PageFormat_8RGB, 255, Result); //PageFormat_8RGB, PageFormat_1Indexed
APage.DrawToIXCPage(Result, ADestRect, APageMatrix, ARenderParams, AOCContext, nil);
end;