Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Wednesday, November 22, 2017 11:15:07 AM(UTC)

Groups: Registered, Tech Support, Administrators
Posts: 89

Was thanked: 4 time(s) in 4 post(s)

Often when we convert a file type we need to delete the previous version of the file for the sake of saving space.
The example below shows how to implement the LEADTOOLS SDK in order to achieve this.

It is important to note that the DLLs needed for splitting the documents will depend on the documents that the application will be working with.
In our application we are working with PDFs and with Tifs so those DLLs are included.

Follow this link to see what you will need: Files To Be Included With Your Application

using Leadtools;
using Leadtools.Codecs;

namespace simplePdfReplaceDelete_20
    class Program
        static void Main(string[] args)
            // Add License and Key here
            RasterSupport.SetLicense("", "");

            string pdfFileName = @"C:\Users\cthompson\Desktop\Leadtools.pdf"; //file to be deleted
            string tifFileName = @"C:\Users\cthompson\Desktop\LeadtoolsConverted.tif"; //file path for output

            CreateTifFile(pdfFileName, tifFileName);

            File.Delete(pdfFileName); // deletes original file that is converted

            Console.WriteLine(pdfFileName + ">> has been deleted.\n" + tifFileName + ">> has been created.");

        public static void CreateTifFile(string pdfFileName, string tifFileName)
            RasterCodecs codecs = new RasterCodecs();
            codecs.Options.Load.AllPages = true; // Allows for multipage documents

            RasterImage image = codecs.Load(pdfFileName);

            codecs.Save(image, tifFileName, RasterImageFormat.Tif, 0);


Imports Leadtools
Imports Leadtools.Codecs

Module Module1

    Sub Main()

        'Add License and Key here
        RasterSupport.SetLicense("", "")

        Dim pdfFileName As String = "C:\Users\cthompson\Desktop\Leadtools.pdf" 'file to be deleted
        Dim tifFileName As String = "C:\Users\cthompson\Desktop\LeadtoolsConverted.tif" 'file path for output

        CreateTifFile(pdfFileName, tifFileName)

        File.Delete(pdfFileName) 'deletes original file that Is converted

        Console.WriteLine(pdfFileName + ">> has been deleted." + vbLf + tifFileName + ">> has been created.")

    End Sub

    Public Sub CreateTifFile(ByVal pdfFileName, ByVal tifFileName)

        Dim codecs As RasterCodecs = New RasterCodecs()
        codecs.Options.Load.AllPages = True  'Allows for multipage documents

        Dim image As RasterImage = codecs.Load(pdfFileName)

        codecs.Save(image, tifFileName, RasterImageFormat.Tif, 0)

    End Sub

End Module

File Attachment(s):
simplePdfReplaceDelete_20.zip (128kb) downloaded 176 time(s).

File Attachment(s):
simplePdfReplaceDeleteVB_20.zip (124kb) downloaded 148 time(s).
Chris Thompson
Developer Support Engineer
LEAD Technologies, Inc.


Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.056 seconds.