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. Image for the cookie policy date
close icon

Creating a page of arbitrary inch size and filling with an image?

We have an application that generates data graphs. These graphs have a vertical scale that represents a depth, and the horizontal scale represents some data point value.

The vertical scale, when turned into PDF or printed needs to match a particular physical scale. That is we could have a scale that is 5":100' (five inches of paper/PDF vertical = 100 feet of depth in the chart vertical scale).

I am trying to figure out how to do this, but can't seem to get it.

The image has already been created to the right dimensions assuming 96 DPI (it is generated for the screen currently). I would like to generate a page that is of a given width (typically 8.5", but could be different) with a length that is appropriate for the image we're trying to place on it.

I guess I'm asking this: How can I create a page of arbitrary inch size and put an image on it to take up the entirety of the page??


1 Reply

YG Yavanaarasi G Syncfusion Team May 5, 2008 08:17 AM UTC

Hi Nils,

Thank you for your interest in Syncfusion products.

Essential PDF images are rendered as points not as DPI. Images in Pixels/Inches can be converted to points and are then rendered into PDF as points.

Here is a code snippet:

PdfDocument pdfDoc = new PdfDocument();
PdfUnitConvertor con = new PdfUnitConvertor();

//converts inches to points
float height = con.ConvertUnits(718, PdfGraphicsUnit.Inch, PdfGraphicsUnit.Point);
float width = con.ConvertUnits(1048, PdfGraphicsUnit.Inch, PdfGraphicsUnit.Point);
PointF location = new PointF(0, 0);
SizeF pageSize = new SizeF(width, height);
PdfBitmap s=new PdfBitmap(Image.FromFile(path));
page.Graphics.DrawImage(s,location );
pdfDoc.Save("Sample.pdf");


Here is a sample for your reference:

http://websamples.syncfusion.com/samples/PDF.Windows/73331/main.htm

Please let me know if you have any other concerns.

Regards,
G.Yavana


Loader.
Live Chat Icon For mobile
Up arrow icon