public void OpenFile(string fileName) { int nID = Inst.Str2ID("op.openDoc", false); PDFXEdit.IOperation Op = Inst.CreateOp(nID); PDFXEdit.IAFS_Inst fsInst = (PDFXEdit.IAFS_Inst)Inst.GetExtension("AFS"); PDFXEdit.IAFS_Name name = fsInst.DefaultFileSys.StringToName(fileName); var input = Op.Params.Root["Input"]; input.v = name; PDFXEdit.ICabNode options = Op.Params.Root["Options"]; options["NativeOnly"].v = true; Op.Do(); m_doc?.Close(); m_doc = null; m_doc = (PDFXEdit.IPXC_Document)Op.Params.Root["Output"].v; OpenFile(m_doc); }
private void Redraw_PDF() { ProgressBar1 prBar = new ProgressBar1(); try { prBar.Show(); prBar.Refresh(); int Rect_size_for_20 = page_Width / 22; if (workspace_ob.op.orientation_of_document == 0) { Rect_size = (page_Width) / (workspace_ob.field_ex.width + 2); } else { Rect_size = (page_Height) / (workspace_ob.field_ex.heigth + 2); } height = workspace_ob.field_ex.heigth; width = workspace_ob.field_ex.width; keys_count = workspace_ob.keys.Count; int nID = axPXV_Control1.Inst.Str2ID("op.document.insertEmptyPages", false); //Create new "InsertEmptyPages" operation iD PDFXEdit.IOperation pOp = axPXV_Control1.Inst.CreateOp(nID); //Create new operation PDFXEdit.ICabNode input = pOp.Params.Root["Input"]; //Create "Input" id to current operation IPXC_Document pDoc = axPXV_Control1.Doc.CoreDoc; input.v = pDoc; //Specify that working with current document PDFXEdit.ICabNode options = pOp.Params.Root["Options"]; //Create "Option" id to current operation options["PaperType"].v = 2; //Apply custom paper type if (workspace_ob.op.orientation_of_document == 0) { options["Width"].v = 800; options["Height"].v = 1200; } else { options["Width"].v = 1200; options["Height"].v = 800; } pOp.Do(); //Applying creation new pages nID = axPXV_Control1.Inst.Str2ID("op.document.deletePages", false); //Create new "deletePages" operation id pOp = axPXV_Control1.Inst.CreateOp(nID); //Create new operation input = pOp.Params.Root["Input"]; //Create "Input" id to current operation input.v = pDoc; //Specify that working with current document options = pOp.Params.Root["Options"]; //Create "Option" id to current operation options["PagesRange.Custom"].v = 0; //Specify range of deleting pages. In this case it is just one zeroth page pOp.Do(); //Applying deletion range of pages var page = axPXV_Control1.Doc.CoreDoc.Pages[0]; //Create handler to first page var CC = axPXV_Control1.Doc.CoreDoc.CreateContentCreator(); //Create "Content Creator" for drawing on page. if (workspace_ob.op.orientation_of_document == 0) { Redraw_field_vertical(width, height, CC, page); Draw_Keys_Vartical(ref CC, ref page); } else if (workspace_ob.op.orientation_of_document == 1) { Redraw_field_horisontal(width, height, CC, page); Draw_Keys_Horisontal(ref CC, ref page); } CC.SetLineWidth(0.5); //Set line width CC.StrokePath(true); //Set end of drawing current element nID = axPXV_Control1.Inst.Str2ID("op.document.resizePages", false); pOp = axPXV_Control1.Inst.CreateOp(nID); input = pOp.Params.Root["Input"]; input.v = pDoc; options = pOp.Params.Root["Options"]; options["PaperType"].v = 2; //Document values table options["StdPaperIndex"].v = 4; //A2 options["ScalePage"].v = true; options["ConstraintProportions"].v = true; options["PagesRange.Filter"].v = 1; if (workspace_ob.op.orientation_of_document == 1) { options["Width"].v = 841.89; options["Height"].v = 595.276; } pOp.Do(); prBar.Hide(); prBar.Refresh(); } catch { MessageBox.Show("Generate PDF again."); prBar.Hide(); prBar.Refresh(); return; } prBar.Hide(); prBar.Refresh(); }
public Form1() { //Custom Instance initialization PDFXEdit.PXV_Inst Inst = new PDFXEdit.PXV_Inst(); Inst.Init(null, "", "", "", "", (int)PDFXEdit.PXV_AppTypeFlags.PXV_AppType_SDK); InitializeComponent(); //Creating Custom Pane's ID int nViewID = Inst.Str2ID(m_sCustomPaneID, true); //This part is necessary for correct pane loading from settings CAB - without this it won't show do { //First we check whether the pane is already inside of the settings CAB PDFXEdit.ICabNode layout = Inst.Settings["MainView.Layout"]; //This is the layout CAB - here all of the Panes' settings are stored //Then we have docked panes and floating panes //Docked panes are stored in Root and floating panes are stored in FloatingRoots //We'll need to run recursively through the children to see whether our custom pane is inside bool bHasPane = HasPane(layout["Root"]); if (bHasPane) { break; } bHasPane = HasPane(layout["FloatingRoots"]); if (bHasPane) { break; } //If we don't yet have the pane added then in this sample we will have to add it as a docked pane ICabNode root = layout["Root"]; //First level children of the Root node are place holders for panes //The root itself has a UIX_LayoutItemStyle_Splitted | UIX_LayoutItemStyle_VertSplitters | UIX_LayoutItemStyle_NoTabBar style //In this sample we will add panes to the rightmost splitter (where the search view and properties pane are) ICabNode placeHolders = root["Kids"]; //Taking the last child for the rightmost placeholder and if it does not exist for some reason, we will add it //Alternatively the placeholders can be added to divide the Main View even more //For example, if you want your Custom view to be added before the Properties View and Search View then insert the placeholder before the placeholder that holds these views ICabNode placeHolder = null; if (placeHolders.Count == 0) { placeHolder = placeHolders.Add(); } else { placeHolder = placeHolders[placeHolders.Count - 1]; } //Now we have our new placeholder and we will have to add our Custom View to it ICabNode kid = placeHolder["Kids"].Add(); //Now we will have to fill the newly added CAB node with needed data kid["ID"].v = m_sCustomPaneID; kid["S"].v = 0; //UIX_LayoutItemStyleFlags kid["FW"].v = 200; //width //Flags //UIX_LayoutItemFlag_Hidden = 0x1, //UIX_LayoutItemFlag_Client = 0x4, //UIX_LayoutItemFlag_Minimized = 0x8, kid["F"].v = 0; //This will be displayed in the pane's title kid["Title"].v = "My Custom View"; } while (false); //Creating a view creator so that the control will know how to initialize our Custom pane CustomViewCreator myViewCreator = new CustomViewCreator(Inst, m_sCustomPaneID, this); Inst.RegisterViewCreator(myViewCreator); //Loading panes layout Inst.ActiveMainView.LoadPanesLayout(); //Showing our pane when the Control is initialized for (uint i = 0; i < Inst.ActiveMainView.Panes.Count; i++) { IPXV_View view = Inst.ActiveMainView.Panes[i]; if (view?.ID == nViewID) { Inst.ActiveMainView.Panes.Show(view); break; } } }