Brian.Li wrote:Hello,
Thanks for your inquiry.
I simulated a PDF file with several words "idotlessi", and then converted it to an image, but I did not reproduce your issue. To help us reproduce your issue and help you solve it, please provide your input file to help us investigate further. You could upload it here or send it to us (
[email protected]) via email. Thanks in advance.
Sincerely,
Brian
E-iceblue support team
Attached please find the input.pdf and the output.tif I generated.
Please note in the Output.tif the image does not have the last 2 lines from the input PDF and the first line contains idotlessi
The code snippet I used listed below.
JoinTiffImages(SaveAsImage(pdfDoc), strTifFile, EncoderValue.CompressionLZW);
public static void JoinTiffImages(Image[] images, string outFile, EncoderValue compressEncoder)
{
//use the save encoder
System.Drawing.Imaging.Encoder enc = System.Drawing.Imaging.Encoder.SaveFlag;
EncoderParameters ep = new EncoderParameters(2);
ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.MultiFrame);
ep.Param[1] = new EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)EncoderValue.CompressionLZW);
Image pages = images[0];
int frame = 0;
ImageCodecInfo info = GetEncoderInfo("image/tiff");
foreach (Image img in images)
{
if (frame == 0)
{
pages = img;
//save the first frame
pages.Save(outFile, info, ep);
}
else
{
//save the intermediate frames
ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.FrameDimensionPage);
pages.SaveAdd(img, ep);
}
if (frame == images.Length - 1)
{
//flush and close.
ep.Param[0] = new EncoderParameter(enc, (long)EncoderValue.Flush);
pages.SaveAdd(ep);
}
frame++;
}
}
private static Image[] SaveAsImage(PdfDocument document)
{
Image[] images = new Image[document.Pages.Count];
for (int i = 0; i < document.Pages.Count; i++)
{
//use the document.SaveAsImage() method save the pdf as image
images[i] = document.SaveAsImage(i, Spire.Pdf.Graphics.PdfImageType.Bitmap);
}
return images;
}
Login to view the files attached to this post.