Summary: How can I reduce the amount of time it takes to convert tifs to pdfs using itextsharp
?
Background: I\'m convertin
You're crunching quite a lot of data, so if the PDF export process is slow, and you're not using a fast PC, then you may be stuck with that sort of performance.
The most obvious way to speed this up on a multi-core system would be to multi-thread it.
Break the code into two stages. First, a set of images can be converted and stored in a list, then the list can be output to the PDF. With the file sizes you're talking about, memory usage to store the entire document in memory during processing shouldn't be a problem.
You can then make the first stage of this process multi-threaded - you could fire off a threadpool thread for each image that needs to be converted, capping the number of active threads (roughtly one per CPU core is enough - any more won't gain you much). Aln alternative is to split your list of inputs into n lists (again, one list per CPU core) and then fire off threads that just process their own list. This reduces the threading overheads, but may result in some threds finishing a long time before others (if their workload turns out to be a lot less) so it may not always work out quite as fast.
By splitting it into two passes you may also gain performance (even without mutlithreading) by doing all the input processing and then all the output processing as separate stages, which will probably reduce the disk seeking involved (depending on how much RAM you have available for disk caches on your PC).
Note that mutithreading it won't be of much use if you only have a single core CPU (though you could still see gains in parts of the process that are I/O bound, it sounds like you're primarily CPU bound).
You could also experiment with resizing the bitmap using something other than itextsharp calls - I don't know anything about itextsharp but it is possible that its image conversion code is slow, or does not make use of graphics hardware in a way that other scaling techniques may be able to. There may also be some scaling options that you can set that will give you a trade-off between quality and speed that you could try.