PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Sep 24, 2018 5:07 pm

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: Thu Jan 25, 2007 9:44 pm 
Offline

Joined: Thu Jan 25, 2007 9:32 pm
Posts: 2
I've boiled it down to a fairly simple example case, and I am seeing the following:

Printing to an HP Laserjet 4 printer, I get different results depending on whether I print directly or open a saved document that I created with MigraDoc.

There is a specific offset difference between the PDFDocumentRenderer.Save document and the directly-printed one.

All objects in the directly printed PDF appear to be .25inches to the right and .33 inches down from where they appear in the same PDF saved to a file.

I used the same code to build the document in two asp.net pages, saved one to a file (rendered with PDFDocumentRenderer, so I can .Save), and printed the other directly (rendered with DocumentRenderer so I can .Print), and regardless of which relative horizontal setting I use (well, between page page and margin), if they are set the same on each version, I get that particular offset between elements on the two pages.

The PDFDocumentRenderer version appears to be correct, as far as placement of objects on the page goes, so I suspect there's a problem in DocumentRenderer. I plan to look into it tomorrow.

On what may be a related note, in order to build Migradoc successfully (the latest version), I had to remove several assembly references that pointed to "MigraDocLite.xxx" and replace them with references to "MigraDoc.xxx". I have an older version of MigraDoc/PDFSharp that doesn't have this problem, but it also doesn't have the text layout stuff.

Any pointers are appreciated.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Feb 20, 2007 5:45 pm 
Offline
empira Employee
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2862
Location: Cologne, Germany
We can replicate this behaviour but haven't solved it.

PDFsharp ignores the non-printable area of the page. The offset is printer and printer driver specific.

We'll fix it soon.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Mar 08, 2007 10:55 pm 
Offline
empira Employee
User avatar

Joined: Thu Oct 12, 2006 10:07 pm
Posts: 49
Location: Cologne, Germany
It's a bug in MigraDocPrintDocument.

Add this to class MigraDocPrintDocument:
Code:
[DllImport("gdi32.dll")]
static extern int GetDeviceCaps(IntPtr hdc, int capability);
const int PHYSICALOFFSETX = 112; // Physical Printable Area x margin
const int PHYSICALOFFSETY = 113; // Physical Printable Area y margin

And this into function OnPrintPage
Code:
Graphics graphics = e.Graphics;
IntPtr hdc = graphics.GetHdc();
int xOffset = GetDeviceCaps(hdc, PHYSICALOFFSETX);
int yOffset = GetDeviceCaps(hdc, PHYSICALOFFSETY);
graphics.ReleaseHdc();
graphics.TranslateTransform(-xOffset * 100 / graphics.DpiX, -yOffset * 100 / graphics.DpiY);


Setting OriginAtMargins = true is the correct solution by documentation of GDI+, but it does not work.


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 1 guest


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