当前位置: 首页>>代码示例>>C#>>正文


C# Doc.GetInfoInt方法代码示例

本文整理汇总了C#中Doc.GetInfoInt方法的典型用法代码示例。如果您正苦于以下问题:C# Doc.GetInfoInt方法的具体用法?C# Doc.GetInfoInt怎么用?C# Doc.GetInfoInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doc的用法示例。


在下文中一共展示了Doc.GetInfoInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        private static void Main(string[] args)
        {
            // install your own licence

            using (Doc doc = new Doc())
            {
                doc.Read("in.pdf"); // in this PDF the image has an embedded ICC profile, and I must remove them

                Console.WriteLine("################################ THROUGH GETINFO ################################");

                // Remove the ICC profiles through Get/SetInfo methods
                foreach (var item in doc.ObjectSoup)
                {
                    if (item != null && doc.GetInfo(item.ID, "/ColorSpace*[0]*:Name").Equals("ICCBased", StringComparison.InvariantCultureIgnoreCase))
                    {
                        int profileId = doc.GetInfoInt(item.ID, "/ColorSpace*[1]:Ref"); // note the [1]: why is it there?
                        if (profileId != 0)
                        {
                            doc.GetInfo(profileId, "Decompress");
                            string profileData = doc.GetInfo(profileId, "Stream");

                            // this outputs the ICC profile raw data, with the profile's name somewhere up top
                            Console.WriteLine(string.Format("ICC profile for object ID {0}: {1}", item.ID, profileData)); 

                            doc.SetInfo(profileId, "Stream", string.Empty);
                            doc.GetInfo(profileId, "Compress");
                        }
                    }
                }

                doc.Save("out-infos.pdf");
                doc.Clear();
                doc.Read("in.pdf");

                Console.WriteLine("################################ THROUGH OBJECTS ################################");

                // Remove ICC profiles through the pixmap objects
                foreach (var item in doc.ObjectSoup)
                {
                    if (doc.GetInfo(item.ID, "Type") == "jpeg") // only work on PixMaps
                    {
                        PixMap pm = (PixMap)item;
                        if (pm.ColorSpaceType == ColorSpaceType.ICCBased)
                        {
                            // pm.ColorSpace.IccProfile is always null so I can't really set it to null or Recolor() it because it would change noting
                            Console.WriteLine(string.Format("ICC profile for object ID {0}: {1}", item.ID, pm.ColorSpace.IccProfile)); // there should already be an ICC profile (ColorSpaceType = ICCBased) so why does ColorSpace.IccProfile creates one ?
                        }
                    }
                }

                doc.Save("out-objects.pdf");
            }
        }
开发者ID:tbroust-trepia,项目名称:abcpdf8-icc-profiles,代码行数:53,代码来源:Program.cs


注:本文中的Doc.GetInfoInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。