How to Make Unsearchable PDF in ASP.NET, C#, VB.NET and VBScript using PDF Extractor SDK - ByteScout

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

Check out this source code to run the program for making unsearchable PDFs 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#

Check out this code snippet that helps you 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

See this source code below that would be helpful 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)

Follow this source code snippet below in order to make an 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")

Tutorials:

prev
next