PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Apr 27, 2024 7:39 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Jan 31, 2008 12:50 pm 
Offline

Joined: Thu Sep 20, 2007 1:06 pm
Posts: 15
I'm starting to get some trouble with some pdf documents when I try to add margins to them... it doesn't happen all the time, in fact it almost never happens... When debugging I can't see anything wrong until it throws the exception "Object reference not set to an instance of an object" when I try to use the following code:

--

// Add a new page to the output document
PdfPage page = outputDocument.AddPage(CreatePageFromSize(printSize));

XGraphics _grPage = XGraphics.FromPdfPage(page);

// Select current page from the original document
orgForm.PageNumber = i + 1;

// Create a box on the output docuement page that fits the current original document page.
XRect box = new XRect(((printSize.Width - orgForm.Page.Width) / 2), ((printSize.Height - orgForm.Page.Height) / 2), orgForm.Page.Width.Point, orgForm.Page.Height.Point);

_grPage.DrawImage(orgForm, box);

--

this is the stack trace:
at PdfSharp.Pdf.PdfObject.ImportClosure(PdfImportedObjectTable importedObjectTable, PdfDocument owner, PdfObject externalObject)
at PdfSharp.Pdf.Advanced.PdfFormXObject..ctor(PdfDocument thisDocument, PdfImportedObjectTable importedObjectTable, XPdfForm form)
at PdfSharp.Pdf.Advanced.PdfFormXObjectTable.GetForm(XForm form)
at PdfSharp.Pdf.PdfPage.GetFormName(XForm form)
at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.GetFormName(XForm form)
at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.Realize(XImage image)
at PdfSharp.Drawing.Pdf.XGraphicsPdfRenderer.DrawImage(XImage image, Double x, Double y, Double width, Double height)
at PdfSharp.Drawing.XGraphics.DrawImage(XImage image, Double x, Double y, Double width, Double height)
at PdfSharp.Drawing.XGraphics.DrawImage(XImage image, XRect rect)
at vulkan.filemanager.Business.PdfLogic.AddCutMarginToDocument(String documentPath, PrintPaperFormat paperFormat) in C:\folder\file.cs:line 395


---


Could it be that pdf files from some pdf-converters lacks some attributes that pdfSharp is looking for? and which could it be? and can I add it before running it through my method?
I can't find anything in general with the pdf that could be wrong, and I haven't created it myself. All I know is in the application attribute under the pdf's document properties it says "Application: Writer"... so I don't know what application was used to create the file...


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 390 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