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.

Fri Dec 17, 2021 2:24 pm

Hello,

The process that I am using to merge documents used to work perfectly fine. But after I updated the package to the latest version, I seem to be getting this same error with all my pdf documents. When I go to delete the temporary files that were used to merge into 1 file, I cannot. It throws an exception and tells me that the file is still being used. Any help would be great. My code for this process is as follows:
Code: Select all
 'Merges PDFs
        Dim OutputFile As String = FileName
        Using doc As Spire.Pdf.PdfDocumentBase = Spire.Pdf.PdfDocument.MergeFiles(array)
            doc.Save(OutputFile, FileFormat.PDF)
        End Using

I have also tried using doc.close() and doc.dispose() to no luck
I can provide more info as it is needed. Thanks!

EDIT:
I have come up with quite a janky solution but also one that I would rather not have. The reason I updated to the latest version to begin with is because Spire was creating blank pages when merging pdfs. There really was not any rhyme or reason for it too. So I updated. Fixed the issue of the blank doc but gave me the new issue shown above. It will generate the merged pdf perfectly but will not allow for the temp files to be deleted.

The way I circumvented the issue for now is if the array has only one file in it (basically if there is only one pdf to merge) Rename it and move it to the proper destination.

It looks like this:
Code: Select all
     Sub MergeEverythingSpire(filename As String, Folder As String, Array As String())
        Try 'merges all files in passed folder path into one file using pdfsharp         
            If Array.Count = 1 Then
                File.Move(Directory.GetFiles(ConversionFolder).First, filename)
            Else
                Dim OutputFile As String = filename
                Using docFinal As Spire.Pdf.PdfDocumentBase = Spire.Pdf.PdfDocument.MergeFiles(Array)
                    Threading.Thread.Sleep(5000)
                    docFinal.Save(OutputFile, Spire.Pdf.FileFormat.PDF)
                End Using
            End If
        Catch ex As System.Exception

        End Try
    End Sub

So now I resolved one problem by creating another. The temp files are able to be deleted but as a result my merged pdf is missing pages.

Is there a specific version that addresses these issues or am I doing something wrong? I would appreciate any input on this.

Thanks!

Zach_peterson4
 
Posts: 6
Joined: Fri Dec 17, 2021 2:16 pm

Mon Dec 20, 2021 7:57 am

Hello,

Thanks for your inquiry!

For the issue about” the file is still being used”, did your “Array” include the file pointed to by” OutputFile”?

If so, I did reproduce this issue under this situation, and logged it in our issue tracking system with the ticket SPIREPDF-4854 for further investigation.

If not, please provide us with your input files for further investigate.

For your second issue, sorry that I do not quite clear which is the “temp file” you mentioned. To help us better reproduce and understand your issue, please provide us a simple project and your input files. You can also send them to us via email (support@e-iceblue.com). Thanks in advance!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Dec 20, 2021 5:31 pm

Marcia.Zhou wrote:For your second issue, sorry that I do not quite clear which is the “temp file” you mentioned. To help us better reproduce and understand your issue, please provide us a simple project and your input files. You can also send them to us via email (support@e-iceblue.com). Thanks in advance!


The referenced "Temp File" Refers simply to the pdf files that exist to be merged into 1 file. They are nothing more then pages in the final merged pdf.

Zach_peterson4
 
Posts: 6
Joined: Fri Dec 17, 2021 2:16 pm

Mon Dec 20, 2021 5:35 pm

Marcia.Zhou wrote:For the issue about” the file is still being used”, did your “Array” include the file pointed to by” OutputFile”?


The output file is not listed in the array as the output file is the file generated by the pdf files within the array list. The array is generated simply by:
Code: Select all
 Dim Array As String() = Directory.GetFiles(ConversionFolder)

And since the "OutputFile" is not in the ConversionFolder at the time that the array is generated. It is not included in the array list.

Zach_peterson4
 
Posts: 6
Joined: Fri Dec 17, 2021 2:16 pm

Tue Dec 21, 2021 5:54 am

Hello,

Thanks for sharing more information!

Do you mean that you get this exception when you delete the files in Array after merging them, like the screenshot shows?
exception.png

If so, this issue has been submitted to our Dev team with the ticket SPIREPDF-4854 for further investigations.

If I still have some understood, please provide us with the screenshot of the error and the complete code to reproduce it. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Tue Dec 21, 2021 1:25 pm

If this exception message says something similar to "Cannot delete the file because it is being used by another process" Then yes!

Zach_peterson4
 
Posts: 6
Joined: Fri Dec 17, 2021 2:16 pm

Wed Dec 22, 2021 1:14 am

Hello,

Thanks for your reply!

Okay, this issue has been submitted to our Dev team with the ticket SPIREPDF-4854 for further investigation.

We will let you know if there is any update. Sorry for the inconvenience caused.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Thu Jan 06, 2022 10:13 am

Hello,

Thanks for your patience!

Glad to inform you that we just released Spire.PDF Pack Version:8.1 which fixes the issue of SPIREPDF-4854.

Please download the fix version from the following links to test.

Website link:https://www.e-iceblue.com/Download/download-pdf-for-net-now.html
Nuget link: https://www.nuget.org/packages/Spire.PDF/8.1.0

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Jan 10, 2022 8:12 am

Hello,

Hope you are doing well!

Has the issue been solved now? Could you please give us some feedback at your convenience?

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Jan 10, 2022 1:21 pm

Hello. Yes the update fixed that issue.

Zach_peterson4
 
Posts: 6
Joined: Fri Dec 17, 2021 2:16 pm

Tue Jan 11, 2022 1:26 am

Hello,

Thanks for your feedback!

Glad to hear that your issue has been solved.

If you encounter any issues related to our product in the future, just feel free to contact us.

Have a nice day!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.PDF