After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 633123 - pdfmod can't open pdfopt-optimized pdf (InvalidCastException in get_Outlines)
pdfmod can't open pdfopt-optimized pdf (InvalidCastException in get_Outlines)
Status: RESOLVED FIXED
Product: pdfmod
Classification: Other
Component: general
0.9.x
Other Linux
: Normal major
: ---
Assigned To: pdfmod-maint
pdfmod-maint
Depends on:
Blocks:
 
 
Reported: 2010-10-25 18:26 UTC by Nigel Stewart
Modified: 2011-03-03 18:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
PDF documentation that can't be loaded by pdfmod (25.45 KB, application/pdf)
2010-10-25 18:26 UTC, Nigel Stewart
Details
Step 1/3 - Original .pdf file (24.74 KB, application/pdf)
2010-10-25 18:30 UTC, Nigel Stewart
Details
Step 2/3 - use pdfmod to edit the properties - title, author, etc, and save (28.61 KB, application/pdf)
2010-10-25 18:32 UTC, Nigel Stewart
Details
Step 3/3 - Run though pdfopt (25.34 KB, application/pdf)
2010-10-25 18:33 UTC, Nigel Stewart
Details

Description Nigel Stewart 2010-10-25 18:26:18 UTC
Created attachment 173195 [details]
PDF documentation that can't be loaded by pdfmod

I noticed this with PDF Mod 0.8.3 as packaged for Ubuntu 10.10 x86_64.

But I saw the same building pdfmod-0.9.0 from source.

Attaching repro .pdf file.

- Nigel


$ ~/Downloads/pdfmod-0.9.0/bin/PdfMod.exe docs/license/license.pdf
[Debug 13:19:14.175] Starting PdfMod
[Debug 13:19:14.260] Loaded custom AccelMap from /home/nstewart/.config/pdfmod/gtk_accel_map
[Debug 13:19:14.289] Cache directory set to /home/nstewart/.cache/pdfmod
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.InvalidCastException: Cannot cast from source type to destination type.
  at PdfSharp.Pdf.Advanced.PdfCatalog.get_Outlines () [0x00000] in <filename unknown>:0 
  at PdfSharp.Pdf.PdfDocument.get_Outlines () [0x00000] in <filename unknown>:0 
  at PdfMod.Gui.BookmarkView.SetDocument (PdfMod.Pdf.Document new_doc) [0x00000] in <filename unknown>:0 
  at PdfMod.Gui.Client+<LoadPath>c__AnonStorey10.<>m__22 () [0x00000] in <filename unknown>:0 
  at Hyena.ThreadAssist+<BlockingProxyToMain>c__AnonStoreyF.<>m__4 () [0x00000] in <filename unknown>:0 
  at PdfMod.Gui.Client+<RunIdle>c__AnonStorey14.<>m__21 () [0x00000] in <filename unknown>:0 
  at GLib.Idle+IdleProxy.Handler () [0x00000] in <filename unknown>:0 
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal)
   at GLib.Idle+IdleProxy.Handler()
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at PdfMod.Gui.Client..ctor(Boolean loadFiles)
   at PdfMod.PdfMod.Main(System.String[] args)
Comment 1 Nigel Stewart 2010-10-25 18:30:40 UTC
Created attachment 173196 [details]
Step 1/3 - Original .pdf file

This is the original license.pdf file, unmodified
Comment 2 Nigel Stewart 2010-10-25 18:32:02 UTC
Created attachment 173197 [details]
Step 2/3 - use pdfmod to edit the properties - title, author, etc, and save

Saved from pdfmod with properties changed.
Comment 3 Nigel Stewart 2010-10-25 18:33:26 UTC
Created attachment 173198 [details]
Step 3/3 - Run though pdfopt

$ pdfopt 1.pdf 2.pdf
   **** Warning:  File has an invalid xref entry:  23.  Rebuilding xref table.

