Class QPdfClient<T>
Inheritance
Implements
Namespace: IronSoftware.Pdfium
Assembly: IronPdf.dll
Syntax
public abstract class QPdfClient<T> : Object, IDisposable, IQPdfClient where T : QPdfDeploymentBase
Type Parameters
| Name | Description |
|---|---|
| T |
Constructors
QPdfClient(Boolean)
Declaration
protected QPdfClient(bool deployQpdf = true)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | deployQpdf |
Methods
CompleteSavingAsPdfA4(IDocumentId, String, String)
Applies final PDF/A-4 specific flags and saves the provided PDF content using QPdf.
Declaration
public void CompleteSavingAsPdfA4(IDocumentId documentId, string outputPath, string password = "")
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Abstractions.Pdf.IDocumentId | documentId | The id of the input document. |
| System.String | outputPath | The file path where the PDF should be saved. |
| System.String | password | An optional password to encrypt the PDF. Pass |
Remarks
Note: IronSoftware.Pdfium.IPdfClient.ConvertToPdfA(IronSoftware.Abstractions.Pdf.IDocumentId,System.Byte[],IronPdf.InternalPdfAVersion) should be called before invoking this method to perform the actual conversion.
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentNullException | Thrown if |
| System.IO.IOException | Thrown if there is an error retrieving the PDF bytes from the native PDF library. |
| System.Exception | Thrown if the QPdf handle creation, reading, initialization, or writing fails. |
CompleteSavingAsPdfUA2(IDocumentId, String, String)
Declaration
public void CompleteSavingAsPdfUA2(IDocumentId documentId, string outputPath, string password = "")
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Abstractions.Pdf.IDocumentId | documentId | |
| System.String | outputPath | |
| System.String | password |
CompressAndSaveAs(IDocumentId, String, QPdfCompressionFlags, String)
Save the document referenced by id using the supplied QPdfCompressionFlags. Builds a richer QPdfJob configuration than the int-jpeg overload so that text-heavy documents pick up structural optimisations (content-stream coalescing, generalized stream re-encoding) in addition to image compression.
Declaration
public void CompressAndSaveAs(IDocumentId id, string filename, QPdfCompressionFlags flags, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Abstractions.Pdf.IDocumentId | id | |
| System.String | filename | |
| QPdfCompressionFlags | flags | |
| System.String | password |
CompressAndSaveAs(IDocumentId, String, Nullable<Int32>, String)
Save PDF document with compression applied
Declaration
public void CompressAndSaveAs(IDocumentId id, string filename, Nullable<int> jpeg, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Abstractions.Pdf.IDocumentId | id | id of the document |
| System.String | filename | path where the compressed file will be saved |
| System.Nullable<System.Int32> | jpeg | optional JPEG quality (1-100). If null, image optimization will not be applied |
| System.String | password | password of the pdf content |
CompressAndSaveAs(Byte[], String, QPdfCompressionFlags, String)
Save raw PDF bytes using the supplied QPdfCompressionFlags.
Declaration
public void CompressAndSaveAs(byte[] pdfBytes, string filename, QPdfCompressionFlags flags, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | |
| System.String | filename | |
| QPdfCompressionFlags | flags | |
| System.String | password |
CompressAndSaveAs(Byte[], String, Nullable<Int32>, String)
Save PDF document with compression applied
Declaration
public void CompressAndSaveAs(byte[] pdfBytes, string filename, Nullable<int> jpeg, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | PDF bytes to compress |
| System.String | filename | path where the compressed file will be saved |
| System.Nullable<System.Int32> | jpeg | optional JPEG quality (1-100). If null, image optimization will not be applied |
| System.String | password | password of the pdf content |
CompressInMemory(IDocumentId, QPdfCompressionFlags, String)
Compresses a PDF referenced by id in memory with the supplied advanced flags. See the byte[] overload for the list of flags this code path can honour.
Declaration
public byte[] CompressInMemory(IDocumentId id, QPdfCompressionFlags flags, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Abstractions.Pdf.IDocumentId | id | |
| QPdfCompressionFlags | flags | |
| System.String | password |
Returns
| Type | Description |
|---|---|
| System.Byte[] |
CompressInMemory(IDocumentId, String)
Compresses the PDF document specified by its ID entirely in memory.
This method retrieves the document bytes from the native and performs structural compression (Object Streams, Flate) without writing to disk.
Declaration
public byte[] CompressInMemory(IDocumentId id, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Abstractions.Pdf.IDocumentId | id | The ID of the document to compress. |
| System.String | password | The password if the document is encrypted. |
Returns
| Type | Description |
|---|---|
| System.Byte[] | A byte array containing the compressed PDF data. |
Exceptions
| Type | Condition |
|---|---|
| System.Exception | Thrown if document bytes cannot be retrieved from the native library. |
CompressInMemory(Byte[], QPdfCompressionFlags, String)
Compresses raw PDF bytes in memory using the subset of QPdfCompressionFlags that the handle-level QPdf API exposes.
Honoured in this mode:RemoveUnreferencedResources.
Object-stream generation, stream-data compression, and stream
recompression are always applied as part of the in-memory pipeline.
Ignored in this mode (no equivalent in the C handle API):
CoalesceContents, DecodeGeneralizedStreams,
RecompressFlate, custom CompressionLevel,
OptimizeImages + JpegQuality +
OptimizeImagesMin*. Callers that need any of those must use
the disk-backed CompressAndSaveAs path
(
Declaration
public byte[] CompressInMemory(byte[] pdfBytes, QPdfCompressionFlags flags, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | |
| QPdfCompressionFlags | flags | |
| System.String | password |
Returns
| Type | Description |
|---|---|
| System.Byte[] |
CompressInMemory(Byte[], String)
Compresses raw PDF bytes entirely in memory using structural optimization.
Declaration
public byte[] CompressInMemory(byte[] pdfBytes, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | The raw byte array of the PDF to compress. |
| System.String | password | The password if the document is encrypted. |
Returns
| Type | Description |
|---|---|
| System.Byte[] | A byte array containing the compressed PDF data. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown if |
| System.Exception | Thrown if the native QPdf initialization or writing fails. |
Dispose()
Declaration
public virtual void Dispose()
IsLinearized(String, String)
Check if a file is linearized or not
Declaration
public bool IsLinearized(string path, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | path | file path where the linearized file is located |
| System.String | password | password of the pdf content |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the file is linearized, otherwise returns false |
LinearizeInMemory(IDocumentId, String)
Linearizes the PDF document specified by its ID entirely in memory.
This method retrieves the document bytes from the native and performs linearization without writing to disk.
Declaration
public byte[] LinearizeInMemory(IDocumentId id, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Abstractions.Pdf.IDocumentId | id | The ID of the document to linearize. |
| System.String | password | The password if the document is encrypted. |
Returns
| Type | Description |
|---|---|
| System.Byte[] | A byte array containing the linearized PDF data. |
Exceptions
| Type | Condition |
|---|---|
| System.Exception | Thrown if document bytes cannot be retrieved from the native library. |
LinearizeInMemory(Byte[], String)
Linearizes raw PDF bytes entirely in memory.
Declaration
public byte[] LinearizeInMemory(byte[] pdfBytes, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | The raw byte array of the PDF to linearize. |
| System.String | password | The password if the document is encrypted. |
Returns
| Type | Description |
|---|---|
| System.Byte[] | A byte array containing the linearized PDF data. |
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | Thrown if |
| System.Exception | Thrown if the native QPdf initialization or writing fails. |
SaveAsJson(Byte[], String, String, QPdfJsonOptions)
Saves PDF document as JSON file with custom options
Declaration
public void SaveAsJson(byte[] pdfBytes, string outputPath, string password, QPdfJsonOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | PDF document bytes |
| System.String | outputPath | Output JSON file path |
| System.String | password | PDF password if encrypted |
| QPdfJsonOptions | options | JSON conversion options |
SaveAsJsonAsync(Byte[], String, String, QPdfJsonOptions)
Async version of SaveAsJson with options
Declaration
public Task SaveAsJsonAsync(byte[] pdfBytes, string outputPath, string password, QPdfJsonOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | |
| System.String | outputPath | |
| System.String | password | |
| QPdfJsonOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task |
SaveAsLinearized(IDocumentId, String, String)
Save PDF document as a linearized PDF file
Declaration
public void SaveAsLinearized(IDocumentId id, string path, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Abstractions.Pdf.IDocumentId | id | id of the document |
| System.String | path | path where the linearized file will be saved |
| System.String | password | password of the pdf content |
SaveAsLinearized(Byte[], String, String)
Save PDF document as a linearized PDF file
Declaration
public void SaveAsLinearized(byte[] pdfBytes, string path, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | |
| System.String | path | path where the linearized file will be saved |
| System.String | password | password of the pdf content |
ToJson(Byte[], String, QPdfJsonOptions)
Converts PDF document to JSON format with custom options
Declaration
public string ToJson(byte[] pdfBytes, string password, QPdfJsonOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | PDF document bytes |
| System.String | password | PDF password if encrypted |
| QPdfJsonOptions | options | JSON conversion options |
Returns
| Type | Description |
|---|---|
| System.String | JSON string representation of the PDF |
ToJson(Byte[], String, TextWriter, QPdfJsonOptions)
Converts PDF document to JSON format using TextWriter
Declaration
public void ToJson(byte[] pdfBytes, string password, TextWriter writer, QPdfJsonOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | PDF document bytes |
| System.String | password | PDF password if encrypted |
| System.IO.TextWriter | writer | TextWriter to write JSON to |
| QPdfJsonOptions | options | JSON conversion options |
ToJson(Byte[], String, StringBuilder, QPdfJsonOptions)
Converts PDF document to JSON format using StringBuilder
Declaration
public void ToJson(byte[] pdfBytes, string password, StringBuilder builder, QPdfJsonOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | PDF document bytes |
| System.String | password | PDF password if encrypted |
| System.Text.StringBuilder | builder | StringBuilder to append JSON to |
| QPdfJsonOptions | options | JSON conversion options |
ToJsonAsync(Byte[], String, QPdfJsonOptions)
Async version of ToJson with options
Declaration
public Task<string> ToJsonAsync(byte[] pdfBytes, string password, QPdfJsonOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfBytes | |
| System.String | password | |
| QPdfJsonOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.String> |