Skip to content

Instantly share code, notes, and snippets.

View Polaringu's full-sized avatar

Alex Polaringu

  • SoftServe
  • Ukraine
View GitHub Profile
@Polaringu
Polaringu / op.document.resizePages.cs
Last active December 16, 2015 07:52
Resize pages operation code sample
//C#
private void ResizePageToA2(PDFXEdit.IPXV_Document pDoc, PDFXEdit.PXV_Inst pInst)
{
if (pDoc == null)
return;
int nID = pInst.Str2ID("op.document.resizePages", false);
PDFXEdit.IOperation pOp = pInst.CreateOp(nID);
PDFXEdit.ICabNode input = pOp.Params.Root["Input"];
input.v = pDoc;
PDFXEdit.ICabNode options = pOp.Params.Root["Options"];
private void EmbeddPageAsAnIcon(PDFXEdit.IPXC_Document srcDoc, PDFXEdit.IPXC_Document destDoc, PDFXEdit.IPXV_Inst Inst)
{
if (destDoc.HasAcroForm != false)
{
PDFXEdit.IPXC_FormField ff = destDoc.AcroForm.GetFieldByName("Button1");
if (ff != null)
{
PDFXEdit.IPXC_Annotation annot = ff.Widget[0];
PDFXEdit.IPXC_AnnotData_Widget WData = (PDFXEdit.IPXC_AnnotData_Widget)annot.Data;
PDFXEdit.IPXC_Page srcPage = srcDoc.Pages[0];
public void InitializeTwoControls()
{
//First frame will be with full Control functionality
PDFXEdit.IPXV_MainFrame firstMainFrame = pdfCtl.Inst.MainFrm[0];
PDFXEdit.IPXV_MainView firstMainView = firstMainFrame.View;
PDFXEdit.IPXC_Document doc = pxcInst.OpenDocumentFromFile("D:\\TestFile.pdf", null, null);
firstMainFrame.OpenDocFrom(doc);
firstMainView.CmdPaneTop.Show();
//Setting up preview frame
SourceCtrl.OpenDocFromPath(appRootDir + "\\SP.pdf");
PDFXEdit.IPXV_Document sourceDoc = SourceCtrl.Doc;
DestinationCtrl.OpenDocFromPath(appRootDir + "\\SF.pdf");
EmbeddPageAsAnIcon(sourceDoc.CoreDoc, DestinationCtrl.Doc.CoreDoc, DestinationCtrl.Inst);
private void changeAnnotationScaleToolStripMenuItem_Click(object sender, EventArgs e)
{
PDFXEdit.IPXC_Annotation annot = pdfCtl.Doc.CoreDoc.Pages[0].GetAnnot(0);
PDFXEdit.IPXC_AnnotData_Poly PData = (PDFXEdit.IPXC_AnnotData_Poly)annot.Data;
PDFXEdit.IPXC_MeasureRL measure = (PDFXEdit.IPXC_MeasureRL)PData.Measure;
//We'll set the scale from 33mm to 11m
measure.Ratio = "33 mm = 11 m";
PDFXEdit.IPXC_NumberFormatArray nfa = measure.GetX();
PDFXEdit.IPXC_NumberFormatItem nfi = nfa.CreateNewItem();
nfi.FractionType = PDFXEdit.PXC_MeasureFractionType.MFT_AsDecimal;
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;
PDFXEdit.ICab openParams = m_Inst.CreateOpenDocParams();
PDFXEdit.ICabNode openParamsRoot = openParams.Root;
openParamsRoot.SetBool("NoProgress", true);
m_Inst.ActiveMainFrm.OpenDocFromPath(ofd.FileName, openParams);
uint m_nImagesCount = 0;
private void CountImageTypeContentItems(PDFXEdit.IPXC_Document srcDoc, PDFXEdit.IPXC_Content content)
{
//Getting image or inline image types of the content items
for (uint j = 0; j < content.Items.Count; j++)
{
PDFXEdit.IPXC_ContentItem ci = content.Items[j];
if ((ci.Type == PDFXEdit.PXC_CIType.CIT_Image) || (ci.Type == PDFXEdit.PXC_CIType.CIT_InlineImage))
{
public partial class CustomEventTarget:
PDFXEdit.IUIX_ObjImpl,
IDisposable
{
//Here we push custom implementation of the PagesView
public CustomEventTarget(PDFXEdit.IUIX_Obj obj, MainFrm parentForm)
{
Obj_ = obj;
if (Obj_ != null)
Obj_.PushImpl(this);