Skip to content

Instantly share code, notes, and snippets.

@Polaringu
Last active May 19, 2016 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Polaringu/e0ecba2e44de2601b8127ee3b04d33d0 to your computer and use it in GitHub Desktop.
Save Polaringu/e0ecba2e44de2601b8127ee3b04d33d0 to your computer and use it in GitHub Desktop.
private void iIXCExperimentsToolStripMenuItem_Click(object sender, EventArgs e)
{
PDFXEdit.IPXC_Document doc = pxcInst.NewDocument();
PDFXEdit.IIXC_Inst iInst = (PDFXEdit.IIXC_Inst)pdfCtl.Inst.GetExtension("IXC");
PDFXEdit.IIXC_Image iImage = iInst.CreateEmptyImage();
iImage.Load(System.IO.Directory.GetParent(System.Environment.CurrentDirectory).Parent.FullName + "\\Resources\\multipage_tif_example.tif");
for (uint i = 0; i < iImage.PagesCount; i++)
{
PDFXEdit.IIXC_Page iPage = iImage.GetPage(i);
iPage.ConvertToFormat(PDFXEdit.IXC_PageFormat.PageFormat_8Gray);
PDFXEdit.PXC_Rect rcMedia;
rcMedia.left = iPage.Rect.left;
rcMedia.bottom = iPage.Rect.bottom;
rcMedia.top = iPage.Rect.top;
rcMedia.right = iPage.Rect.right;
PDFXEdit.IPXC_UndoRedoData urData;
PDFXEdit.IPXC_Page page = doc.Pages.InsertPage(0, ref rcMedia, out urData);
PDFXEdit.IPXC_Image img = doc.AddImageFromIXCPage(iPage);
PDFXEdit.IPXC_ContentCreator CC = doc.CreateContentCreator();
//We'll need to do matrix Rect2Rect from the rectangle with 1pt width and height (as it's interpreted in the PDF specification) into the page rect
PDFXEdit.PXC_Rect rcTo;
rcTo.left = 0;
rcTo.right = 1;
rcTo.top = 1;
rcTo.bottom = 0;
PDFXEdit.PXC_Matrix m = auxInst.MathHelper.Matrix_RectToRect(ref rcTo, ref rcMedia);
CC.ConcatCS(m);
CC.PlaceImage(img);
page.PlaceContent(CC.Detach(), (uint)PDFXEdit.PXC_PlaceContentFlags.PlaceContent_Replace);
}
pdfCtl.OpenDocFrom(doc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment