Menu

#481 out of memory exception trying to import pdf

5.X
open
nobody
None
5.8.2
Support
Medium
N/A
2018-09-28
2018-08-02
Tony Jones
No

Trying to import and existing pdf, size 31870k. Get the following.

I actually started with the PBM files but NAPS cannot import these, so I used imagemagick to convert from *.PBM->PDF.

It would be great it NAPS could natively import PBM

System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb)
at Ghostscript.NET.Viewer.GhostscriptViewerDisplayHandler.Page(IntPtr handle, IntPtr device, Int32 copies, Int32 flush)
at Ghostscript.NET.GhostscriptDisplayDeviceHandler.display_page(IntPtr handle, IntPtr device, Int32 copies, Int32 flush)
at Ghostscript.NET.Interpreter.GhostscriptInterpreter.Run(String str)
at Ghostscript.NET.Viewer.GhostscriptViewerPdfFormatHandler.ShowPage(Int32 pageNumber)
at Ghostscript.NET.Viewer.GhostscriptViewer.ShowPage(Int32 pageNumber, Boolean refresh)
at NAPS2.ImportExport.Pdf.GhostscriptPdfRenderer.<Render>d__6.MoveNext()
at System.Linq.Enumerable.Single[TSource](IEnumerable1 source) at NAPS2.Scan.Images.ScannedImageRenderer.Render(ScannedImage image) at NAPS2.ImportExport.Pdf.PdfSharpImporter.ExportRawPdfPage(PdfPage page, ImportParams importParams) at NAPS2.ImportExport.Pdf.PdfSharpImporter.<>c__DisplayClass6_0.<Import>b__3(PdfPage page) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at NAPS2.ImportExport.ImportOperation.Run(IEnumerable1 filesToImport, Action1 imageCallback, Boolean oneFile)

Discussion

  • Ben Olden-Cooligan

    The out-of-memory issue should hopefully be fixed in the latest version of NAPS2 (6.0b1).

     
    • Tony Jones

      Tony Jones - 2018-09-25

      Now just get "could not be imported" after 75 pages. v6.0.2

       
  • Ben Olden-Cooligan

    Could you attach your errorlog.txt file here? You can find it in the "%APPDATA%\NAPS2" folder. For example, if your user name is Tony, it would be in "C:\Users\Tony\AppData\Roaming\NAPS2".

     
  • Tony Jones

    Tony Jones - 2018-09-26

    2018-09-26 08:23:10.8547 Error importing PDF file. System.OverflowException: Overflow error.
    at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
    at NAPS2.ImportExport.Pdf.PdfSharpImporter.<>cDisplayClass6_0.<<import>b</import>0>d.MoveNext()

     
  • Tony Jones

    Tony Jones - 2018-09-27

    Distilled down to a single page.

    2018-09-27 10:35:21.2041 Error importing PDF file. System.OverflowException: Overflow error.
    at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task)
    at NAPS2.ImportExport.Pdf.PdfSharpImporter.<>cDisplayClass6_0.<<import>b</import>0>d.MoveNext()

     
  • Tony Jones

    Tony Jones - 2018-09-27

    Above is from 6.0.2

     
  • Ben Olden-Cooligan

    Thank you, that's very helpful. The problem was that the page size according to the PDF is very large (3m by 1.3m), which made it try to render a ridiculous number of pixels. A fix will be included in the next version (published soon).

     
  • Tony Jones

    Tony Jones - 2018-09-27

    Interesting. It was created by: 'magick convert image-0075.pbm test.pdf'

    $ magick identify image-0075.pbm
    image-0075.pbm PBM 8639x3805 8639x3805+0+0 1-bit Bilevel Gray 3.91904MiB 0.031u
    0:00.034

     
  • Tony Jones

    Tony Jones - 2018-09-27

    The actual scan that it came from was only three 8.5x11 sheets. Stitched together into a single image using Microsoft Image Composite Editor. Not really sure why the page size is being reported as 3m x 1.3m.

     
  • Ben Olden-Cooligan

    Yeah, PBM files don't store the resolution so I suppose ImageMagick inferred a lower resolution (and if you decrease the resolution while keeping the number of pixels the same, the page size increases).

     
  • Tony Jones

    Tony Jones - 2018-09-27

    Hmmn. I wonder if there are any useful arguments (to convert) to specify the page size.

     
  • Ben Olden-Cooligan

     
    • Tony Jones

      Tony Jones - 2018-09-28

      thanks, --density 300x300 which matches the initial scanning dpi allowed beta2 to import

       

Log in to post a comment.