Hi Alex,
thank you for your reply. However, I don't get the rect of the page exported, i'd selected.
In my case, the user has to select a rect of the pdf page (like snipping tool). After that, I calculate that selected rectangle with IPXV_PagesLayoutManager.DeviceRectToPageRect to the specified PXC_Rect, the user has selected.
After that, I try to export that rect as an image with the following code:
Code: Select all
const uint dpiX = 300;
const uint dpiY = 500;
var imgCore = (IIXC_Inst) inst.GetExtension("IXC");
var img = imgCore.CreateEmptyImage();
var page = doc.CoreDoc.Pages[0];
var cx = (uint)(customRect.right - customRect.left);
var cy = (uint)(customRect.top - customRect.bottom);
var iPage = imgCore.Page_CreateEmpty(cx, cy, IXC_PageFormat.PageFormat_8RGB, 0);
var ipxcInst = (IPXC_Inst) inst.GetExtension("PXC");
var param = ipxcInst.CreateRenderParams();
if (param == null)
throw new NullReferenceException("Cannot export with rect. Creating params failed.");
param.RenderFlags = (uint)PXC_RenderFlags.RF_OverrideBackgroundColor | (uint)PXC_RenderFlags.RF_SmoothImages | (uint)PXC_RenderFlags.RF_SmoothLineArts;
param.TextSmoothMode = PXC_TextSmoothMode.TSM_ClearType;
var matrix = new PXC_Matrix();
var tagRec = new tagRECT
{
top = (int)customRect.bottom,
left = (int)customRect.left,
bottom = (int)customRect.top,
right = (int)customRect.right
};
page.DrawToIXCPage(iPage, ref tagRec, ref matrix, param);
iPage.set_FmtInt((uint) IXC_FormatParametersIDS.FP_ID_XDPI, dpiX);
iPage.set_FmtInt((uint) IXC_FormatParametersIDS.FP_ID_YDPI, dpiY);
iPage.set_FmtInt((uint) IXC_FormatParametersIDS.FP_ID_FILTER, 0);
iPage.set_FmtInt((uint) IXC_FormatParametersIDS.FP_ID_FORMAT, (uint) IXC_ImageFileFormatIDs.FMT_BMP_ID);
iPage.set_FmtInt((uint) IXC_FormatParametersIDS.FP_ID_ITYPE, 16);
iPage.set_FmtInt((uint) IXC_FormatParametersIDS.FP_ID_COMP_LEVEL, 5);
iPage.set_FmtInt((uint) IXC_FormatParametersIDS.FP_ID_COMP_TYPE, 32773);
img.InsertPage(iPage, 0);
nPage++;
img.Save(fileName, IXC_CreationDisposition.CreationDisposition_Overwrite);
The problem is, I'm getting bitmaps like this
image.
You can see, the background ist black and the defined rect, which needs to be exported, seems to be moved to the lower right corner of the bmp file. Also, the rect you can see in the picture is not in the range of the rectangle the user has selected.
So my problem is first that the rect I pass seems to be bigger than the actual selected one and second that I just cannot move the content to fit into its dimensions. I hope you can help me in some way.
Thanks in advance
mbz