Export to PDF, what is the correct Mediabox size for A4?

2 posts, 0 answers
  1. Mi
    Mi avatar
    16 posts
    Member since:
    Apr 2011

    Posted 15 Dec 2013 Link to this post

    Hi!

    When I use this code, to create an empty PDF file (2013Q3SP1):

    var filename = "C:\\temp\\test.pdf";
    var doc = new Telerik.Windows.Documents.Model.RadDocument();
    var stream = new FileStream(filename, FileMode.Create);
    var pdfExp = new Telerik.Windows.Documents.FormatProviders.Pdf.PdfFormatProvider();
     
    pdfExp.Export(doc, stream);
    stream.Close();

    and look at test.pdf I get

    /MediaBox [0 0 612 792]

    This is OK for letter format, which is the default.

    But when I set the size to A4:

    doc.SectionDefaultPageSize = Telerik.Windows.Documents.Model.PaperTypeConverter.ToSize(Telerik.Windows.Documents.Model.PaperTypes.A4);
    pdfExp.Export(doc, stream);
    stream.Close();

    the Mediabox looks like this

    /MediaBox [0 0 594.75 842.25]

    I cannot find an official reference which is the correct size, but when I do a google search with https://www.google.de/search?q="%2FMediaBox+%5B0+0+594.75+842.25%5D" I just get one page of results.But if I use https://www.google.de/search?q=%2FMediaBox+%5B0+0+595+842%5D to search, I get hundreds of pages with this result.

    Could you check, which is the correct value and If /MediaBox [0 0 595 842] is the correct one, how to fix it?

    Thanks 

    Mike



  2. Alexander
    Admin
    Alexander avatar
    41 posts

    Posted 18 Dec 2013 Link to this post

    Hello Mi Ha,

    The paper A4 type has dimensions of 793 width and 1123 height. When those values are converted to point size, the resulting values are 594.75 and 842.25. In the PDF Specification it is not stated that the MediaBox rectangle should not have dimensions which are floating point numbers, so we are not considering a change in the behavior. 

    If you have further questions or some other concerns do not hesitate to contact us again.

    Regards,
    Alexander
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top