$ pdfmod 2.pdf 
[Debug 13:33:08.714] Starting PdfMod
[Debug 13:33:08.723] Initializing i18n catalog from /usr/share/locale/
[Debug 13:33:08.827] Loaded custom AccelMap from /home/nstewart/.config/pdfmod/gtk_accel_map
[Debug 13:33:08.866] Cache directory set to /home/nstewart/.cache/pdfmod
Author           = B
CreationDate     = 9/22/2008 6:21:13 PM
Creator          = PScript5.dll Version 5.2.2
Keywords         = C
ModificationDate = 9/22/2008 6:21:13 PM
Producer         = PDFsharp 1.2.1269-g (www.pdfsharp.com) (Original: GPL Ghostscript 8.15)
Subject          = D
Title            = A
Page Layout      = SinglePage
Page Mode        = UseNone
SecurityLevel    = None
Settings.TrimMgns= PdfSharp.Pdf.TrimMargins
Version          = 14
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.InvalidCastException: Cannot cast from source type to destination type.
  at PdfSharp.Pdf.Advanced.PdfCatalog.get_Outlines () [0x00000] in <filename unknown>:0 
  at PdfSharp.Pdf.PdfDocument.get_Outlines () [0x00000] in <filename unknown>:0 
  at PdfMod.Gui.MetadataEditorBox.HandleDocumentLoaded (System.Object o, System.EventArgs e) [0x00000] in <filename unknown>:0 
  at (wrapper delegate-invoke) System.EventHandler:invoke_void__this___object_EventArgs (object,System.EventArgs)
  at PdfMod.Core.Client.OnDocumentLoaded () [0x00000] in <filename unknown>:0 
  at PdfMod.Gui.Client+<LoadPath>c__AnonStorey6.<>m__E () [0x00000] in <filename unknown>:0 
  at PdfMod.Gui.Client+<RunIdle>c__AnonStoreyA.<>m__D () [0x00000] in <filename unknown>:0 
  at GLib.Idle+IdleProxy.Handler () [0x00000] in <filename unknown>:0 
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal)
   at GLib.Idle+IdleProxy.Handler()
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at PdfMod.Gui.Client..ctor(Boolean loadFiles)
   at PdfMod.PdfMod.Main(System.String[] args)
Comment 4 Gabriel Burt 2010-10-25 19:29:51 UTC
I can reproduce this.
Comment 5 Gabriel Burt 2010-10-26 15:51:07 UTC
*** Bug 633173 has been marked as a duplicate of this bug. ***
Comment 6 Gabriel Burt 2011-03-03 16:18:52 UTC
Apparently pdfopt writes out the outline not as a reference like we expect, but something else.  Need to 1) determine what it is actually writing it out as 2) make sure it's legitimate and we should actually support it and 3) handle it.

Trace with line numbers:

System.InvalidCastException: Cannot cast from source type to destination type.
  at PdfSharp.Pdf.Advanced.PdfCatalog.get_Outlines () [0x0000b] in /home/gabe/Projects/pdfmod/lib/PdfSharp/PdfSharp.Pdf.Advanced/PdfCatalog.cs:150 
  at PdfSharp.Pdf.PdfDocument.get_Outlines () [0x00000] in /home/gabe/Projects/pdfmod/lib/PdfSharp/PdfSharp.Pdf/PdfDocument.cs:635 
  at PdfMod.Gui.BookmarkView.SetDocument (PdfMod.Pdf.Document new_doc) [0x000d5] in /home/gabe/Projects/pdfmod/src/PdfMod/Gui/BookmarkView.cs:70 
  at PdfMod.Gui.Client+<LoadPath>c__AnonStorey10.<>m__22 () [0x0001b] in /home/gabe/Projects/pdfmod/src/PdfMod/Gui/Client.cs:288 
  at Hyena.ThreadAssist+<BlockingProxyToMain>c__AnonStoreyF.<>m__4 () [0x00000] in /home/gabe/Projects/hyena/Hyena/Hyena/ThreadAssist.cs:82 
  at PdfMod.Gui.Client+<RunIdle>c__AnonStorey14.<>m__21 () [0x00000] in /home/gabe/Projects/pdfmod/src/PdfMod/Gui/Client.cs:445 
  at GLib.Idle+IdleProxy.Handler () [0x0000c] in /usr/src/packages/BUILD/gtk-sharp-2.12.10/glib/Idle.cs:73 
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal) in /usr/src/packages/BUILD/gtk-sharp-2.12.10/glib/ExceptionManager.cs:line 58
   at GLib.Idle+IdleProxy.Handler() in /usr/src/packages/BUILD/gtk-sharp-2.12.10/glib/Idle.cs:line 78
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run() in /home/gabe/Projects/gtk-sharp-2-12-branch/gtk/Application.cs:line 135
   at PdfMod.Gui.Client..ctor(Boolean loadFiles) in /home/gabe/Projects/pdfmod/src/PdfMod/Gui/Client.cs:line 153
   at PdfMod.PdfMod.Main(System.String[] args) in /home/gabe/Projects/pdfmod/src/PdfMod/Main.cs:line 39
Comment 7 Gabriel Burt 2011-03-03 18:17:47 UTC
Hrm, so the Outline object is a PdfNull object and not a PdfOutline like we expect.  I can't find in the PDF Reference that that's legal, but whatever, we'll handle it, replacing it with a PdfOutline object so the bookmarks are editable.

commit 7e1ef2f2513bf31dcb613ce97b066595f00a1827
Author: Gabriel Burt <gabriel.burt@gmail.com>
Date:   Thu Mar 3 12:15:37 2011

    [PdfSharp] Fix crash if Catalog.Outlines is PdfNull (bgo#633123)