Class PdfDocumentAnalyzer
Represents the analyzer of the Pdf document.
Inheritance
Inherited Members
Namespace: Syncfusion.Pdf.Parsing
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfDocumentAnalyzer
Constructors
PdfDocumentAnalyzer(Stream)
Initializes a new instance of the PdfDocumentAnalyzer class with the specified stream.
Declaration
public PdfDocumentAnalyzer(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream containing the PDF document to analyze. |
Examples
string filePath = "Input.pdf";
Stream streamFile = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
load the stream
PdfDocumentAnalyzer analyzer = new PdfDocumentAnalyzer(streamFile);
//Analyze syntax issues.
SyntaxAnalyzerResult analyzerResult = analyzer.AnalyzeSyntax();
if(analyzerResult.IsCorrupted)
{
throw new Exception("The document is corrupt");
}
analyzer.Close();
PdfDocumentAnalyzer(Stream, String)
Initializes a new instance of the PdfDocumentAnalyzer class.
Declaration
public PdfDocumentAnalyzer(Stream stream, string password)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | The stream containing the PDF document to analyze. |
System.String | password | The password (user or owner) of the encrypted document. |
Examples
string filePath = "Input.pdf";
Stream streamFile = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read, FileShare.Read);
load the stream with password
PdfDocumentAnalyzer analyzer = new PdfDocumentAnalyzer(streamFile, "passsword");
//Analyze the syntax issues.
SyntaxAnalyzerResult analyzerResult = analyzer.AnalyzeSyntax();
if(analyzerResult.IsCorrupted)
{
throw new Exception("The document is corrupt");
}
analyzer.Close();
PdfDocumentAnalyzer(String)
Initializes a new instance of the PdfDocumentAnalyzer class with the specified input file path.
Declaration
public PdfDocumentAnalyzer(string filePath)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | A relative or absolute path for the file. |
Remarks
This constructor is supported in .NET 8.0 and later. It requires the application to run in an environment with file system access. For restricted environments use the PdfDocumentAnalyzer(Stream) method instead.
Examples
string filePath = "Input.pdf";
//load the document
PdfDocumentAnalyzer analyzer = new PdfDocumentAnalyzer(filePath);
//Analyze the synyax issue
SyntaxAnalyzerResult analyzerResult = analyzer.AnalyzeSyntax();
if(analyzerResult.IsCorrupted)
{
throw new Exception("The document is corrupt");
}
analyzer.Close();
PdfDocumentAnalyzer(String, String)
Initializes a new instance of the PdfDocumentAnalyzer class.
Declaration
public PdfDocumentAnalyzer(string filePath, string password)
Parameters
Type | Name | Description |
---|---|---|
System.String | filePath | A relative or absolute path for the file. |
System.String | password | The password (user or owner) of the encrypted document. |
Remarks
This constructor is supported in .NET 8.0 and later. It requires the application to run in an environment with file system access. For restricted environments use the PdfDocumentAnalyzer(Stream, String) method instead.
Examples
string filePath = "Input.pdf";
//load the document
PdfDocumentAnalyzer analyzer = new PdfDocumentAnalyzer(filePath, "password");
//Analyze the synyax issue
SyntaxAnalyzerResult analyzerResult = analyzer.AnalyzeSyntax();
if(analyzerResult.IsCorrupted)
{
throw new Exception("The document is corrupt");
}
analyzer.Close();
Methods
AnalyzeSyntax()
Analyze the given PDF file and check whether any syntax issues found.
Declaration
public SyntaxAnalyzerResult AnalyzeSyntax()
Returns
Type |
---|
SyntaxAnalyzerResult |
Examples
string filePath = "Input.pdf";
//load the document
PdfDocumentAnalyzer analyzer = new PdfDocumentAnalyzer(filePath);
//Analyze the synyax issue
SyntaxAnalyzerResult analyzerResult = analyzer.AnalyzeSyntax();
if(analyzerResult.IsCorrupted)
{
throw new Exception("The document is corrupt");
}
analyzer.Close();
Close()
Close the PdfDocumentAnalyzer class.
Declaration
public void Close()
Examples
string filePath = "Input.pdf";
//load the document
PdfDocumentAnalyzer analyzer = new PdfDocumentAnalyzer(filePath);
//Analyze the syntax issues.
SyntaxAnalyzerResult analyzerResult = analyzer.AnalyzeSyntax();
if(analyzerResult.IsCorrupted)
{
throw new Exception("The document is corrupt");
}
analyzer.Close();