Asked by:
TallComponents PDFRasterizer memory explodes to 16GB for valid PDF

Question
-
User-603456352 posted
For an otherwise valid one page 80KB PDF the method ConvertToTiff explodes the process memory up to 16GB. The method does succeed, no exception is thrown.
Does anyone else experience this?
Monday, June 25, 2018 11:45 AM
All replies
-
User-2069324601 posted
In order to reproduce this, would it be possible to share to specific PDF and the exact version of TallComponents PDFRasterizer that you are using?
Tuesday, June 26, 2018 7:25 AM -
User753101303 posted
Hi,
My first move would be to check the final Tiff image. It doesn't have an unexpected size/resolution ? I would try first the support forum for this product.
Tuesday, June 26, 2018 7:32 AM -
User-603456352 posted
This happens for the latest version 3.0.170.
I cannot share the PDF here publicly. I have submitted an example (it happens often) to the TallComponents website via the support form.
Tuesday, June 26, 2018 9:54 AM -
User-603456352 posted
The final Tiff is ok.
Tuesday, June 26, 2018 9:55 AM -
User-2069324601 posted
Thank you. We are investigating now and share our findings.
Tuesday, June 26, 2018 9:57 AM -
User-2069324601 posted
I ran the VS Performance Profiler and I could not reproduce the 16 GB: https://imgur.com/a/w0JdV9A
I used code from the following article: https://www.tallcomponents.com/pdfrasterizer/convert-pdf-to-multipage-tiff against the PDF that your provided.
Tuesday, June 26, 2018 10:36 AM -
User-603456352 posted
Our settings are a bit different from the sample. We call Page.ConvertToTiff() with 32bpp and 300 dpi which gives the 16GB burst.
We also tried using Page.Draw() with some different results:
72 dpi -> 9GB
300 dpi -> Ok, but the line is drawn incorrectly
301 dpi -> Ok, but no line is renderedChanging the settings on the Graphics object or RenderSettings (even the GdiSettings) didn’t make any difference.
Tuesday, June 26, 2018 1:32 PM -
User-2069324601 posted
Thank you.
It would be good to share ready-to-run C# code to make sure I am looking at the exact same thing that you are. Can you please follow up with our support?
Tuesday, June 26, 2018 1:42 PM -
User-603456352 posted
Make sure to run on 64bit. Running this as 32bit ‘only’ uses 2GB memory.
Document document; using (FileStream fs = new FileStream(@"6810-b88d5dbf-371e-4197-baea-c0f678f91b40.pdf", FileMode.Open, FileAccess.Read)) { document = new Document(fs); } double[] resolutions = {72d, 100d, 300d, 301d}; int i = 1; foreach (Page page in document.Pages) { foreach (double resolution in resolutions) { ConvertToTiffOptions tiffOptions = new ConvertToTiffOptions(resolution, TiffCompression.Lzw); tiffOptions.PixelFormat = PixelFormat.Rgba32Bpp; using (FileStream fs = new FileStream(String.Format(CultureInfo.InvariantCulture, "ConvertToTiff_page{0}_{1}dpi.tiff", i, (int) resolution), FileMode.Create, FileAccess.Write)) { page.ConvertToTiff(fs, tiffOptions); } using (Bitmap bitmap = new Bitmap((int) (page.Width * resolution / 72d + 0.5), (int) (page.Height * resolution / 72d + 0.5), System.Drawing.Imaging.PixelFormat.Format24bppRgb)) using (Graphics g = Graphics.FromImage(bitmap)) { g.SmoothingMode = SmoothingMode.AntiAlias; g.ScaleTransform((float) (resolution / 72d), (float) (resolution / 72d)); g.Clear(Color.White); page.Draw(g); bitmap.Save(String.Format(CultureInfo.InvariantCulture, "Draw_page{0}_{1}dpi.png", i, (int)resolution)); } } i++; }
Tuesday, June 26, 2018 2:41 PM -
User-603456352 posted
Hi Frank, were you able now to reproduce it, the memory burst to 16GB?
Monday, July 2, 2018 9:18 PM