How to make unsearchable PDF in ASP.NET, C#, VB.NET and VBScript using PDF Extractor SDK

  • Home
  • /
  • Articles
  • /
  • How to make unsearchable PDF in ASP.NET, C#, VB.NET and VBScript using PDF Extractor SDK

Check the samples below to learn how to make an unsearchable PDF document in ASP.NET, C#, VB.NET and VBScript using ByteScout PDF Extractor SDK.

If you need to make a PDF searchable, please check this tutorial.

Select your programming language:

How to make unsearchable PDF in ASP.NET

using System;
using System.IO;
using Bytescout.PDFExtractor;

namespace MakeUnsearchablePDF
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            String inputFile = Server.MapPath(@"bin\sample1.pdf");

			// Create Bytescout.PDFExtractor.UnsearchablePDFMaker instance
			UnsearchablePDFMaker unsearchablePDFMaker = new UnsearchablePDFMaker();
            unsearchablePDFMaker.RegistrationName = "demo";
            unsearchablePDFMaker.RegistrationKey = "demo";

			// Load sample PDF document
			unsearchablePDFMaker.LoadDocumentFromFile(inputFile);
			
			// Set PDF rendering resolution to 150 DPI. Higher value - better quality, but larger output file.
	        unsearchablePDFMaker.RenderingResolution = 150;
			// Set embedded images format
			unsearchablePDFMaker.ImageFormat = EmbeddedImageFormat.PNG;

			Response.Clear();
			Response.ContentType = "application/pdf";
			Response.AddHeader("Content-Disposition", "attachment;filename=result.pdf");
			
			// Process the document and write the result to the output stream
			unsearchablePDFMaker.MakePDFUnsearchable(Response.OutputStream);
			
            Response.End();
        }
    }
}

How to make unsearchable PDF in C#

using Bytescout.PDFExtractor;

namespace MakeUnsearchablePDF
{
    class Program
    {
        static void Main()
        {
            // Create Bytescout.PDFExtractor.UnsearchablePDFMaker instance
            UnsearchablePDFMaker unsearchablePDFMaker = new UnsearchablePDFMaker();
            unsearchablePDFMaker.RegistrationName = "demo";
            unsearchablePDFMaker.RegistrationKey = "demo";

            // Load sample PDF document
            unsearchablePDFMaker.LoadDocumentFromFile("sample1.pdf");

            // Set PDF rendering resolution to 150 DPI. Higher value - better quality, but larger output file.
            unsearchablePDFMaker.RenderingResolution = 150;
            // Set embedded images format
            unsearchablePDFMaker.ImageFormat = EmbeddedImageFormat.PNG;

            // Process the document 
            unsearchablePDFMaker.MakePDFUnsearchable("result.pdf");

            // Open the result PDF file in default associated application
            System.Diagnostics.Process.Start("result.pdf");
        }
    }
}

How to make unsearchable PDF in Visual Basic .NET

Imports Bytescout.PDFExtractor

Module Module1

    Sub Main()

        ' Create Bytescout.PDFExtractor.UnsearchablePDFMaker instance
        Dim unsearchablePDFMaker = New UnsearchablePDFMaker()
        unsearchablePDFMaker.RegistrationName = "demo"
        unsearchablePDFMaker.RegistrationKey = "demo"

        ' Load sample PDF document
        unsearchablePDFMaker.LoadDocumentFromFile("sample1.pdf")

        ' Set PDF rendering resolution to 150 DPI. Higher value - better quality, but larger output file.
        unsearchablePDFMaker.RenderingResolution = 150
        ' Set embedded images format
        unsearchablePDFMaker.ImageFormat = EmbeddedImageFormat.PNG

        ' Process the document
        unsearchablePDFMaker.MakePDFUnsearchable("result.pdf")

        ' Open the result PDF file in default associated application
        System.Diagnostics.Process.Start("result.pdf")

    End Sub

End Module

How to make unsearchable PDF in VBScript (Visual Basic 6)

' Create Bytescout.PDFExtractor.UnsearchablePDFMaker object
Set unsearchablePDFMaker = CreateObject("Bytescout.PDFExtractor.UnsearchablePDFMaker")
unsearchablePDFMaker.RegistrationName = "demo"
unsearchablePDFMaker.RegistrationKey = "demo"

' Load sample PDF document
unsearchablePDFMaker.LoadDocumentFromFile("sample1.pdf")

' Set PDF rendering resolution to 150 DPI. Higher value - better quality, but larger output file.
unsearchablePDFMaker.RenderingResolution = 150
' Set embedded images format
unsearchablePDFMaker.ImageFormat = EmbeddedImageFormat.PNG

' Process the document
unsearchablePDFMaker.MakePDFUnsearchable("result.pdf")
prev
next