public void ExtractDocToTiff(object obj) { try { stData data = (stData)obj; var importCV = FindNeededImportConverter(Path.GetExtension(data.sDoc)); PDFXEdit.IAFS_Name name = m_fsInst.DefaultFileSys.StringToName(data.sDoc); int openFileFlags = (int)(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read | PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_ShareRead); PDFXEdit.IAFS_File destFile = m_fsInst.DefaultFileSys.OpenFile(name, openFileFlags); PDFXEdit.IPXC_Document Doc = importCV.Convert(m_Inst, destFile); //PDFXEdit.IPXC_Document Doc = m_pxcInst.OpenDocumentFromFile(data.sDoc, null); PDFXEdit.IOperation Op = m_Inst.CreateOp(m_nID); PDFXEdit.ICabNode input = Op.Params.Root["Input"]; input.Add().v = Doc; PDFXEdit.ICabNode options = Op.Params.Root["Options"]; options["PagesRange.Type"].v = "All"; options["DestFolder"].v = data.sFolder; //Output folder options["ExportMode"].v = "AllToMutliPage"; options["Zoom"].v = 150; options["ShowResultFolder"].v = data.bLast; //We'll show the result folder only when we'll work with last doc //Saving as tiff PDFXEdit.ICabNode fmtParams = options["FormatParams"]; //Compression type fmtParams["COMP"].v = 5; //LZW compression //X DPI fmtParams["DPIX"].v = 150; //Y DPI fmtParams["DPIY"].v = 150; //Image format fmtParams["FMT"].v = PDFXEdit.IXC_ImageFileFormatIDs.FMT_TIFF_ID; //TIFF //Image type fmtParams["ITYP"].v = 16; //24 TrueColor //Use Predictor fmtParams["PRED"].v = 1; //Yes //Thumbnail fmtParams["ITYP"].v = 0; //No Op.Do(); Doc.Close(); m_nSavedFilesCount++; if (m_nSavedFilesCount == m_aFiles.Count) { MessageBox.Show("Export completed"); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
public void ExtractDocToTiff(object obj) { try { stData data = (stData)obj; PDFXEdit.IPXC_Document Doc = m_pxcInst.OpenDocumentFromFile(data.sDoc, null); PDFXEdit.IOperation Op = m_Inst.CreateOp(m_nID); PDFXEdit.ICabNode input = Op.Params.Root["Input"]; input.Add().v = Doc; PDFXEdit.ICabNode options = Op.Params.Root["Options"]; options["PagesRange.Type"].v = "All"; options["DestFolder"].v = data.sFolder; //Output folder options["ExportMode"].v = "AllToMutliPage"; options["Zoom"].v = 150; options["ShowResultFolder"].v = data.bLast; //We'll show the result folder only when we'll work with last doc //Saving as tiff PDFXEdit.ICabNode fmtParams = options["FormatParams"]; //Compression type fmtParams["COMP"].v = 5; //LZW compression //X DPI fmtParams["DPIX"].v = 150; //Y DPI fmtParams["DPIY"].v = 150; //Image format fmtParams["FMT"].v = 1414088262; //TIFF //Image type fmtParams["ITYP"].v = 16; //24 TrueColor //Use Predictor fmtParams["PRED"].v = 1; //Yes //Thumbnail fmtParams["ITYP"].v = 0; //No Op.Do(); Doc.Close(); m_nSavedFilesCount++; if (m_nSavedFilesCount == m_aFiles.Count) { MessageBox.Show("Export completed"); } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
public virtual bool Run(MainFrm mainFrm, bool bShowOpDlg, bool bAllowOpUI) { PDFXEdit.IOperation op = null; try { op = mainFrm.pdfCtl.Inst.CreateOp(ID); } catch { return(false); } if (op == null) { return(false); } Form ui = UI; if (ui != null) { IFormHelper hlp = (IFormHelper)ui; if (hlp != null) { hlp.OnSerialize(op); } } uint flags = Flags; if ((flags & (uint)DemoFlags.Input_Doc) != 0) { PDFXEdit.IPXV_Document doc = mainFrm.pdfCtl.Doc; if (doc == null) { return(false); } PDFXEdit.ICabNode input = op.Params.Root["Input"]; if (input.Type == PDFXEdit.CabDataTypeID.dt_Array) { input.Add().v = doc; } else { input.v = doc; } } else if (!bShowOpDlg && ((flags & (uint)DemoFlags.Input_Mask) != 0)) { string fileFilter = ""; if ((flags & (uint)DemoFlags.Input_AllSupp) != 0) { fileFilter = "<allSupp>"; } else if ((flags & (uint)DemoFlags.Input_AllSuppImg) != 0) { fileFilter = "<allSuppImg>"; } else if ((flags & (uint)DemoFlags.Input_AllSuppRasterImg) != 0) { fileFilter = "<allSuppRasterImg>"; } else if ((flags & (uint)DemoFlags.Input_PdfFile) != 0) { fileFilter = "PDF Documents (*.pdf)|*.pdf"; } else if ((flags & (uint)DemoFlags.Input_TxtFile) != 0) { fileFilter = "Plain Text Documents (*.txt)|*.txt"; } else if ((flags & (uint)DemoFlags.Input_RtfFile) != 0) { fileFilter = "RTF Files (*.rtf)|*.rtf"; } PDFXEdit.IAFS_NamesCollection fileNames = mainFrm.ShowOpenFilesDlg((flags & (uint)DemoFlags.Input_MultFiles) != 0, fileFilter); if (fileNames == null || (fileNames.Count == 0)) { return(false); } PDFXEdit.ICabNode input = op.Params.Root["Input"]; if (input.Type == PDFXEdit.CabDataTypeID.dt_Array) { for (uint i = 0; i < fileNames.Count; i++) { input.Add().v = fileNames[i]; } } else { input.v = fileNames[0]; } } if (bShowOpDlg) { try { op.ShowSetupUI((uint)mainFrm.Handle); } catch (Exception ex) { int hr = Marshal.GetHRForException(ex); if (hr != HResults.E_NOTIMPL) { return(false); } } } if (!OnBeforeRun(mainFrm, op)) { return(false); } int opExecFlags = 0; if (!bAllowOpUI) { opExecFlags |= (int)PDFXEdit.OpExecFlags.OpExecFlag_NoUI; } try { if ((flags & (int)DemoFlags.SyncDo) != 0) { op.Do(opExecFlags); } else { mainFrm.pdfCtl.Inst.AsyncDoAndWaitForFinish(op, (uint)opExecFlags); } } catch (Exception ex) { int hr = Marshal.GetHRForException(ex); mainFrm.ShowErrMsg(hr); return(false); } if ((flags & (int)DemoFlags.Output_Doc) != 0) { PDFXEdit.ICabNode output = op.Params.Root["Output"]; PDFXEdit.IPXC_Document newCoreDoc = null; try { if (output.Type == PDFXEdit.CabDataTypeID.dt_Array) { if (output.Count != 0) { newCoreDoc = (PDFXEdit.IPXC_Document)output[0].Unknown; } } else { newCoreDoc = (PDFXEdit.IPXC_Document)output.Unknown; } if (newCoreDoc != null) { mainFrm.pdfCtl.OpenDocFrom(newCoreDoc); } } catch { } } return(true); }