Exemple #1
0
        public bool GetString(nint idx, out string?result)
        {
            var r = CGPDFArrayGetString(Handle, idx, out var res);

            result = r ? CGPDFString.ToString(res) : null;
            return(r);
        }
Exemple #2
0
        public bool GetString(int idx, out string result)
        {
            IntPtr res;
            var    r = CGPDFArrayGetString(handle, idx, out res);

            result = r ? CGPDFString.ToString(res) : null;
            return(r);
        }
Exemple #3
0
        public bool GetString(string key, out string result)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            IntPtr res;
            var    r = CGPDFDictionaryGetString(handle, key, out res);

            result = r ? CGPDFString.ToString(res) : null;
            return(r);
        }
Exemple #4
0
        public bool TryGetValue(out string value)
        {
            IntPtr ip;

            if (CGPDFObjectGetValue(Handle, CGPDFObjectType.String, out ip))
            {
                value = CGPDFString.ToString(ip);
                return(true);
            }
            else
            {
                value = null;
                return(false);
            }
        }
Exemple #5
0
        public bool TryPop(out string value)
        {
            IntPtr ip;

            if (CGPDFScannerPopString(Handle, out ip))
            {
                value = CGPDFString.ToString(ip);
                return(true);
            }
            else
            {
                value = null;
                return(false);
            }
        }
Exemple #6
0
        internal static object FromHandle(IntPtr handle)
        {
            IntPtr ip;

            var type = CGPDFObjectGetType(handle);

            switch (type)
            {
            case CGPDFObjectType.Null:
                return(null);

            case CGPDFObjectType.Boolean:
                byte b;
                if (CGPDFObjectGetValue(handle, type, out b))
                {
                    return(b != 0);
                }
                return(null);

            case CGPDFObjectType.Integer:
                nint i;
                if (CGPDFObjectGetValue(handle, type, out i))
                {
                    return(i);
                }
                return(null);

            case CGPDFObjectType.Real:
                nfloat f;
                if (CGPDFObjectGetValue(handle, type, out f))
                {
                    return(f);
                }
                return(null);

            case CGPDFObjectType.Name:
                if (CGPDFObjectGetValue(handle, type, out ip))
                {
                    return(Marshal.PtrToStringAnsi(ip));
                }
                return(null);

            case CGPDFObjectType.String:
                if (CGPDFObjectGetValue(handle, type, out ip))
                {
                    return(CGPDFString.ToString(ip));
                }
                return(null);

            case CGPDFObjectType.Array:
                if (CGPDFObjectGetValue(handle, type, out ip))
                {
                    return(new CGPDFArray(ip));
                }
                return(null);

            case CGPDFObjectType.Dictionary:
                if (CGPDFObjectGetValue(handle, type, out ip))
                {
                    return(new CGPDFDictionary(ip));
                }
                return(null);

            case CGPDFObjectType.Stream:
                if (CGPDFObjectGetValue(handle, type, out ip))
                {
                    return(new CGPDFStream(ip));
                }
                return(null);
            }
            return(null);
        }