This is a migrated thread and some comments may be shown as answers.

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

1 Answer 579 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Mi
Top achievements
Rank 1
Mi asked on 15 Dec 2013, 08:44 AM
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



1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 18 Dec 2013, 04:28 PM
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 >>
Tags
RichTextBox
Asked by
Mi
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or