Hi.
I have a "Custom handler" which returns a pdf. In the pdf I import an image. I want the page size is the size of the page.
This is the source code:
public void ProcessRequest(HttpContext context)
{
PdfDocument doc = new PdfDocument();
doc.ViewerPreferences.PageMode = PdfPageMode.FullScreen;
//read image
PdfBitmap image = new PdfBitmap("C:\\Users\\ccarranza\\Pictures\\Sin título.png");
//ImageSize
System.Drawing.SizeF size = new System.Drawing.SizeF(image.Width, image.Height);
System.Drawing.PointF location = new System.Drawing.PointF(0, 0);
System.Drawing.RectangleF rect = new System.Drawing.RectangleF(location, size);
PdfSection section = doc.Sections.Add();
section.PageSettings.SetMargins(0);
//Page Size
section.PageSettings.Width = image.Width;
section.PageSettings.Height = image.Height;
PdfPage page = section.Pages.Add();
As I can insert an image that fills the entire page created?
PdfGraphics g = page.Graphics;
PdfLayoutFormat format = new PdfLayoutFormat();
format.Layout = PdfLayoutType.Paginate;
image.Draw(page, rect, format);
doc.Save("Sample.pdf", context.Response, HttpReadType.Open);
}
But when you open the PDF page size is larger than the image inserted.
Attached PDF output on screen
Thank you very much for your help
Attachment:
test_198a9383.zip