Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
private void getFormFieldsToolStripMenuItem_Click(object sender, EventArgs e)
PDFXEdit.IPXC_Document SrcDoc = pxcInst.OpenDocumentFromFile("D:\\TestFile.pdf", null);
PDFXEdit.IPXC_Document DestDoc = pxcInst.OpenDocumentFromFile("D:\\TestFile1.pdf", null);
PDFXEdit.IPXC_PagesOverlayInfo poi = pxcInst.CreatePagesOverlayInfo();
//Getting source page
PDFXEdit.IPXC_Page srcPage = SrcDoc.Pages[0];
//Getting source page matrix
PDFXEdit.PXC_Matrix srcPageMatrix = srcPage.GetMatrix(PDFXEdit.PXC_BoxType.PBox_PageBox);
//Getting source page Page Box without rotation
PDFXEdit.PXC_Rect srcRect = srcPage.get_Box(PDFXEdit.PXC_BoxType.PBox_PageBox);
//Getting visual source Page Box by transforming it through matrix
TransformRect(srcPageMatrix, ref srcRect);
//Getting destination page
PDFXEdit.IPXC_Page destPage = DestDoc.Pages[0];
//Getting destination page matrix
PDFXEdit.PXC_Matrix destPageMatrix = destPage.GetMatrix(PDFXEdit.PXC_BoxType.PBox_PageBox);
//Getting destination page Page Box without rotation
PDFXEdit.PXC_Rect destRect = destPage.get_Box(PDFXEdit.PXC_BoxType.PBox_PageBox);
//Getting visual destination Page Box by transforming it through matrix
TransformRect(destPageMatrix, ref destRect);
//Forming resulting rectangle by indenting from the visual destination rectangle borders
destRect.bottom += 100; -= 100;
destRect.left += 100;
destRect.right -= 100;
//We'll insert the visual src page into visual dest page indented rectangle including page rotations and clipping
PDFXEdit.PXC_Matrix pageToRectMatrix = RectToRectMatrix(srcRect, destRect);
//For that we invert and multiply matrix
destPageMatrix = Invert(destPageMatrix);
pageToRectMatrix = Multiply(pageToRectMatrix, destPageMatrix);
//Inserting new data into the pages overlay info meaning we insert 0 source page into 0 destination page using the constructed matrix
poi.InsertNew2(0, 0, ref pageToRectMatrix);
//Applying overlays for the destination document
DestDoc.Pages.OverlayPages(SrcDoc, poi);
//Saving the document
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.