IPXS_EncodeFiltersArray::AddFilterInfo Method
From PDF XChange PDF SDK
Adds filters into encode filters array
Syntax
HRESULT AddFilterInfo([in] ULONG nFilter, [in] IPXS_PDFVariant* pParams);
Parameters
- nFilter
- [in] Value of ULONG containing the filter's atom ID.
- pParams
- [in] Pointer to IPXS_PDFVariant containing the filer's parameters.
Return Value
Returns S_OK if operation was successful or error code in other cases.
Sample
//C# private void AddJPEG(PDFXEdit.IPXS_EncodeFiltersArray arr, int nQuality = 75 /*1 - 100*/) { PDFXEdit.IPXS_PDFVariant varDist = pxsInst.NewVar_Dict(); varDist.Dict_SetInt("Quality", nQuality); arr.AddFilterInfo(pxsInst.StrToAtom("DCTDecode"), varDist); } private void AddJPEG2000(PDFXEdit.IPXS_EncodeFiltersArray arr, int nQuality = 75 /*1 - 100*/) { PDFXEdit.IPXS_PDFVariant varDist = pxsInst.NewVar_Dict(); varDist.Dict_SetInt("Quality", nQuality); varDist.Dict_SetBool("EncodeLosslessly", true); arr.AddFilterInfo(pxsInst.StrToAtom("JPXDecode"), varDist); } private void AddFlate(PDFXEdit.IPXS_EncodeFiltersArray arr, int nCompressionLevel = 0 /* -1 - 9 */) { PDFXEdit.IPXS_PDFVariant varDist = pxsInst.NewVar_Dict(); varDist.Dict_SetInt("Level", nCompressionLevel); arr.AddFilterInfo(pxsInst.StrToAtom("FlateDecode"), varDist); } private void AddJBIG2(PDFXEdit.IPXS_EncodeFiltersArray arr, int nQuality = 75 /*0 - 100*/) { arr.AddFilterInfo(pxsInst.StrToAtom("JBIG2Decode"), null); } private void AddRunLength(PDFXEdit.IPXS_EncodeFiltersArray arr) { arr.AddFilterInfo(pxsInst.StrToAtom("RunLengthDecode"), null); } private void AddLZW(PDFXEdit.IPXS_EncodeFiltersArray arr, int nEarlyChange = 0 /*0 - 1*/) { PDFXEdit.IPXS_PDFVariant varDist = pxsInst.NewVar_Dict(); varDist.Dict_SetInt("EarlyChange", nEarlyChange); arr.AddFilterInfo(pxsInst.StrToAtom("LZWDecode"), varDist); } private void AddCCITT3(PDFXEdit.IPXS_EncodeFiltersArray arr, int nK = 0) { PDFXEdit.IPXS_PDFVariant var = pxsInst.NewVar_Dict(); var.Dict_SetInt("K", nK); arr.AddFilterInfo(pxsInst.StrToAtom("CCITTFaxDecode"), var); } private void AddCCITT4(PDFXEdit.IPXS_EncodeFiltersArray arr) { AddCCITT3(arr, -1); } PDFXEdit.IPXS_EncodeFiltersArray arr = pxsInst.Create_EncodeFiltersArray(); AddJPEG(arr, Compression_JPEG); AddFlate(arr); pdfCtl.Doc.CoreDoc.SetEncodersForStreamType("Image.TrueColor", arr);