diff --git a/net/_index.md b/net/_index.md index 9e6fd0c..ef5ea96 100644 --- a/net/_index.md +++ b/net/_index.md @@ -60,7 +60,7 @@ GroupDocs.Viewer ships with a wide range of options that allow you to control th diff --git a/net/developer-guide/loading-documents/detect-encoding-when-loading-documents.md b/net/developer-guide/loading-documents/detect-encoding-when-loading-documents.md new file mode 100644 index 0000000..f002e5a --- /dev/null +++ b/net/developer-guide/loading-documents/detect-encoding-when-loading-documents.md @@ -0,0 +1,35 @@ +--- +id: detect-encoding-when-loading-documents +url: viewer/net/detect-encoding-when-loading-documents +title: Detect encoding when loading documents +weight: 5 +description: "This article explains how to detect encoding when loading documents with GroupDocs.Viewer within your .NET applications." +keywords: get encoding, detect encoding +productName: GroupDocs.Viewer for .NET +hideChildren: False +--- +You can detect the file encoding using [LoadOptions](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/loadoptions). If the encoding cannot be detected the default, GroupDocs.Viewer uses the default [encoding]({{< ref "viewer/net/developer-guide/loading-documents/specify-encoding-when-loading-documents.md" >}}). + +This feature is supported for the following documents: + +* [Plain-text (.txt) files](https://docs.fileformat.com/word-processing/txt/) +* [Comma-separated values (.csv)](https://docs.fileformat.com/spreadsheet/csv/) +* [Tab-separated values (.tsv)](https://docs.fileformat.com/spreadsheet/tsv/) + +The following code snippet shows how to detect the document encoding: + +{{< tabs "example1">}} +{{< tab "C#" >}} +```csharp +LoadOptions loadOptions = new LoadOptions(); +loadOptions.DetectEncoding = true; // Enable encoding detection + +using (Viewer viewer = new Viewer("employees.csv", loadOptions)) +{ + HtmlViewOptions viewOptions = HtmlViewOptions.ForEmbeddedResources(); + + viewer.View(viewOptions); +} +``` +{{< /tab >}} +{{< /tabs >}} diff --git a/net/developer-guide/loading-documents/loading-external-resources.md b/net/developer-guide/loading-documents/loading-external-resources.md index d773a34..3191f04 100644 --- a/net/developer-guide/loading-documents/loading-external-resources.md +++ b/net/developer-guide/loading-documents/loading-external-resources.md @@ -2,7 +2,7 @@ id: loading-external-resources url: viewer/net/loading-external-resources title: Loading of external resources containing by a document -weight: 5 +weight: 6 keywords: set timeout, Groupdocs.Viewer description: "This article explains how to manage loading of external resources contained by a document with GroupDocs.Viewer within your .NET applications." productName: GroupDocs.Viewer for .NET diff --git a/net/developer-guide/processing-attachments/_index.md b/net/developer-guide/processing-attachments/_index.md deleted file mode 100644 index 0200840..0000000 --- a/net/developer-guide/processing-attachments/_index.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -id: working-with-attachments -url: viewer/net/working-with-attachments -title: Process attachments -weight: 4 -description: "Processing email attachments, embedded files, and compressed files with GroupDocs.Viewer for .NET" -keywords: email attachments, embedded files, compressed files -productName: GroupDocs.Viewer for .NET -hideChildren: False ---- - -Using GroupDocs.Viewer, you can list and save the following attachments: - -* Email attachments -* Files embedded in PDF files -* Email messages contained by Outlook, LotusNotes and other storage files -* Compressed files - -See following examples on how to process document attachments in more details: diff --git a/net/developer-guide/processing-attachments/how-to-convert-and-view-attachments.md b/net/developer-guide/processing-attachments/how-to-convert-and-view-attachments.md deleted file mode 100644 index 2043885..0000000 --- a/net/developer-guide/processing-attachments/how-to-convert-and-view-attachments.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -id: how-to-convert-and-view-attachments -url: viewer/net/how-to-convert-and-view-attachments -title: Render attachments -weight: 3 -description: "Render email attachments with GroupDocs.Viewer for .NET in the same way as you would render any other documents" -keywords: Render email attachments -productName: GroupDocs.Viewer for .NET -hideChildren: False ---- - -Render attachments in the same way as any other documents. - -To view attachments, follow these steps: - -1. Instantiate the first [Viewer](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer) object. Specify a file that contains attachments. -2. Call the [SaveAttachment](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/saveattachment) method to save the attachment (to local disk, memory stream, etc). -3. Instantiate the second [Viewer](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer) object. Specify the previously saved attachment. -4. Specify the view options depending on the output format - [HtmlViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/htmlviewoptions)/[PngViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/pngviewoptions)/[JpgViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/jpgviewoptions)/[PdfViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/pdfviewoptions). -5. Call the [View](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/view) method. - -The following code snippet shows how to render attachments from the MSG file: - -{{< alert style="info" >}}NOTE: provided code snippet suits all format families that support attachments: emails, Outlook data files, archives, and PDF documents.{{< /alert >}} - -{{< tabs "example1">}} -{{< tab "C#" >}} -```csharp -// Specify attachment. -Attachment attachment = new Attachment("attachment-word.doc", @"C:\Output\attachment-word.doc"); -// Create a stream for attachment. -MemoryStream attachmentStream = new MemoryStream(); -//Save attachment -using (Viewer viewer = new Viewer("sample.msg")) -{ - viewer.SaveAttachment(attachment, attachmentStream); -} -// Render attachment -using (Viewer viewer = new Viewer(attachmentStream)) -{ - HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(); - viewer.View(options); -} -``` -{{< /tab >}} -{{< /tabs >}} diff --git a/net/developer-guide/processing-attachments/how-to-extract-and-save-attachments.md b/net/developer-guide/processing-attachments/how-to-extract-and-save-attachments.md deleted file mode 100644 index ae734a4..0000000 --- a/net/developer-guide/processing-attachments/how-to-extract-and-save-attachments.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -id: how-to-extract-and-save-attachments -url: viewer/net/how-to-extract-and-save-attachments -title: Save attachments -weight: 2 -description: "Save attachments and embedded files from PDF, Outlook data file or email" -keywords: Save attachments, embedded files from PDF, Outlook data file -productName: GroupDocs.Viewer for .NET -hideChildren: False ---- -To get and save attachments, follow these steps: - -1. Instantiate the [Viewer](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer) object. Specify a file that contains attachments. -2. Call the [GetAttachments](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/getattachments) method. It returns the attachment collection. -3. Iterate through the collection. To save an attachment, call the [SaveAttachment](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/saveattachment) method. - -The following code snippet shows how to get and save all attachments from the MSG file: - -{{< alert style="info" >}}NOTE: provided code snippet suits all format families that support attachments: emails, Outlook data files, archives, and PDF documents.{{< /alert >}} - -{{< tabs "example1">}} -{{< tab "C#" >}} -```csharp -using (Viewer viewer = new Viewer("with_attachments.msg")) -{ - // Get list of attachments. - IList attachments = viewer.GetAttachments(); - // Save each attachments. - foreach(Attachment attachment in attachments) - { - string filePath = Path.Combine(@"C:\output", attachment.FileName); - viewer.SaveAttachment(attachment, File.OpenWrite(filePath)); - } -} -``` -{{< /tab >}} -{{< /tabs >}} diff --git a/net/developer-guide/processing-attachments/how-to-list-attachments.md b/net/developer-guide/processing-attachments/how-to-list-attachments.md deleted file mode 100644 index 0affa99..0000000 --- a/net/developer-guide/processing-attachments/how-to-list-attachments.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -id: how-to-list-attachments -url: viewer/net/how-to-list-attachments -title: List attachments -weight: 1 -description: "Retrieve a list of document attachments from your emails, Outlook data files, archives and PDF documents with GroupDocs.Viewer for .NET" -keywords: document attachments, Outlook data files, archives, PDF documents -productName: GroupDocs.Viewer for .NET -hideChildren: False ---- -To get a list of all attachments to a source file, follow these steps: - -1. Instantiate the [Viewer](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer) object. Specify a file that contains attachments. -2. Call the [GetAttachments](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/getattachments) method. It returns the attachment collection. -3. Iterate through the collection. - -The following code snippet shows how to get a list of attachments from the MSG file: - - -{{< alert style="info" >}}NOTE: provided code snippet suits all format families that support attachments: emails, Outlook data files, archives, and PDF documents.{{< /alert >}} - -{{< tabs "example1">}} -{{< tab "C#" >}} -```csharp -using (Viewer viewer = new Viewer("sample.msg")) -{ - // Get list of attachments. - IList attachments = viewer.GetAttachments(); - // Display list of attachments. - Console.WriteLine("\nAttachments:"); - foreach(Attachment attachment in attachments) - Console.WriteLine(attachment); -} -``` -{{< /tab >}} -{{< /tabs >}} - -The following image shows a sample console output: - -![](/viewer/net/images/how-to-list-attachments.png) diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/allow-reuse-page-content.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/allow-reuse-page-content.md new file mode 100644 index 0000000..861b2ee --- /dev/null +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/allow-reuse-page-content.md @@ -0,0 +1,41 @@ +--- +id: allow-reuse-page-content +url: viewer/net/allow-reuse-page-content +title: Reuse page content +linkTitle: Reuse page content +weight: 9 +description: "This topic describes how to reuse page content in a PDF file using the GroupDocs.Viewer .NET API (C#)." +keywords: convert to pdf, optimize size, pdf reduce size +productName: GroupDocs.Viewer for .NET +hideChildren: False +toc: True +--- +This property allows you to reuse the content for identical pages when optimizing the document. + +To allow reusing page content in a PDF file, set the [AllowReusePageContent](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pdfoptimizationoptions/linkduplicatestreams/) property to `true`. + +The following code snippet shows how to link duplicate streams in a PDF file: + +{{< tabs "Example1">}} +{{< tab "C#" >}} +```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; +// ... + +using (var viewer = new Viewer("sample.docx")) +{ + PdfViewOptions viewOptions = new PdfViewOptions(); + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions + { + AllowReusePageContent = true + }; + + viewer.View(viewOptions); +} +``` +{{}} +{{}} + + diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/link-duplicate-streams.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/link-duplicate-streams.md new file mode 100644 index 0000000..a4a66c1 --- /dev/null +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/link-duplicate-streams.md @@ -0,0 +1,41 @@ +--- +id: link-duplicate-streams +url: viewer/net/link-duplicate-streams +title: Link duplicate streams +linkTitle: Link duplicate streams +weight: 6 +description: "This topic describes how to link duplicate streams in a PDF file using the GroupDocs.Viewer .NET API (C#)." +keywords: convert to pdf, optimize size, pdf reduce size +productName: GroupDocs.Viewer for .NET +hideChildren: False +toc: True +--- +Sometimes a document contains several identical resource streams, like images. GroupDocs.Viewers can compare all resource streams. If streams are duplicated, it merges them leaving only one copy, changes the references appropriately, and removes copies of the object. This can significantly decrease the document size. + +To link duplicate streams in a PDF file, set the [LinkDuplicateStreams](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pdfoptimizationoptions/linkduplicatestreams/) property to `true`. + +The following code snippet shows how to link duplicate streams in a PDF file: + +{{< tabs "Example1">}} +{{< tab "C#" >}} +```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; +// ... + +using (var viewer = new Viewer("sample.docx")) +{ + PdfViewOptions viewOptions = new PdfViewOptions(); + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions + { + LinkDuplicateStreams = true + }; + + viewer.View(viewOptions); +} +``` +{{}} +{{}} + + diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-annotations.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-annotations.md index 26ac4da..4d3dfcd 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-annotations.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-annotations.md @@ -3,7 +3,7 @@ id: optimization-pdf-remove-annotations url: viewer/net/optimization-pdf-remove-annotations title: Remove annotations linkTitle: Remove annotations -weight: 1 +weight: 2 description: "This topic describes how to remove annotations from PDF file using the GroupDocs.Viewer .NET API (C#)." keywords: convert to pdf, optimize size, pdf reduce size, remove annotations productName: GroupDocs.Viewer for .NET diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-fields.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-fields.md index 2d35b33..f24a2c9 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-fields.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-remove-fields.md @@ -3,7 +3,7 @@ id: optimization-pdf-remove-fields url: viewer/net/optimization-pdf-remove-fields title: Remove form fields linkTitle: Remove form fields -weight: 2 +weight: 3 description: "This topic describes how to remove form fields from PDF file using the GroupDocs.Viewer .NET API (C#)." keywords: convert to pdf, optimize size, pdf reduce size, remove fields productName: GroupDocs.Viewer for .NET diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-resources.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-resources.md similarity index 99% rename from net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-resources.md rename to net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-resources.md index 613e821..82483cf 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-resources.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-resources.md @@ -3,7 +3,7 @@ id: optimization-pdf-resources url: viewer/net/optimization-pdf-resources title: Optimize the PDF file resources linkTitle: Optimize the PDF file resources -weight: 2 +weight: 1 description: "This topic describes how to optimize PDF file using the GroupDocs.Viewer .NET API (C#) to reduce size." keywords: convert to pdf, optimize size, pdf reduce size productName: GroupDocs.Viewer for .NET diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-spreadsheets.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-spreadsheets.md similarity index 99% rename from net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-spreadsheets.md rename to net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-spreadsheets.md index e8bbaf3..51bf04e 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimization-pdf-spreadsheets.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/optimization-pdf-spreadsheets.md @@ -3,7 +3,7 @@ id: optimization-pdf-spreadsheets url: viewer/net/optimization-pdf-spreadsheets title: Optimize spreadsheets in a PDF file linkTitle: Optimize spreadsheets in a PDF file -weight: 3 +weight: 4 description: "This topic describes how to optimize spreadsheets in a PDF file using the GroupDocs.Viewer .NET API (C#)." keywords: convert to pdf, optimize browser, optimize web productName: GroupDocs.Viewer for .NET diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/remove-private-info.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/remove-private-info.md new file mode 100644 index 0000000..45e85a7 --- /dev/null +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/remove-private-info.md @@ -0,0 +1,41 @@ +--- +id: remove-private-info +url: viewer/net/remove-private-info +title: Remove private information +linkTitle: Remove private information +weight: 5 +description: "This topic describes how to remove private information from a PDF file using the GroupDocs.Viewer .NET API (C#)." +keywords: convert to pdf, optimize size, pdf reduce size +productName: GroupDocs.Viewer for .NET +hideChildren: False +toc: True +--- +A PDF file often contains private information. GroupDocs.Viewer allows you to remove this information to protect sensitive data, enable secure document exchange and minimize the risks of data leakage. + +To remove fonts in a PDF file, set the [RemovePrivateInfo](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pdfoptimizationoptions/removeprivateinfo/) property to `true`. + +The following code snippet shows how to remove private information from a PDF file: + +{{< tabs "Example1">}} +{{< tab "C#" >}} +```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; +// ... + +using (var viewer = new Viewer("sample.docx")) +{ + PdfViewOptions viewOptions = new PdfViewOptions(); + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions() + { + RemovePrivateInfo = true + }; + + viewer.View(viewOptions); +} +``` +{{}} +{{}} + + diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/remove-unused-objects.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/remove-unused-objects.md new file mode 100644 index 0000000..bc0698d --- /dev/null +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/remove-unused-objects.md @@ -0,0 +1,41 @@ +--- +id: remove-unused-objects +url: viewer/net/remove-unused-objects +title: Remove unused objects +linkTitle: Remove unused objects +weight: 8 +description: "This topic describes how to remove unused objects from a PDF file using the GroupDocs.Viewer .NET API (C#)." +keywords: convert to pdf, optimize size, pdf reduce size +productName: GroupDocs.Viewer for .NET +hideChildren: False +toc: True +--- +Sometimes a PDF document may have objects that aren't referenced by any other part of the document. For instance, if a page may be removed from the document page tree but its object remains. Removing these unused objects does not affect the document's validity but can significantly reduce its size. + +To remove unused objects from a PDF file, set the [RemoveUnusedObjects](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pdfoptimizationoptions/removeunusedobjects/) property to `true`. + +The following code snippet shows how to link duplicate objects in a PDF file: + +{{< tabs "Example1">}} +{{< tab "C#" >}} +```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; +// ... + +using (var viewer = new Viewer("sample.docx")) +{ + PdfViewOptions viewOptions = new PdfViewOptions(); + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions + { + RemoveUnusedObjects = true + }; + + viewer.View(viewOptions); +} +``` +{{}} +{{}} + + diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/remove-unused-streams.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/remove-unused-streams.md new file mode 100644 index 0000000..3819ccc --- /dev/null +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-content/remove-unused-streams.md @@ -0,0 +1,43 @@ +--- +id: remove-unused-streams +url: viewer/net/remove-unused-streams +title: Remove unused streams +linkTitle: Remove unused streams +weight: 7 +description: "This topic describes how to remove unused streams from a PDF file using the GroupDocs.Viewer .NET API (C#)." +keywords: convert to pdf, optimize size, pdf reduce size +productName: GroupDocs.Viewer for .NET +hideChildren: False +toc: True +--- +Sometimes a PDF document contains unused resource streams. These streams are not “unused objects” because they are referenced from a page’s resource dictionary. This may happen if an image has been removed from the page, but not from the page resources. + +GroupDocs.Viewer analyze the page contents to determine if a resource stream is used or not. Then it removes the unused streams. This can significantly decrease the document size. + +To remove unused streams from a PDF file, set the [RemoveUnusedStreams](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pdfoptimizationoptions/removeunusedstreams/) property to `true`. + +The following code snippet shows how to link duplicate streams in a PDF file: + +{{< tabs "Example1">}} +{{< tab "C#" >}} +```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; +// ... + +using (var viewer = new Viewer("sample.docx")) +{ + PdfViewOptions viewOptions = new PdfViewOptions(); + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions + { + RemoveUnusedStreams = true + }; + + viewer.View(viewOptions); +} +``` +{{}} +{{}} + + diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-subset-fonts.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-subset-fonts.md index 5945c66..fd01ea0 100644 --- a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-subset-fonts.md +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-subset-fonts.md @@ -3,16 +3,13 @@ id: optimization-pdf-subset-fonts url: viewer/net/optimization-pdf-subset-fonts title: Subset fonts linkTitle: Subset fonts -weight: 2 +weight: 1 description: "This topic describes how to subset fonts in PDF file using the GroupDocs.Viewer .NET API (C#)." keywords: convert to pdf, optimize size, pdf reduce size, subset fonts productName: GroupDocs.Viewer for .NET hideChildren: False toc: True --- -Optimization resources. SubsetFonts optimization option -Fonts will be converted into subsets if set to true - If the file uses embedded fonts, it contains all font data. GroupDocs.Viewer can subset embedded fonts to reduce the file size. To subset fonts in a PDF file, set the [SubsetFonts](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pdfoptimizationoptions/subsetfonts) property to `true`. diff --git a/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-unembed-fonts.md b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-unembed-fonts.md new file mode 100644 index 0000000..17bf3ba --- /dev/null +++ b/net/developer-guide/rendering-documents/rendering-to-pdf/optimization-pdf-options/optimize-fonts/optimization-pdf-unembed-fonts.md @@ -0,0 +1,49 @@ +--- +id: optimization-pdf-unembed-fonts +url: viewer/net/optimization-pdf-unembed-fonts +title: Unembed fonts +linkTitle: Unembed fonts +weight: 2 +description: "This topic describes how to unembed fonts in PDF file using the GroupDocs.Viewer .NET API (C#)." +keywords: convert to pdf, optimize size, pdf reduce size, unembed fonts +productName: GroupDocs.Viewer for .NET +hideChildren: False +toc: True +--- +If a document uses embedded fonts, it means all font data is included in the document, allowing it to be viewed even if the user does not have the font installed. However, embedding fonts increases the document size. + +The GroupDocs.Viewer allows you to unembed all embedded fonts. This decreases the document size but the document may become unreadable if the correct font is not installed. + +To unembed fonts in a PDF file, set the [UnembedFonts](https://reference.groupdocs.com/viewer/net/groupdocs.viewer.options/pdfoptimizationoptions/unembedfonts) property to `true`. + +The following code snippet shows how to unembed fonts in a PDF file: + +{{< tabs "Example1">}} +{{< tab "C#" >}} +```csharp +using GroupDocs.Viewer; +using GroupDocs.Viewer.Options; +using GroupDocs.Viewer.Domain.Documents.PostProcessing.Pdf.Optimization; +// ... + +using (var viewer = new Viewer("sample.docx")) +{ + PdfViewOptions viewOptions = new PdfViewOptions(); + viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions() + { + UnembedFonts = true + }; + + viewer.View(viewOptions); +} +``` +{{}} +{{}} + +The following image demonstrates the result. There is no difference in appearance: + +![No difference in appearance](/viewer/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-unembed-fonts-appearance.png) + +But there is the significant difference in size: + +![Significant difference in size](/viewer/net/images/developer-guide/pdf-rendering/optimization/optimization-pdf-unembed-fonts-size.png) diff --git a/net/developer-guide/working-with-attachments.md b/net/developer-guide/working-with-attachments.md new file mode 100644 index 0000000..08d30f7 --- /dev/null +++ b/net/developer-guide/working-with-attachments.md @@ -0,0 +1,117 @@ +--- +id: working-with-attachments +url: viewer/net/working-with-attachments +title: Processing attachments +weight: 4 +description: "Processing email attachments, embedded files, and compressed files with GroupDocs.Viewer for .NET" +keywords: email attachments, embedded files, compressed files +productName: GroupDocs.Viewer for .NET +hideChildren: False +--- + +Using GroupDocs.Viewer, you can list and save the following attachments: + +* Email attachments +* Files embedded in PDF files +* Email messages contained by Outlook, LotusNotes and other storage files +* Compressed files + +## List attachments + +To get a list of all attachments to a source file, follow these steps: + +1. Instantiate the [Viewer](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer) object. Specify a file that contains attachments. +2. Call the [GetAttachments](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/getattachments) method. It returns the attachment collection. +3. Iterate through the collection. + +The following code snippet shows how to get a list of attachments from the MSG file: + + +{{< alert style="info" >}}NOTE: provided code snippet suits all format families that support attachments: emails, Outlook data files, archives, and PDF documents.{{< /alert >}} + +{{< tabs "example1">}} +{{< tab "C#" >}} +```csharp +using (Viewer viewer = new Viewer("sample.msg")) +{ + // Get list of attachments. + IList attachments = viewer.GetAttachments(); + // Display list of attachments. + Console.WriteLine("\nAttachments:"); + foreach(Attachment attachment in attachments) + Console.WriteLine(attachment); +} +``` +{{< /tab >}} +{{< /tabs >}} + +The following image shows a sample console output: + +![](/viewer/net/images/how-to-list-attachments.png) + +## Save attachments +To get and save attachments, follow these steps: + +1. Instantiate the [Viewer](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer) object. Specify a file that contains attachments. +2. Call the [GetAttachments](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/getattachments) method. It returns the attachment collection. +3. Iterate through the collection. To save an attachment, call the [SaveAttachment](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/saveattachment) method. + +The following code snippet shows how to get and save all attachments from the MSG file: + +{{< alert style="info" >}}NOTE: provided code snippet suits all format families that support attachments: emails, Outlook data files, archives, and PDF documents.{{< /alert >}} + +{{< tabs "example2">}} +{{< tab "C#" >}} +```csharp +using (Viewer viewer = new Viewer("with_attachments.msg")) +{ + // Get list of attachments. + IList attachments = viewer.GetAttachments(); + // Save each attachments. + foreach(Attachment attachment in attachments) + { + string filePath = Path.Combine(@"C:\output", attachment.FileName); + viewer.SaveAttachment(attachment, File.OpenWrite(filePath)); + } +} +``` +{{< /tab >}} +{{< /tabs >}} + +## Render attachments + +Render attachments in the same way as any other documents. + +To view attachments, follow these steps: + +1. Instantiate the first [Viewer](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer) object. Specify a file that contains attachments. +2. Call the [SaveAttachment](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/saveattachment) method to save the attachment (to local disk, memory stream, etc). +3. Instantiate the second [Viewer](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer) object. Specify the previously saved attachment. +4. Specify the view options depending on the output format - [HtmlViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/htmlviewoptions)/[PngViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/pngviewoptions)/[JpgViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/jpgviewoptions)/[PdfViewOptions](https://reference.groupdocs.com/net/viewer/groupdocs.viewer.options/pdfviewoptions). +5. Call the [View](https://reference.groupdocs.com/net/viewer/groupdocs.viewer/viewer/methods/view) method. + +The following code snippet shows how to render attachments from the MSG file: + +{{< alert style="info" >}}NOTE: provided code snippet suits all format families that support attachments: emails, Outlook data files, archives, and PDF documents.{{< /alert >}} + +{{< tabs "example3">}} +{{< tab "C#" >}} +```csharp +// Specify attachment. +Attachment attachment = new Attachment("attachment-word.doc", @"C:\Output\attachment-word.doc"); +// Create a stream for attachment. +MemoryStream attachmentStream = new MemoryStream(); +//Save attachment +using (Viewer viewer = new Viewer("sample.msg")) +{ + viewer.SaveAttachment(attachment, attachmentStream); +} +// Render attachment +using (Viewer viewer = new Viewer(attachmentStream)) +{ + HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(); + viewer.View(options); +} +``` +{{< /tab >}} +{{< /tabs >}}