Created
April 1, 2016 12:40
Star
You must be signed in to star a gist
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 PDFXEdit.PXC_Matrix Multiply(PDFXEdit.PXC_Matrix m1, PDFXEdit.PXC_Matrix m2) | |
{ | |
double t0 = (double)(m1.a * m2.a + m1.b * m2.c); | |
double t2 = (double)(m1.c * m2.a + m1.d * m2.c); | |
double t4 = (double)(m1.e * m2.a + m1.f * m2.c + m2.e); | |
m1.b = (double)(m1.a * m2.b + m1.b * m2.d); | |
m1.d = (double)(m1.c * m2.b + m1.d * m2.d); | |
m1.f = (double)(m1.e * m2.b + m1.f * m2.d + m2.f); | |
m1.a = t0; | |
m1.c = t2; | |
m1.e = t4; | |
return m1; | |
} | |
private void TransformPage(PDFXEdit.IPXC_Document doc, PDFXEdit.IPXC_Page page, PDFXEdit.PXC_Matrix m) | |
{ | |
PDFXEdit.IPXC_Content content = page.GetContent(PDFXEdit.PXC_ContentAccessMode.CAccessMode_WeakClone); | |
for (uint i = 0; i < content.GStatesCount; i++) | |
{ | |
PDFXEdit.IPXC_GState gState = content.GetGStateByIndex(i); | |
PDFXEdit.PXC_Matrix mCtm = gState.get_CTM(); | |
mCtm = Multiply(mCtm, m); | |
gState.set_CTM(mCtm); | |
content.SetGStateByIndex(i, gState); | |
} | |
page.PlaceContent(content, (uint)PDFXEdit.PXC_PlaceContentFlags.PlaceContent_Replace); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment