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


C# Doc.Read方法代码示例

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


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

示例2: Main

        static void Main(string[] args)
        {
            var theDoc = new Doc();

            theDoc.Read("C:\\FileServer\\test.pdf");

            theDoc.Rendering.DotsPerInch = 200;
            
            for (int i = 0; i < 4; i++)
            {
                theDoc.PageNumber = i;
                theDoc.Rect.String = theDoc.CropBox.String;
                theDoc.Rendering.Save("C:\\FileServer\\" + i.ToString(CultureInfo.InvariantCulture) + ".JPG");
            }
        }
开发者ID:alqadasifathi,项目名称:OfficeTools.Pdf2Image.Word2Image,代码行数:15,代码来源:Program.cs

示例3: GetNumberOfPages

        private int GetNumberOfPages(string url, string extension, int marginLeft, int marginTop)
        {
            this.margineLeft = marginLeft;
            this.margineTop = marginTop;
            this.url = url;
            int PageCount = 0;
            bool isLogged = Boolean.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings[constLog]);
            // This code line sets the license key to the Doc object
            XSettings.InstallRedistributionLicense(System.Web.Configuration.WebConfigurationManager.AppSettings[constLicenseKey]);

            //Create a new Doc

            switch (extension)
            {
                //If the url is a pdf file
                case PDF:
                    byte[] buffer = new byte[4096];
                    int count = 0;
                    byte[] pdfBytes = null;

                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        WebRequest webRequest = WebRequest.Create(url);
                        WebResponse webResponse = webRequest.GetResponse();
                        Stream stream = webResponse.GetResponseStream();
                        do
                        {
                            count = stream.Read(buffer, 0, buffer.Length);
                            memoryStream.Write(buffer, 0, count);

                        } while (count != 0);

                        pdfBytes = memoryStream.ToArray();

                    }
                    using (Doc theDoc = new Doc())
                    {
                        theDoc.HtmlOptions.UseScript = true;
                        theDoc.HtmlOptions.UseActiveX = true;
                        theDoc.HtmlOptions.UseVideo = true;
                        theDoc.HtmlOptions.PageCacheEnabled = true;
                        theDoc.HtmlOptions.Timeout = 120000;
                        theDoc.Rect.Inset(marginLeft, marginTop);
                        theDoc.Read(pdfBytes);
                        PageCount = theDoc.PageCount;
                    }
                    return PageCount;
                //break;
                default:
                    using (Doc htmlDoc = new Doc())
                    {
                        //Start new thread to generate images when user call GetNumberOfPages method
                        htmlDoc.HtmlOptions.UseScript = true; // Enable javascript at the startup time
                        htmlDoc.HtmlOptions.UseActiveX = true; // Enable SVG
                        htmlDoc.HtmlOptions.UseVideo = true; // Enable Video
                        htmlDoc.HtmlOptions.Timeout = 120000;
                        // Time out is 2 minutes for ABCPDF .NET Doc calls the url to get the html
                        htmlDoc.HtmlOptions.PageCacheEnabled = true; // Enable ABCPDF .NET page cache
                        htmlDoc.Rect.Inset(marginLeft, marginTop); // Insert the margin left and margin top
                        htmlDoc.Page = htmlDoc.AddPage();

                        int theID = htmlDoc.AddImageUrl(url.ToString());
                        // Now chain subsequent pages together. Stop when reach a page which wasn't truncated.
                        while (true)
                        {
                            if (!htmlDoc.Chainable(theID))
                                break;
                            htmlDoc.Page = htmlDoc.AddPage();
                            htmlDoc.Rendering.DotsPerInch = constDotPerInches; // set DPI = 150
                            htmlDoc.Rendering.SaveQuality = constSaveQuality; // set Quality = 100
                            theID = htmlDoc.AddImageToChain(theID);
                        }
                        if (htmlDoc != null)
                            return htmlDoc.PageCount;
                    }
                    break;
            }
            return 0;
        }
开发者ID:srscopyright,项目名称:FilseServerTest9,代码行数:79,代码来源:PrintService.cs

示例4: ConvertPdfToImage

        private Stream ConvertPdfToImage(string url, int marginLeft, int marginTop, int page)
        {
            Stream returnStream = null;

            byte[] buffer = new byte[4096];
            int count = 0;
            byte[] pdfBytes = null;
            XSettings.InstallRedistributionLicense(System.Web.Configuration.WebConfigurationManager.AppSettings[constLicenseKey]);

            using (MemoryStream memoryStream = new MemoryStream())
            {
                WebRequest webRequest = WebRequest.Create(url);
                WebResponse webResponse = webRequest.GetResponse();

                Stream stream = webResponse.GetResponseStream();
                do
                {
                    count = stream.Read(buffer, 0, buffer.Length);
                    memoryStream.Write(buffer, 0, count);

                } while (count != 0);

                pdfBytes = memoryStream.ToArray();
            }

            using (Doc theDoc = new Doc())
            {
                theDoc.HtmlOptions.UseScript = true;
                theDoc.HtmlOptions.UseActiveX = true; // Enalbe SVG
                theDoc.HtmlOptions.UseVideo = true;
                theDoc.HtmlOptions.PageCacheEnabled = true; //Enable cache
                theDoc.HtmlOptions.Timeout = 120000;
                theDoc.Rect.Inset(marginLeft, marginTop);
                theDoc.Read(pdfBytes);
                theDoc.PageNumber = page;
                theDoc.Rendering.DotsPerInch = constDotPerInches;
                theDoc.Rendering.SaveQuality = constSaveQuality;
                theDoc.Flatten();

                //Each page of pdf will be returned as a byte array

                byte[] images = theDoc.Rendering.GetData("abc.png");
                returnStream = new MemoryStream(images);
                theDoc.Clear();
            }
            return returnStream;
        }
开发者ID:srscopyright,项目名称:FilseServerTest9,代码行数:47,代码来源:PrintService.cs

示例5: CreateTestDoc

		private Doc CreateTestDoc(int assessmentID, List<AssessmentPrintBatchHelper> assessmentPrintBatchHelpers, Doc doc, string imagesUrl,bool isAdminInst=false)
        {
            /*  Modified to add uploaded document */
            int userID = SessionObject.LoggedInUser.Page;
            var assessmentInfo = Assessment.GetConfigurationInformation(assessmentID, userID);
            var contentType = assessmentInfo.ContentType;
            bool stringCompareResult = contentType.Equals(_externalTestType, StringComparison.OrdinalIgnoreCase);
            bool noDataFlag = true;

            if (!contentType.Equals(_externalTestType, StringComparison.OrdinalIgnoreCase))    // Is this an External Test
            {
                doc = Assessment.RenderAssessmentToPdf_Batch(assessmentID, assessmentPrintBatchHelpers, imagesUrl, isAdminInst); // Not an External Document
                noDataFlag = false;
            }
            else
            {
                foreach (var assessmentPrintBatchHelper in assessmentPrintBatchHelpers)  //Test Can have multiple Forms (Example: Form 201, Form 101, form 301, etc.)
                {
                    DataTable tbl = Assessment.GetDocs(assessmentID);
                    string tempFile = string.Empty;
                    string AnswerKeyTempFile = tbl.Rows[0][_answerKeyFile].ToString();
                    string[] attachmentTypes = { _assementFile, _reviewerFile, _answerKeyFile };  //rename formNames Attacment types
                   
                    /** Print Uploaded Assessment file **/
                    foreach (string attachmentType in attachmentTypes)
                    {
                        if (!string.IsNullOrEmpty(tbl.Rows[0][attachmentType].ToString()))
                        {
                            tempFile = tbl.Rows[0][attachmentType].ToString();
                            using (Doc externalDoc = new Doc())
                            {
                                int docCount = 0;
                                switch (attachmentType)
                                {
                                    case _assementFile:
                                        docCount = assessmentPrintBatchHelper.AssessmentCount;
                                        break;
                                    case _reviewerFile:
                                        docCount = assessmentPrintBatchHelper.AssessmentCount;
                                        break;
                                    case _answerKeyFile:
                                        docCount = assessmentPrintBatchHelper.AnswerKeyCount;
                                        break;
                                }
                                externalDoc.Read(Server.MapPath("~/upload/" + tempFile));

                                for (int j = 0; j < docCount; j++)
                                {
                                    doc.Append(externalDoc);
                                    noDataFlag = false;
                                }
                            }
                             
                        }                        
                    }


                    //Ashley Reeves said that the Answer Key must Print if there is no enternal file loaded - Reference TFS Bug 1350
                    if (string.IsNullOrEmpty(AnswerKeyTempFile) && assessmentPrintBatchHelper.AnswerKeyCount > 0)
                    {
                        Doc answerKeyDoc = new Doc();
                        answerKeyDoc = Assessment.RenderAssessmentToPdf(assessmentID, assessmentPrintBatchHelper.FormID, PdfRenderSettings.PrintTypes.AnswerKey, isAdminInst);
                        //answerKeyDoc = Assessment.RenderAssessmentAnswerKeyToPdf_Batch(assessmentID, assessmentPrintBatchHelpers); // Not an External Document
                        for (int j = 0; j < assessmentPrintBatchHelper.AnswerKeyCount; j++)
                        {
                            doc.Append(answerKeyDoc);
                            noDataFlag = false;
                        }
                        answerKeyDoc.Dispose();
                    }
                    //1-30-2014 Bug 13579:Print on External Assessment with Rubric should print Rubric and not blank pdf
                    if (assessmentPrintBatchHelper.RubricCount > 0)
                    {
                        Doc RubricDoc = new Doc();
                        RubricDoc = Assessment.RenderAssessmentToPdf(assessmentID, assessmentPrintBatchHelper.FormID, PdfRenderSettings.PrintTypes.Rubric, isAdminInst);
                        for (int j = 0; j < assessmentPrintBatchHelper.RubricCount; j++)
                        {
                            doc.Append(RubricDoc);
                            noDataFlag = false;
                        }
                        RubricDoc.Dispose();
                    }
                    //END 1-30-2014 Bug 13579
                }
                #region JavaScript
                //string scriptName = "MasterJavaScript";
                //string myScriptName = "CustomMessage";
                //if (noDataFlag && !ClientScript.IsClientScriptBlockRegistered(scriptName) && !ClientScript.IsClientScriptBlockRegistered(myScriptName))  //Verify script isn't already registered
                //{

                //    string masterJavaScriptText = string.Empty;
                //    string filePath = Server.MapPath("~/Scripts/master.js");
                //    using (StreamReader MasterJavaScriptFile = new StreamReader(filePath))
                //    {
                //        masterJavaScriptText = MasterJavaScriptFile.ReadToEnd();
                //    }
                //    if (!string.IsNullOrEmpty(masterJavaScriptText))
                //    {
                //        ClientScript.RegisterClientScriptBlock(this.GetType(), scriptName, masterJavaScriptText);

//.........这里部分代码省略.........
开发者ID:ezimaxtechnologies,项目名称:ASP.Net,代码行数:101,代码来源:RenderAssessmentAsPDF.aspx.cs


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