I am working with PDF Form fields. I add values programaticaly, save the PDF and then want to generate a preview of the document. The source PDF is attached as well as the output. Please tell me where I am doing something wrong.
I tried to add DPI x and y to the code when saving an image but it just seems to add a white bank on top and right side of the picture.
I also tried both Bitmap and MetaFile. No difference whatsoever.
- Code: Select all
...
var content = new byte[fi.Length];
using (var s = fi.OpenRead())
{
s.Read(content, 0, content.Length);
}
using (var doc = new PdfDocument())
{
doc.LoadFromBytes(content, file.DocumentPassword);
var img = doc.SaveAsImage(0, PdfImageType.Metafile);
doc.Close();
doc.Dispose();
img.Save(fiOut.FullName, ImageFormat.Png);
}