PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon May 06, 2024 1:11 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: PDF Page size
PostPosted: Thu Mar 04, 2010 7:03 am 
Offline

Joined: Fri Feb 26, 2010 11:15 pm
Posts: 10
hi,

I have generated a pdf using PDF sharp and another file generated from acrobat. when I see both the files I noticed PDF sharp shrink the content little size. Why is the difference? I am setting the page size (816,1056). I am seeing font size are same but overall page size is not matched with original one. please let me know.

Thanks,
Ganesh


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Page size
PostPosted: Thu Mar 04, 2010 8:41 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
Hi!
ganpp wrote:
Why is the difference?

PDFsharp can create documents with any page size (default is IIRC DIN A4 if no page size is set).

My Acrobat also creates A4 pages - exactly same size, no difference.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Page size
PostPosted: Wed Mar 10, 2010 1:24 am 
Offline

Joined: Fri Feb 26, 2010 11:15 pm
Posts: 10
Hi,

I am getting the source from fixed document and writing as PDF using PDF sharp. I have my custom model of classes like FixedPage,Glyph,Line,Rectangle... before I write a string I get a text from textblock and assigned to Glyphs object.

foreach (Element page in fixedDocument.Children)
{

FixedPage fixedPage = (FixedPage)page;
XGraphics pageGfx = CreatePdfPage(fixedPage);
XForm staticForm = new XForm(_page.Owner,
XUnit.FromPoint(_page.Width), XUnit.FromPoint(_page.Height));
_formGfx = XGraphics.FromForm(staticForm);
e.g
_formGfx.DrawString(glyph.UnicodeString, fontToUse, glyphBrush, layoutRect, textFormat);

_formGfx.Dispose();
}

Please let me know am I doing right way of writing a pdf page. If I take a print out of generated PDF and original one I am seeing custom one y co-ordinate gone down and size of font reduced.


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Page size
PostPosted: Wed Mar 10, 2010 8:58 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
Hi!
ganpp wrote:
If I take a print out of generated PDF and original one I am seeing custom one y co-ordinate gone down and size of font reduced.

When printing with Adobe Reader, you can control how Reader treats page sizes. Make sure that Reader is not scaling your pages while printing.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Page size
PostPosted: Thu Mar 11, 2010 7:08 am 
Offline

Joined: Thu Feb 25, 2010 10:25 am
Posts: 8
I had the same problem, at least I think so.

On the PDF (in Acrobat), it looked perfect, but when I print it is comprimised, and looked badly. You should consider the print margins ... (Even if you generated pdf is on a4)

I've done it this way:
Code:
            // Create an empty page
           
            page = document.AddPage();
            page.Size = PageSize.A4;
 
            pageMargeHeight = XUnit.FromInch(10.19);
            pageMargeWidth = XUnit.FromInch(7.77);

            pageMargeTop = XUnit.FromInch(0.75);
            pageMargeLeft = XUnit.FromInch(0.25);
            pageMargeBottom = page.Height - (XUnit.FromInch(0.75));
            pageMargeRight = page.Width - (XUnit.FromInch(0.25));

            // Get an XGraphics object for drawing
            gfx = XGraphics.FromPdfPage(page);
            tf = new XTextFormatter(gfx);

Good luck,
Greets Gerard


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Page size
PostPosted: Thu Mar 11, 2010 6:58 pm 
Offline

Joined: Fri Feb 26, 2010 11:15 pm
Posts: 10
Where to set the pageMargin variables?


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Page size
PostPosted: Fri Mar 12, 2010 10:28 pm 
Offline

Joined: Fri Feb 26, 2010 11:15 pm
Posts: 10
Hi,

I want to write PDF using PDFsharp for tax forms 1040. When I take printout, page size has squeezed. Please provide a solution.

_page = _document.AddPage();
_page.Width = fixedPage.Width;
_page.Height = fixedPage.Height;
//_page.Size = PdfSharp.PageSize.A4;

//XUnit pageMargeHeight = XUnit.FromInch(11.69);
//XUnit pageMargeWidth = XUnit.FromInch(8.27);

XUnit pageMargeTop = XUnit.FromInch(0.75);
XUnit pageMargeLeft = XUnit.FromInch(0.25);
XUnit pageMargeBottom = _page.Height - (XUnit.FromInch(0.75));
XUnit pageMargeRight = _page.Width - (XUnit.FromInch(0.25));

XTextFormatter tt = new XTextFormatter(gfx);
// Make a new bounding box for the contents of the page

XRect box = new XRect(0,0, pageMargeRight.Point,pageMargeBottom.Point );


form.PageNumber = i;
form.Page.Rotate = 0;
// Add the contents of the page to the new page

gfx.DrawImage(form, box);
}

doc.Save(@"c:\pdf\rescale3.pdf");


Top
 Profile  
Reply with quote  
 Post subject: Re: PDF Page size
PostPosted: Mon Mar 15, 2010 3:18 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3097
Location: Cologne, Germany
Hi!
ganpp wrote:
Please provide a solution.

I cannot do that as long as I don't know where the problem is.

When printing with Adobe Reader, you can control how Reader treats page sizes. Make sure that Reader is not scaling your pages while printing.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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

All times are UTC


Who is online

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