|
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 |
drakaan
Joined: 25 Jan 2007 Posts: 2
|
Posted: Thu Jan 25, 2007 9:44 pm Post subject: Offset in DocumentRenderer or MigradocPrintDocument |
|
|
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. |
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: Tue Feb 20, 2007 5:45 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
Stefan Lange
Joined: 12 Oct 2006 Posts: 47 Location: Cologne, Germany
|
Posted: Thu Mar 08, 2007 10:55 pm Post subject: |
|
|
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. |
|
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
|
|