|
PDFsharp - moved to http://forum.pdfsharp.net/ Please visit the new PDFsharp forum at http://forum.pdfsharp.net/
|
View previous topic :: View next topic |
Author |
Message |
rudib
Joined: 04 Aug 2008 Posts: 2
|
Posted: Mon Aug 04, 2008 2:03 pm Post subject: Trouble with PDFs generated by Scribus |
|
|
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/PDFSharpScribusBug.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! |
|
Back to top |
|
|
Stefan Lange
Joined: 12 Oct 2006 Posts: 47 Location: Cologne, Germany
|
Posted: Mon Aug 04, 2008 10:20 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
rudib
Joined: 04 Aug 2008 Posts: 2
|
Posted: Tue Aug 05, 2008 9:55 am Post subject: |
|
|
Thanks for the quick reply, this fixes our problems. Many thanks. |
|
Back to top |
|
|
|
|
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 vote in polls in this forum
|
|