Forum rules DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
I'm looking to create a TBitmap from the PDF page using the DrawToDevice call. I've got most of it working but my issue is that IPXC_Page gets drawn to the upper left corner of the defined TBitmap below. I always consult the help before bothering you, but the help was a bit a sparce on this one so I did some guessing on how to set some of the parameters. It seems I'm missing something that will draw the device on the entire defined TBitmap size below. I ensure that the size of the TBitmap in Pixels has the same proportions as the page dimensions in Points.
procedure BuildPageBitmap(APage: IPXC_Page; var B: TBitmap; ASize: Integer);
var
AWidth, AHeight: Double;
W, H, ADPI: Integer;
ARect: tagRECT;
AMatrix: PXC_Matrix;
AFlags: Integer;
ARenderParams: IPXC_PageRenderParams;
AOCContext: IPXC_OCContext;
begin
ADPI := 300;
if (B.PixelFormat = pfDevice) then B.PixelFormat := pf24bit;
//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 ARect do
begin
Left := 0;
Top := 0;
Right := Left + W;
Bottom := Top + H;
end;
B.SetSize(W, H);
APage.GetMatrix(PBox_MediaBox, AMatrix); //Is PBox_MediaBox correct here? I tried others but didn't seem to make a difference.
AFlags := DDF_AsVector;
ARenderParams := nil;
AOCContext := nil;
APage.DrawToDevice(B.Canvas.Handle, ARect, AMatrix, AFlags, ARenderParams, AOCContext, nil);
end;
There's a problem with the correct matrix that you should path to the DrawToDevice method. Please tell me more precisely what do you want - fit or stretch the page in the given image rectangle?
I want the PDF page to fill the entire rectangle, so I guess that means stretch. But since my defined rectangle has the same proportions as the PDF page width/height, wouldn't fit and stretch be the same?
I'm also open to using DrawToIXCPage if you feel that is a better approach, but would need a little guidance on how to set it up.
Also, I see that there are some Operations with the IPXV_Inst that do similar things. However, this would force me to open the PDF via the IPXV_Control and it wouldn't allow using this call in an independent thread. Correct? I'm am tending to shy away from using IPXV_Inst and use IPXC_Inst calls instead since many of my routines will be in multiple threads. Is this correct thinking? And I assume that the Operations in IPXV_Inst actuall make calls into IPXC_Inst anyway??
I'm now needed to use DrawToIXCPage. I'm following your lead on the DrawToDevice example, but my image keeps coming out blank. Could you give me an example of how I can convert a PDF page to a IIXC_Page?
Where exactly are you experiencing a problem? Our sample should do what you need. If you can, please describe why do you need to use DrawToIXCPage. For now, I can give you a code snippet on how to use it, though the precise usage may differ because I'll need a better description of the problem: