Skip to content

Instantly share code, notes, and snippets.

@Polaringu
Created April 1, 2016 12:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save Polaringu/1a7f9d0564937aeb8f3d26f0498d2622 to your computer and use it in GitHub Desktop.
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