PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Nov 17, 2018 12:24 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Aug 04, 2008 2:03 pm 
Offline

Joined: Mon Aug 04, 2008 1:19 pm
Posts: 2
Hi,

Here's a little project with a sample document exported from Scribus with PDF 1.3-1.5 output settings.

http://zoidberg.whiletrue.com/rudi/PDFS ... busBug.zip

Output from my machine:

Code:
test_pdf_1.3.pdf
System.NullReferenceException: Object reference not set to an instance of an object.
   at PdfSharp.Pdf.Advanced.PdfResources.AddFont(PdfFont font)
   at PdfSharp.Drawing.Pdf.PdfGraphicsState.RealizeFont(XFont font, XBrush brush, Int32 renderMode)
   at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.Realize(XFont font, XBrush brush, Int32 renderMode)
   at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.DrawString(String s, XFont font, XBrush brush, XRect rect, XStringFormat format)
   at PdfSharp.Drawing.XGraphics.DrawString(String text, XFont font, XBrush brush, XRect layoutRectangle, XStringFormat format)
   at PdfSharp.Drawing.XGraphics.DrawString(String s, XFont font, XBrush brush, Double x, Double y, XStringFormat format)
   at PDFSharpScribusBug.Program.Main(String[] args) in c:\code\pdfsharp_bug\PDFSharpScribusBug\Program.cs:line 30


test_pdf_1.4.pdf
System.NullReferenceException: Object reference not set to an instance of an object.
   at PdfSharp.Pdf.Advanced.PdfResources.AddExtGState(PdfExtGState extGState)
   at PdfSharp.Drawing.Pdf.PdfGraphicsState.RealizeBrush(XBrush brush, PdfColorMode colorMode)
   at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.DrawRectangle(XPen pen, XBrush brush, Double x, Double y, Double width, Double height)
   at PdfSharp.Drawing.XGraphics.DrawRectangle(XBrush brush, Double x, Double y, Double width, Double height)
   at PdfSharp.Drawing.XGraphics.DrawRectangle(XBrush brush, Int32 x, Int32 y, Int32 width, Int32 height)
   at PDFSharpScribusBug.Program.Main(String[] args) in c:\code\pdfsharp_bug\PDFSharpScribusBug\Program.cs:line 24


test_pdf_1.5.pdf
System.NullReferenceException: Object reference not set to an instance of an object.
   at PdfSharp.Pdf.Advanced.PdfResources.AddExtGState(PdfExtGState extGState)
   at PdfSharp.Drawing.Pdf.PdfGraphicsState.RealizeBrush(XBrush brush, PdfColorMode colorMode)
   at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.DrawRectangle(XPen pen, XBrush brush, Double x, Double y, Double width, Double height)
   at PdfSharp.Drawing.XGraphics.DrawRectangle(XBrush brush, Double x, Double y, Double width, Double height)
   at PdfSharp.Drawing.XGraphics.DrawRectangle(XBrush brush, Int32 x, Int32 y, Int32 width, Int32 height)
   at PDFSharpScribusBug.Program.Main(String[] args) in c:\code\pdfsharp_bug\PDFSharpScribusBug\Program.cs:line 24


We haven't been able to find a workaround yet (export settings or anything else). Debugging PDFSharp uncovered that this.Owner is null for these PDFDictionaries which obviously shouldn't be the case.

The project is bundled with PDFSharp 1.2, also crashes on 1.0.

Thanks!


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Aug 04, 2008 10:20 pm 
Offline
empira Employee
User avatar

Joined: Thu Oct 12, 2006 10:07 pm
Posts: 49
Location: Cologne, Germany
Hi,

you found a serious bug. Scribus uses a rare way of resource inheritance, which was yet not correctly handled in PDFsharp.

Fix InheritValues in PdfPage.cs.
Code:
     internal static void InheritValues(PdfDictionary page, InheritedValues values)
        ...
        if (res is PdfReference)
        {
          resources = (PdfDictionary)((PdfReference)res).Value.Clone();
          resources.Document = page.Owner;  // <<<<<<<<<<
        }
        else
          resources = (PdfDictionary)res;

        if (resources == null)
        {
          resources = values.Resources.Clone();
          resources.Document = page.Owner;  // <<<<<<<<<<
          page.Elements.Add(PdfPage.Keys.Resources, resources);
        }...

Regards


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Aug 05, 2008 9:55 am 
Offline

Joined: Mon Aug 04, 2008 1:19 pm
Posts: 2
Thanks for the quick reply, this fixes our problems. Many thanks.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group