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.
Unfortunately, activation email could not send to your email. Please try again.

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

Thread ID:

Created:

Updated:

Platform:

Replies:

73331 May 1,2008 04:46 PM May 5,2008 04:17 AM Windows Forms 1
loading
Tags: PDF
Nils Benson
Asked On May 1, 2008 04:46 PM

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??


Yavanaarasi G [Syncfusion]
Replied On May 5, 2008 04:17 AM

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


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.

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.

;