---
title: "Recompress PDFs using MRC compression in VB.NET"
canonical_url: "https://www.nutrient.io/guides/dotnet/samples/recompress-pdf-mrc-vbnet/"
md_url: "https://www.nutrient.io/guides/dotnet/samples/recompress-pdf-mrc-vbnet.md"
last_updated: "2026-05-14T21:57:26.876Z"
description: "Learn how to recompress complex PDF documents using Mixed Raster Content (MRC) compression for reduced file size and improved performance."
---

# Recompress existing PDFs using MRC compression in VB.NET

Mixed raster content (MRC) compression is useful for compressing complex PDF documents to reduce their file size. This example shows how to recompress existing PDF documents, benefiting from the enhanced MRC compression mechanism.

[Get Started](https://www.nutrient.io/sdk/dotnet/getting-started.md)

[All Samples](https://www.nutrient.io/guides/dotnet/samples.md)

[Download](https://www.nutrient.io/guides/dotnet/downloads.md)

[Launch Demo](https://www.nutrient.io/demo/)

---

### C#

[C#](https://www.nutrient.io/guides/dotnet/samples/recompress-pdf-mrc-cs.md)

### VB.NET

[VB.NET](https://www.nutrient.io/guides/dotnet/samples/recompress-pdf-mrc-vbnet.md)

```vb

'We assume that GdPicture has been correctly installed and unlocked.
Using pdf As GdPicturePDF = New GdPicturePDF()
    Dim status As GdPictureStatus = pdf.LoadFromFile("source.pdf", False)
    If status = GdPictureStatus.OK Then
        'Setting MRC options.
        pdf.SetMRCImageBackgroundResolution(100)
        'You can set it to true to obtain a better quality rendering, but it produces a bigger file.
        pdf.SetMRCPreserveSmoothing(False)
        'You can also set the compression values for images here, for example:
        pdf.SetCompressionForBitonalImage(PdfCompression.PdfCompressionJBIG2)
        pdf.SetCompressionForColorImage(PdfCompression.PdfCompressionJPEG2000)
        'Using the negative value permits to specify better quality factor versus a compression rate.
        pdf.SetJpeg2000Quality(-60)
        Dim pageCount As Integer = pdf.GetPageCount()
        status = pdf.GetStat()
        Dim pageNo As Integer = 1
        While (pageNo <= pageCount) AndAlso (status = GdPictureStatus.OK)
            status = pdf.SelectPage(pageNo)
            If status = GdPictureStatus.OK Then
                'We can ignore hiddent text in the example.
                Dim isPageImage As Boolean = pdf.IsPageImage(True)
                status = pdf.GetStat()
                If status = GdPictureStatus.OK Then
                    If isPageImage Then
                        'As the page is image-based, the image number is 1 and we can extract this image.
                        Dim imageID As Integer = pdf.ExtractPageImage(1)
                        status = pdf.GetStat()
                        If status = GdPictureStatus.OK Then
                            'Getting the resource name of the extracted image, the index of the image to be used here is 0.
                            Dim imageResName As String = pdf.GetPageImageResName(0)
                            status = pdf.GetStat()
                            If status = GdPictureStatus.OK Then
                                'The original image is replaced with the compressed image on the whole page surface here.
                                status = pdf.ReplaceImageMRC(imageResName, imageID)
                                'You need to dispose of the used image resource here.
                                GdPictureDocumentUtilities.DisposeImage(imageID)
                            End If
                        End If
                    End If
                End If
            End If
            pageNo += 1
        End While
        If status = GdPictureStatus.OK Then
            status = pdf.SaveToFile("dest.pdf", True)
            If status = GdPictureStatus.OK Then
                MessageBox.Show("The example has been followed successfully and the file has been saved.", "MRC Compression Example", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                MessageBox.Show("The example has been followed successfully, but the file can't be saved. Status: " + status.ToString(), "MRC Compression Example", MessageBoxButtons.OK, MessageBoxIcon.[Error])
            End If
        Else
            MessageBox.Show("The example has NOT been followed successfully. Status: " + status.ToString(), "MRC Compression Example", MessageBoxButtons.OK, MessageBoxIcon.[Error])
        End If
    Else
        MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), "MRC Compression Example", MessageBoxButtons.OK, MessageBoxIcon.[Error])
    End If
End Using

```

This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.

---

## Related pages

- [Automatically rotate pages of a multipage TIFF file using OCR and VB.NET](/guides/dotnet/samples/auto-rotate-tiff-vbnet.md)
- [Automatically rotate pages of a multipage TIFF file using OCR and C#](/guides/dotnet/samples/auto-rotate-tiff-cs.md)
- [Convert PDFs, MS Office, and images to TIFF in C#](/guides/dotnet/samples/convert-to-tiff-cs.md)
- [Saving images into folders based on their barcode](/guides/dotnet/samples/barcode-auto-sorting-cs.md)
- [Saving images into folders based on their barcode](/guides/dotnet/samples/barcode-auto-sorting-vbnet.md)
- [Generate a multipage TIFF file using a compression mode per page in C#](/guides/dotnet/samples/create-multipage-tiff-cs.md)
- [Converting a Microsoft Word binary file document (DOC) to a Microsoft Word OpenXML document (DOCX) in C#](/guides/dotnet/samples/doc-to-docx-cs.md)
- [Merging two PDF documents by alternating pages from both files in VB.NET](/guides/dotnet/samples/merge-pdf-alternate-pages-vbnet.md)
- [Using an external OCR engine during PDF/OCR generation](/guides/dotnet/samples/integrate-omnipage-ocr-cs.md)
- [Converting a multipage PDF to a multipage TIFF using color detection in C#](/guides/dotnet/samples/pdf-to-tiff-color-detection-cs.md)
- [Merging two PDF documents by alternating pages from both files in C#](/guides/dotnet/samples/merge-pdf-alternate-pages-cs.md)
- [Converting a multipage PDF to a multipage TIFF using color detection in VB.NET](/guides/dotnet/samples/pdf-to-tiff-color-detection-vbnet.md)
- [Recompress existing PDFs using MRC compression in C#](/guides/dotnet/samples/recompress-pdf-mrc-cs.md)
- [Recompress an existing PDF using color detection in VB.NET](/guides/dotnet/samples/recompress-pdf-vbnet.md)
- [Recompress an existing PDF using color detection in C#](/guides/dotnet/samples/recompress-pdf-cs.md)
- [Highlight and crop an image in C#](/guides/dotnet/samples/select-image-crop-area-cs.md)
- [Highlight and crop an image in VB.NET](/guides/dotnet/samples/select-image-crop-area-vbnet.md)
- [Highlight a region in PDF or an image in VB.NET](/guides/dotnet/samples/select-pdf-image-region-vbnet.md)
- [Choosing the appropriate OCR zone in C#](/guides/dotnet/samples/select-ocr-zone-cs.md)
- [Highlight a region in a PDF or an image in C#](/guides/dotnet/samples/select-pdf-image-region-cs.md)
- [Choosing the appropriate OCR zone in VB.NET](/guides/dotnet/samples/select-ocr-zone-vbnet.md)
- [Save bitonal TIFFs with VB.NET using photometric 0](/guides/dotnet/samples/tiff-photometric-vbnet.md)
- [Convert a multipage TIFF to a multipage JBIG2 in VB.NET](/guides/dotnet/samples/tiff-to-jbig2-vbnet.md)
- [Save bitonal TIFF images with C# and CCITT4](/guides/dotnet/samples/tiff-photometric-cs.md)
- [Convert a multipage TIFF to a multipage JBIG2 in C#](/guides/dotnet/samples/tiff-to-jbig2-cs.md)

