PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Mar 31, 2010 2:55 pm 
Offline

Joined: Wed Mar 31, 2010 2:30 pm
Posts: 6
My base language is C#. I am using PdfSharp 1.31 to draw header and footer on every page of the document. Header consists of line and string, footer consists of line and image.

Here's how I am looping through every page and drawing the header and footer.

Code:
PdfDocument doc = PdfSharp.Pdf.IO.PdfReader.Open(path);

foreach (PdfPage page in doc.Pages)
{
            XUnit pageWidth = page.Width;
            XUnit pageHeight = page.Height;
            XUnit headerLine = 50;
            XUnit footerLine = pageHeight - 50;
     
            XGraphics gfx = XGraphics.FromPdfPage(page);

            // header
            gfx.DrawLine(pen, 15, headerLine , pageWidth - 15, headerLine );
            gfx.DrawString(productName, fontReportHeader, brush, 15, 35, XStringFormat.Default); //productName is a string variable

            // footer
            gfx.DrawLine(pen, 15, footerLine , pageWidth, footerLine);
            gfx.DrawImage(imgLogo, pageWidth - imageWidth - 15, pageHeight - 49); // imgLogo is a XImage variable, imgWidth is imgLogo.PointWidth variable
)

doc.Save(path);


When I run this application, I get a warning as shown in the screenshot below. If I click on the ignore button (same warning comes up five times so I'll have to click ignore as many times), the output contains both the header and footer with lines, string and image. So I know the code is working, only problem is why the error popping up? Am I not doing my code the proper way? However, if I comment out the gfx.DrawString and gfx.DrawImage lines, the application does not throw any error and prints the two lines.

Image

Thanks.


Top
 Profile  
Reply with quote  
PostPosted: Wed Mar 31, 2010 3:33 pm 
Offline

Joined: Wed Mar 31, 2010 2:30 pm
Posts: 6
I found the solution to the problem. It was caused by an error being thrown somewhere else (not PdfSharp related error) before even reaching this stage of the code. The problem is gone now after I handled that problem.

Edit: No, that was false alarm, the error is still coming up.

Edit 2: Downloaded the PdfSharp v1.3.0 and ran the application. It works fine. No Assertion Failed messages anymore.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 201 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