Welcome Guest Search | Active Topics | Sign In | Register

Putting A5 PdfPage into an A4, with a scale of 1 Options
Andreea
Posted: Wednesday, January 17, 2018 5:48:53 AM
Rank: Newbie
Groups: Member

Joined: 1/17/2018
Posts: 5
Hi,

I've updated yesterday the EO.Pdf for .NET to the new version.
Before, I was able to set the size of a PdfPage that initially was A5 to a A4.
Now I change the size of the page into A4 dimensions, but the final result is a page with A5 sizes.

I do something like this:

Code:
public void GenerateDocument (GenerateDocumentParameters parameters, Stream output)
        {
            var pdfDocs = new PdfDocument();
            foreach (var document in parameters.Documents)
            {
                pdfDocs = this.RenderPdfDocument(document, parameters.Request);
            }

            pdfDocs.Save(output);
        }

private PdfDocument RenderPdfDocument(DocumentInfo document, PdfDocumentRequest request)
        {
            PdfDocument pdf;
           
            if (document.AttachmentType == AttachmentType.Pdf)
            {
                pdf = new PdfDocument(document.Stream);

                foreach (var page in pdf.Pages)
                {
                    page.Size = new EO.Pdf.Drawing.PdfSize(PageSizes.A4Landscape.Width, PageSizes.A4Landscape.Height);
                }
            }

            SetDocumentInfo(pdf, document.Metadata?.Title, request?.Info);
            return pdf;
        }


This is the A5 pdf used: https://drive.google.com/open?id=1_qcV74WjVDfCrMNoziarQiNsObYrG3sM

Thank you!
eo_support
Posted: Wednesday, January 17, 2018 10:18:19 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
Hi,

Please try to use the following code:

Code: C#
//Your original code to change page size
page.Size = new_size...

//This line is important
page.CropBox = page.MediaBox;


A PDF page has two important values that are related to size: media box and crop box. Media box defines the overall "paper size" and crop box defines what's visible. Currently setting PdfPage's Size property only changes MediaBox. We will look into it and see if we can automatically update crop box as well.

Additionally, your page has a black background. This background is part of the page contents ---- so once you extend the page size, the content will not be extended and you will see the extended portion has a white background. So you may need to have some other measures to address that.

Thanks!
Andreea
Posted: Friday, January 26, 2018 1:57:45 AM
Rank: Newbie
Groups: Member

Joined: 1/17/2018
Posts: 5
Thank you! That solved my problem :).
eo_support
Posted: Friday, January 26, 2018 8:12:24 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,071
You are welcome. Please feel free to let us know if there is anything else.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.