We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Merging Multiple PDF Files from streams

My requirement is to create a number of separate PDF files from different HTML pages and then merge them all together and save the final file.

Currently, I am using the PDF converter to create a number of temporary PDF files on the server, and then merge those files.

I can't delete the temp files after the merge is complete. I get an error: "The process cannot access the file '[filename.pdf]' because it is being used by another process."

So instead of leaving all these temp files on my server, it would be great if I could write the files to a memory stream and then merge the files from the stream and output the final pdf.

Alternatively, it may be easier to just delete the temp files. Could someone explain how to close the pdf files so i can delete them?

Code attached.

Can anyone help?

Thanks,
Matt



Generator_63640661.zip

2 Replies

DG Divya G Syncfusion Team December 31, 2009 03:54 AM UTC

Hi Matt,

Thank you for using Syncfusion Products.

We have to save and close the document before delete the files.Kindly use the following lines of code to delete the temp files.
(C#):
doc.Save("FinalReport.pdf", Response, HttpReadType.Save);
// Close the document Before delete the files.
doc.Close();
File.Delete(paths[0]);
File.Delete(paths[1]);

Please refer the attachment to solve the issue.

Regards,
Divya.G


DG Divya G Syncfusion Team December 31, 2009 03:56 AM UTC

Hi Matt,

Here is the attachment.

Thanks & regards,
Divya.G




Generator_76232cac.zip

Loader.
Live Chat Icon For mobile
Up arrow icon