Bad performance convert tif to pdf using ITextSharp

后端 未结 7 1302
猫巷女王i
猫巷女王i 2021-02-15 17:03

Summary: How can I reduce the amount of time it takes to convert tifs to pdfs using itextsharp?

Background: I\'m convertin

7条回答
  •  离开以前
    2021-02-15 17:20

    //Testing shows that this line takes the lion's share (80%) of the time involved.
    iTextSharp.text.Image img =
      iTextSharp.text.Image.GetInstance(bm, null, true);
    

    Might be stupid suggestion (don't have a large testset right now to try it locally), but give me the benefit of the doubt:

    You're looping through a multitiff here, selecting frame after frame. bm is this (huge, 6.5M) image, in memory. I don't know enough about iTextSharps internal image handling, but maybe you can help here by just providing a single page image here? Can you try creating a new Bitmap of the desired size, drawing bm on it (look at the options to the Graphics object for properties related to speed: InterpolationMode for example) and passing in this single image instead of the huge thing for each call?

提交回复
热议问题