-
Magick.NET versionMagick.NET-Q8-AnyCPU 13.6.0 Environment (Operating system, version and so on)Windows 11 Descriptionwhen i convert the image to pdf, it genrate the pdf page with a small size,not A4 size pageNumber 2 is normal A4 sizeso how can i get the A4 size pdf with small image? Steps to Reproduce
the test image used in code |
Beta Was this translation helpful? Give feedback.
Answered by
dlemstra
Feb 25, 2024
Replies: 1 comment 1 reply
-
You should set the density after you read the image. Setting it in the settings does nothing when you read those input files. Your code can be simplified to this: using var images = new MagickImageCollection();
var size = MagickGeometry.FromPageSize("a4");
var names = new string[] { "d20220118150203.png", "map.png" };
foreach (var name in names)
{
var image = new MagickImage(SRC + name);
image.Density = new Density(72);
if (image.Width > size.Width || image.Height > size.Height)
{
image.Resize(size);
}
//图片居中显示
image.Extent(size, Gravity.Center);
images.Add(image);
}
// Create pdf file with two pages
images.Write(DEST + "Merge.pdf"); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
liugt34
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should set the density after you read the image. Setting it in the settings does nothing when you read those input files. Your code can be simplified to this: