Reputation: 47
I am trying to split a PDF document of X pages in X png images using Freeware.Pdf2Png in C#.
First, I transform the pdf document to a FileStream:
seleccionado = new FileStream(ruta_archivo, Filemode.OpenOrCreate, FileAccess.ReadWrite);
where ruta_archivo is the path to the PDF file.
Afterwards I use the Freeware.Pdf2Png library to convert all the pages to PNG's.
I try it with several pdf: with a 1 or 36 pages PDF files it worked great but with a 446 pages PDF the converter only transform 271 pages:
I have seen the PDF with another viewer and the file is not corrupt (I can see every page).
Why cannot I get all the pages? Is there any size limit in the converter maybe? Could it be something about the creation of the FileStream?
PD: I know there are other libraries like iTextPdf or PDFSharp that make this much easy, but due to legal stuffs, I cannot use AGPL or GPL license libraries, jut MIT or Apache 2.0 (like Freeware.Pdf2Png).
Thanks for your time!
SOLVED: The problem seems to be the massive use of resources. Despite using 'using' instructions (not enoug to work), I add:
Freeware.Pdf2Png.ConvertConvert(pdf_file_stream, page-number)
GC.Collect();
GC.WaitForPendingFinalizers();
after every transformation and it finally worked properly. Thanks!
Upvotes: 1
Views: 1284