Extra large images to be fit on one page

hi,
i wnat Extra large images to be fit on one page, the problem is that there is only a little peace of that image to see ,not the entire one.

this is my code:

  PdfPage page = doc.Pages.Add();
                PdfBitmap image = new PdfBitmap(item);

                SizeF size = new SizeF(image.Width, image.Height);

                //Need to set page size here, if not it will use default size.
                doc.PageSettings.Size = size;

                if (size.Width > size.Height)
                    doc.PageSettings.Orientation = PdfPageOrientation.Landscape;

                //PdfTemplate template = page.CreateTemplate();
                //PdfGraphics g = page.Graphics;
                //g.DrawPdfTemplate(template, new PointF(0, 0), new SizeF(page.GetClientSize().Width, page.GetClientSize().Height));

                PdfLayoutFormat format = new PdfLayoutFormat
                {
                    Break = PdfLayoutBreakType.FitPage,
                    Layout = PdfLayoutType.OnePage
                };

                image.Draw(page, 0, 0);
tank you

8 Replies

DB Dilli Babu Nandha Gopal Syncfusion Team October 3, 2018 09:19 AM UTC

Hi jjads, 
 
Thank you for contacting Syncfusion support. 
 
We recommend to use Draw(PdfPage,RectangleF) which will fit the extra large image in PDF document based on the specified RectangleF position. The following code example illustrates the above behavior so kindly replace this line in your application. 
    image.Draw(page, new RectangleF(0, 0, image.Width, image.Height)); 
 
Please let us know if the provided solution fulfills your requirement. 
 
To know more about converting Image to PDF with different PDF page size, kindly refer the forum 139695  
 
Regards, 
Dilli babu. 



JJ jjads October 3, 2018 11:11 AM UTC

Can you provide a solution with code ? I Still seems to be the same ... even after replacing that code


DB Dilli Babu Nandha Gopal Syncfusion Team October 4, 2018 10:12 AM UTC

Hi jjads, 
 
Yes, we have prepared a sample based on your requirement which can be downloaded from the following link. 
 
Please let us know if the sample fulfills your requirement. 
 
Regards, 
Dilli babu. 



JJ jjads October 4, 2018 07:00 PM UTC

hi tnanks, so far.

But actually I want the image not to be rotated , because they are alreaedy in the right position.

I removed the landscape mode, but now the images are cut off half way ,so the image ,pdf page is not fully visible.,

By the way syncfusion is auto-roating the images .

Is there a solution ?


JJ jjads October 5, 2018 05:27 AM UTC

best to keep the resolution of that image


DB Dilli Babu Nandha Gopal Syncfusion Team October 5, 2018 11:33 AM UTC

Hi jjads, 
 
Thank you for your update. 
 
To a set a page width more than a page height without changing the page orientation as landscape, page height must be more than page width. We have modified the sample as mentioned above which can be downloaded from the following link. 
 
Note: Page orientation must be set as landscape explicitly if a page width is higher than page height. 
 
Please let us know if you have any questions. 
 
Regards, 
Dilli babu. 



JJ jjads October 5, 2018 03:31 PM UTC

doesnt work, images are still cut off


DB Dilli Babu Nandha Gopal Syncfusion Team October 8, 2018 09:27 AM UTC

Hi jjads, 

Thank you for your update. 

We are unable to reproduce the reported image cut off issue in our latest sample (Updated on 10/5/2018, 7:33 AM). Please find the screen capture of the generated PDF file. 

 

As mentioned earlier, to a set a page width more than a page height without changing the page orientation as landscape, page height must be more than page width. The sample for this behavior is available here. 
To a set a page width more than a page height by changing the page orientation as landscape(default behavior) The sample for this behavior is available here. 
 
Please let us know if you have any questions. 
Regards, 
Dilli babu. 



Loader.
Up arrow icon