Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Feb 17, 2016 10:04 pm

I am using the free version at the moment until we are satisfied enough to purchase the commercial, that being said, in C#, my code below, I am attempting to let go of the PDF document after the conversion, because the system is not letting go of the original PDF.. Once converted, I need to delete the original PDF but when I attempt to, it lets me know that I am denied the ability to delete it.

Code: Select all
        public Boolean ConvertPDFToImage(string pdfFileName)
        {
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(pdfFileName);
            Image bmp = doc.SaveAsImage(0);
            outputFile = pdfFileName.Replace(".pdf", ".bmp");
            bmp.Save(outputFile);
            doc.Dispose();
            return true;
        }


BTW: outputFile is defined in the class with getters and setters that is why it is not defined in this method locally but used in the method.

At any rate, I need the original released by your library once it is done so that I can delete the original PDF that has been converted.

[email protected]
 
Posts: 5
Joined: Wed Feb 17, 2016 9:02 pm

Thu Feb 18, 2016 3:16 am

Hi,

Thanks for your posting and using our component.
I tested your code but didn't reproduce your issue, and the original file was deleted successfully. Attched my full code.
Could you please send us a whole project to help us reproduce your issue? If you can not share it here, you can send it to [email protected]. Thank you.

Code: Select all
static void Main(string[] args)
        {
            string filename="..\\..\\Input\\Test.pdf";
            bool value = ConvertPDFToImage(filename);
            if (value)
            {
                File.Delete(filename);
            }
        }
        static Boolean ConvertPDFToImage(string pdfFileName)
        {
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(pdfFileName);
            Image bmp = doc.SaveAsImage(0);
            string outputFile = pdfFileName.Replace(".pdf", ".bmp");
            bmp.Save(outputFile);
            doc.Dispose();
            return true;
        }


Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Thu Feb 25, 2016 2:07 pm

Thanks for the email correspondence on this issue. We can continue through that medium if the problem persists.

[email protected]
 
Posts: 5
Joined: Wed Feb 17, 2016 9:02 pm

Fri Feb 26, 2016 1:44 am

Hi,

Thanks for your response.
Welcome to feel free to write to us if you have any problems.

Have a nice day!
Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 3011
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.PDF