We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Pdf Scale

Thread ID:

Created:

Updated:

Platform:

Replies:

141102 Nov 23,2018 04:25 PM UTC Nov 26,2018 11:39 AM UTC Xamarin.Forms 4
loading
Tags: PDF
José Donizete de Oliveira Júnior
Asked On November 23, 2018 04:25 PM UTC

Hi!

Can you help me please?

use PDF in this way:


public async Task SharePDFAsync(MemoryStream stream, string name, float width, float heigth)
        {
                //Create a new PDF document. 
                PdfDocument doc = new PdfDocument();

                doc.PageSettings.Width = width;
                doc.PageSettings.Height = heigth;

                //Add a page to the document. 
                PdfPage page = doc.Pages.Add();

                //Create PDF graphics for the page 
                PdfGraphics graphics = page.Graphics;

                //Load the image from the stream 
                PdfBitmap image = new PdfBitmap(stream);

                //Draw the image 
                graphics.DrawImage(image, 0, 0);
                MemoryStream ms = new MemoryStream();
                doc.Save(ms);

                //Close the document. 
                doc.Close(true);



                string filePath = await SaveAsync(ms, "pdf", name);
                await Show("test", "test", filePath);
            
        }

My question:

A jpeg file arrives as stream, with set size. I want to scale the PDF file to A4 and A3. The problem is that when I scale the PdfDocument the jpeg image saved in pdf comes out cut, does not reduce.

Is it possible to do what I want?

thankful


José Donizete de Oliveira Júnior
Replied On November 24, 2018 10:47 AM UTC

Hi!

I got what I wanted this way:

   Syncfusion.Drawing.SizeF size = PdfPageSize.A3;

   //Draw the image 
   graphics.DrawImage(image, 0, 0, size.Height, size.Width);

Let me know if it's the best method.

Thanks

Karthikeyan Chandrasekar [Syncfusion]
Replied On November 26, 2018 06:33 AM UTC

Hi José, 
The code snippet you have provided is the preferred solution to draw the image in specific size. To maintain the aspect ratio of the image, you have to recalculate the width and height before drawing it. Let me know if you need any further assistance in this. 

Regards, 
Karthikeyan  


José Donizete de Oliveira Júnior
Replied On November 26, 2018 11:11 AM UTC

Hi!

Thanks for listening.

Only that.



Karthikeyan Chandrasekar [Syncfusion]
Replied On November 26, 2018 11:39 AM UTC

You are welcome.  


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon