IText large pictures - c#

I am writing program to generate PDF from pictures. I want to my pictures will be in normal size foreach page.For example i have image 2000px width and 10000px height and I don`t want to scalling this image. I want his natural size in PDF and not constant A3, A4 or A0. How can I solved that?
Thanks for helps.

If you know the dpi it's just a matter of creating a page with the correct size.
For example with 300dpi and 2000px the size would be (2000/300)*72=480.

Related

Copy and resize a document and fit it into box

I'm using PDFsharp to create a PDF.
I am trying to copy another document/image (PDF format with A3 size) and paste it within the image box, in the new document (A4 size).
In the new document, there would be an image details box and an image box.
So, how do I copy the image from another PDF into the image box in the new document?
Below is the sample I need to create using PDFsharp.
You can draw pages from other PDF files like you draw images - draw them anywhere at any angle and any size.
You may have to do some calculations to maintain the aspect ratio.
See the Two Pages on One sample:
http://pdfsharp.net/wiki/TwoPagesOnOne-sample.ashx
Lines 40 and 54 draw PDF pages. Check the lines above for prerequisites.

rdlc Report background image doesn't fit page

I created a rdlc report and set background image to it but I can't find a way to make the image fit the page size like A4 or something .. the image is large and resizing it didn't fix the issue
how to set the background to fit the report page
thanks in advance
You can not. All you can do is have an image that is smaller than the page size repeat in either direction using the BackgroundRepeat property.

abcPDF is malforming my image after adding it to a pdf

I'm getting a byte array representing a TIFF file from my server, converting it into an XImage, and then adding it to a new pdf document. The image in question is 1280x800 (it was a screenshot) and is being stretched out and lengthened to fit the height and width of a standard pdf page. How do I fix this?
Try this:
doc.MediaBox.String = img.BoundingBox.String;
doc.Rect.String = doc.MediaBox.String;
where doc is Doc and img is XImage
The particular problem you have is due to having the printer set to Portrait.
Being a PDF object, you may need to emulate a page that mimics the image size you are after.
You might be better off sending your original document to an image and adding your TIFF file.
Depends on how the PDF page is being built. What you probably want to do is ensure that the PDF page that you are creating has the same aspect ratio as your image rather than defaulting to a letter sized page.
Since you don't specify how you're making the PDF page, I can't help you specifically. But in general, PDF pages are in units of 1/72 of an inch. You can figure the right size page like this:
const kPdfPageUnitSize = 72f;
float GetPdfSize(int nPixels, float dotsPerInch) {
return (nPixels / dotsPerInch) * kPdfPageUnitSize;
}
// later
float pdfwidth = GetPdfSize(image.Width, image.Resolution.X); // or however you have this
float pdfheight = GetPdfSize(image.Height, image.Resolution.Y);
As I can see, image scale coefficient is incorrect. You should divide image Height and image Width on 1,33(3) ( i.e. 96f/72f )
By default PDF user unit is 1⁄72 inch, so your image DPI should be proportional with original.

Generating Text to a PNG File with Transparent Background

I need to Export some PNG Images with Transparent Background from a C# Application .
But that is not a Huge Concern .
What make's it complicated and beyond my knowledge is ,how am i able to Export to PNG Image File With Transparent Background with Some Text in it,like a Label only without Background so in that way i can export as many images i want with Different Text into it.
And that PNG should had the Size of the Label ,or if there is a way it should FIT the Font Size and Text Length ,so it Height and Width should be same as Font one .
Bests.
You're looking for the Bitmap and Graphics classes, along with the Font class and the TextRenderer.MeasureText method.

Setting image DPI in relation to height/width C#

I'm writing an application to send some images to a third party, and the images must be 200x200 DPI. The image is a Bitmap and is sized at 500 width and 250 height.
The first time I tested the images with the third party, my resolution was incorrect. I merely used image.SetResolution(200,200) to correctly set it to 200x200. This, however, only changed the resolution tag for the image and did not properly, according to my third party technical contact, adjust the image height and width.
Is there a ratio that I can use so that for each X units I increment the resolution, I merely increment the corresponding height or width Y units? I thought that I could just increment resolution without having to increment height or width.
Thank you,
Aaron.
An image stored digitally has no meaningful concept of DPI. DPI comes into play when reproducing an image on a physical device.
You need to adjust the image size with regard to the DPI of the physical device, and the desired size of the output on that device.
For example, if a printer tells you they need an image at 300dpi to fill a space of 4in x 4in then you would provide them a bitmap with a size of 1200x1200 pixels. This image would end up with a physical size of 4in x 4in on a 300dpi output device. On a 600dpi device the same image would have an output size of 2in x 2in.
When dealing with digital images, you usually refer to PPI, which is pixels per inch. DPI is not directly related to digital image resolution.
So, if you look at a image that is 200px by 200px # 200PPI, you will have an image that is 1 inch by 1 inch.

Categories