Last active
May 18, 2016 14:07
-
-
Save Polaringu/daa06386a7258fcceaa8acc36cbeb14d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void addImageOnPageToolStripMenuItem_Click(object sender, EventArgs e) | |
{ | |
PDFXEdit.IPXC_Document doc = pxcInst.NewDocument(); | |
PDFXEdit.IPXC_Image img = doc.AddImageFromFile("D:\\YourImage.png"); | |
PDFXEdit.PXC_Rect rcMedia; | |
rcMedia.left = 0; | |
rcMedia.bottom = 0; | |
//We will create 200*200 page | |
rcMedia.top = 200;//img.Height; | |
rcMedia.right = 200;//img.Width; | |
PDFXEdit.IPXC_UndoRedoData urData; | |
PDFXEdit.IPXC_Page page = doc.Pages.InsertPage(0, ref rcMedia, out urData); | |
PDFXEdit.IPXC_ContentCreator CC = doc.CreateContentCreator(); | |
//We'll need to do matrix Rect2Rect from the rectangle with 1pt width and height (as the image is interpreted in the PDF specification) into the page's rect | |
PDFXEdit.PXC_Matrix m; | |
PDFXEdit.PXC_Rect rcTo; | |
rcTo.left = 0; | |
rcTo.right = 1; | |
rcTo.top = 1; | |
rcTo.bottom = 0; | |
//Doing rect to rect matrix will fit our image in the given rectangle | |
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); | |
doc.WriteToFile("D:\\TestFile_res.pdf"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment