{"id":23060881,"url":"https://github.com/syncfusionexamples/find-corrupted-pdf-files-csharp-vb-net","last_synced_at":"2025-08-15T08:32:13.159Z","repository":{"id":98095162,"uuid":"210555754","full_name":"SyncfusionExamples/find-corrupted-pdf-files-csharp-vb-net","owner":"SyncfusionExamples","description":"This repo contains the examples about how to find the corrupted PDF files using Syncfusion's C# PDF library.","archived":false,"fork":false,"pushed_at":"2024-12-02T11:20:29.000Z","size":29,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-12-02T12:25:59.224Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SyncfusionExamples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-24T08:49:37.000Z","updated_at":"2024-10-21T07:31:30.000Z","dependencies_parsed_at":"2024-12-02T19:19:19.693Z","dependency_job_id":null,"html_url":"https://github.com/SyncfusionExamples/find-corrupted-pdf-files-csharp-vb-net","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Ffind-corrupted-pdf-files-csharp-vb-net","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Ffind-corrupted-pdf-files-csharp-vb-net/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Ffind-corrupted-pdf-files-csharp-vb-net/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SyncfusionExamples%2Ffind-corrupted-pdf-files-csharp-vb-net/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SyncfusionExamples","download_url":"https://codeload.github.com/SyncfusionExamples/find-corrupted-pdf-files-csharp-vb-net/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229901552,"owners_count":18141741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-16T03:15:35.862Z","updated_at":"2024-12-16T03:15:36.433Z","avatar_url":"https://github.com/SyncfusionExamples.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Easy way to find the corrupted PDF files in C#\n\nYou might have a lot of PDF files in your disc or database; you need to find out the corrupted files and take necessary actions. But it is not possible for you to open every single file with a PDF reader to check whether it is corrupted or not. \n\nTo save your effort and time, [Syncfusion\u0026reg; PDF library](https://www.syncfusion.com/pdf-framework/net/pdf-library) provides you the support to identify the corrupted PDF files using C#, VB.NET by checking whether the PDF format syntax are proper. \n\nLet’s dive into the details about how to find the corrupted PDF files.\n\n* [PdfDocumentAnalyzer](https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Base~Syncfusion.Pdf.Parsing.PdfDocumentAnalyzer.html) class is used to find the corrupted PDF files by analyzing the PDF document structure and syntax. \n* [AnalyzeSyntax()](https://help.syncfusion.com/cr/cref_files/file-formats/Syncfusion.Pdf.Base~Syncfusion.Pdf.Parsing.PdfDocumentAnalyzer~AnalyzeSyntax.html) method of PdfDocumentAnalyzer class will invoke analysis of the PDF document structure and syntax and returns the result (an instance of [SyntaxAnalyzerResult](https://help.syncfusion.com/cr/file-formats/Syncfusion.Pdf.Base~Syncfusion.Pdf.Parsing.SyntaxAnalyzerResult.html)).\n* [IsCorrupted](https://help.syncfusion.com/cr/cref_files/file-formats/Syncfusion.Pdf.Base~Syncfusion.Pdf.Parsing.SyntaxAnalyzerResult~IsCorrupted.html) property of SyntaxAnalyzerResult is used to identify whether the processed PDF file is corrupted or not.\n\nUsing these APIs, you can ensure that the PDF document is not corrupted and then start processing it.\n\nFor example:\n\n1. To avoid uploading corrupted any PDF report or resume to your web applications.\n1. To avoid unexpected behavior or hanging when invoking PDF print programmatically.\n\nThe following code example will check whether the given PDF file is corrupted or not.\n\n```C#\nusing Syncfusion.Pdf;\nusing Syncfusion.Pdf.Parsing;\nusing System;\nusing System.IO;\nusing System.Text;\n\nnamespace find_corrupted_pdf_file_demo\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            //Load the PDF file as stream\n            using (FileStream pdfStream = new FileStream(“inputFile.pdf\", FileMode.Open, FileAccess.Read))\n            {\n                //Create a new instance of PDF document syntax analyzer.\n                PdfDocumentAnalyzer analyzer = new PdfDocumentAnalyzer(pdfStream);\n                //Analyze the syntax and return the results\n                SyntaxAnalyzerResult analyzerResult = analyzer.AnalyzeSyntax();\n\n                //Check whether the document is corrupted or not\n                if (analyzerResult.IsCorrupted)\n                {\n                    StringBuilder strBuilder = new StringBuilder();\n                    strBuilder.AppendLine(\"The PDF document is corrupted.\");\n                    int count = 1;\n                    foreach (PdfException exception in analyzerResult.Errors)\n                    {\n                        strBuilder.AppendLine(count++.ToString() + \": \" + exception.Message);\n                    }\n                    Console.WriteLine(strBuilder);\n                }\n                else\n                {\n                    Console.WriteLine(\"No syntax error found in the provided PDF document\");\n                }\n                analyzer.Close();\n            }   \n        }\n    }\n}\n\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncfusionexamples%2Ffind-corrupted-pdf-files-csharp-vb-net","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyncfusionexamples%2Ffind-corrupted-pdf-files-csharp-vb-net","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncfusionexamples%2Ffind-corrupted-pdf-files-csharp-vb-net/lists"}