Hi Alex!
Please read the code before responding.
I've been attempting to follow the advice that you gave me to do this; so far I can't get it to work. I did explain which parts work, and which parts don't. The instruction that you pointed me to has an IPXC_Page being converted to an IPXC_XForm, which subsequently gets placed on a widget icon.
Remember this?:
Code: Select all
xform := FCoreDoc.CreateXFormFromPage(iPage,IPF_Annots_Flatten or IPF_Widgets_Flatten or IPF_Bookmarks_DoNotCopy or IPF_OCG_DoNotCopy);
...which comes from this reference that you pointed me to?:
https://gist.github.com/Polaringu/f661a5af12c8fbf7e7fd
The first parameter in the call to CreateXFormFromPage is - you guessed it! - an IPXC_Page.
Please read your documentation here:
https://sdkhelp.pdf-xchange.com/vi ... rmFromPage
To narrow it down, this is the code that is not working:
Code: Select all
function CreatePXCPageFromPXCImage(APXCImage: IPXC_Image; out APXCPage: IPXC_Page; ABtnIconRect: PXC_Rect): Boolean;
var
iCC: IPXC_ContentCreator;
ipDoc: IPXC_Document;
arect: PXC_Rect;
iMath: IMathHelper;
matrix,mtx: PXC_Matrix;
iC: IPXC_Content;
urd: IPXC_UndoRedoData;
begin
Result := False;
if APXCImage.Get_Document(ipDoc) = S_OK then
// add new page to document
if ipDoc.Pages.AddEmptyPages(0,1,ABtnIconRect,FInst.ProgressMon,urd) = S_OK then
// get handle to new page
if ipDoc.Pages.Get_Item(0,APXCPage) = S_OK then
// get bounding box of sized page
if APXCPage.Get_Box(PBox_BBox,arect) = S_OK then
// obtain content handle from IPXC_Page
if APXCPage.GetContent(CAccessMode_WeakClone,iC) = S_OK then
begin
mtx.a := arect.right - arect.left; // Can't determine if this section is necessary
mtx.d := arect.top - arect.bottom; //
mtx.e := arect.left; //
mtx.f := arect.bottom; //
iMath := FAUXInst.MathHelper;
// map rects
if iMath.Matrix_RectToRect(ABtnIconRect,arect,matrix) = S_OK then
begin
iCC := ipDoc.CreateContentCreator;
if iCC.Attach(iC) = S_OK then
if iCC.SaveState = S_OK then // don't know if this is necessary
if iCC.ConcatCS(matrix) = S_OK then // also tried iCC.ConcatCS(mtx)
if iCC.PlaceImage(APXCImage) = S_OK then
if iCC.RestoreState = S_OK then // don't know if this is necessary
if iCC.Detach(iC) = S_OK then
if APXCPage.PlaceContent(iC,PlaceContent_Replace) = S_OK then
Result := True;
end;
end;
// the following is just a test to see if the document's IPXC_Page gets the correct dimensions and gets the IPXC_Image placed upon it.
// the IPXC_Page gets the correct dimensions, but does not get the IPXC_Image placement via the IPXC_ContentCreator/IPXC_Content interface.
ipDoc.WriteToFile(PChar(ExtractFilePath(Application.ExeName) + '\test1.pdf'),nil,0);
end;
When I write the temporary, in memory IPXC_Document (ipDoc) to file, it has the correct dimensions. It just doesn't get the image placed on the IPXC_Page (APXCPage).
Again, my number one suspect is the matrix code.
Can you please provide an example of how the matrix should be configured?
Can you please read through the code and try to spot anything that I may be doing wrong that is preventing the IPXC_Image from getting placed on the IPXC_Page?
Could it be something other than the matrix? Like the IPXC_ContentCreator/IPXC_Content interface(s)?