Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Aug 10, 2021 1:03 pm

I am using the licensed version of Spire office. I was trying to convert a PDF to image, and I am getting the image with a word idotlessi as the first line and my last 2 lines are truncated. It is happening only for some PDF images. The spire.pdf version is 7.7.0.0

Let me know how I can correct this issue.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Wed Aug 11, 2021 2:05 am

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
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Aug 11, 2021 4:01 am

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;

}

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Wed Aug 11, 2021 7:34 am

Hello,

Thanks for providing your input file and your test code.
I tested your case and did reproduce your issue. I have logged it in our bug tracking system with the ticket SPIREPDF-4553. If there is any update, we will let you know. Apologize for the inconvenience caused.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Wed Aug 11, 2021 11:45 am

The input.pdf attached in the earlier comment was created from the attached text (Sampl.txt) file using spire.pdf.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Thu Aug 12, 2021 1:38 am

Hello,

Thanks for providing more details.
I have submitted this information to our developers. We will inform you as soon as there is any update.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Thu Aug 12, 2021 12:47 pm

Hi,

This is very critical for us to resolve quickly as we are doing the final User Acceptance Test with scheduled Go live dates on Monday 16th.

If you have a time frame for resolution, it will help us decide to Go live on schedule or push back.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Fri Aug 13, 2021 3:57 am

Hello,

Thanks for your response.
We are very sorry that we can’t give you an estimated time at this moment. Our Dev team will investigate further and fix it. Anyway, I have requested our Dev team to share any possible ETA at their earliest time. I will inform you as soon as there is any update.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Aug 13, 2021 4:09 am

Thanks Brian. My requirement is that text file(input file) should exactly match the tiff image (output file). (All the calculations should exactly below each line as per the input text file.
If text file can directly convert to tif image also it's perfectly fine.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Fri Aug 13, 2021 9:37 am

Hello,

Thanks for your response.
If you just need to convert the TXT file to a tif image, our another product (Spire.Doc) can also meet your needs, just like the code below. You can give it a try on your side.
Code: Select all
        static void Main(string[] args)
        {
            Document document = new Document();
            document.LoadFromFile(@"Sample.txt");

            JoinTiffImages(SaveAsImage(document), "Sample.tif", EncoderValue.CompressionLZW);
        }

        private static Image[] SaveAsImage(Document document)
        {
            //Save all the pages in the document to images.
            Image[] images = document.SaveToImages(ImageType.Bitmap);
            return images;
        }

        private static ImageCodecInfo GetEncoderInfo(string mimeType)
        {
            //Set the code information for the images.
            ImageCodecInfo[] encoders = ImageCodecInfo.GetImageEncoders();
            for (int j = 0; j < encoders.Length; j++)
            {
                if (encoders[j].MimeType == mimeType)
                    return encoders[j];
            }
            throw new Exception(mimeType + " mime type not found in ImageCodecInfo");
        }

        public static void JoinTiffImages(Image[] images, string outFile, EncoderValue compressEncoder)
        {
            //Set the encoder parameters.
            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)compressEncoder);
            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++;
            }
        }


Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Fri Aug 13, 2021 11:56 am

I have tried this also before but for that also the alignment doesn't match exactly to input file given. So then I started converting to pdf and then saving to tif.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Mon Aug 16, 2021 6:58 am

Hello,

Thanks for your feedback.
Yes, I did notice this phenomenon. Sorry for the inconvenience caused. But the good news is that regarding the issue of SPIREPDF-4553, our developers have made some progress. We will notify you as soon as there is any update.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Aug 16, 2021 1:46 pm

Thanks for the update, this is very important for our project go-live.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Thu Aug 19, 2021 3:25 am

Brian, Reminder, my Supervisor is following up on this as we postponed our Go-live. You mentioned that Spire Dev team had a breakthrough. We need to provide the client with the new release schedule which is dependent on this.

namivenus
 
Posts: 32
Joined: Tue Apr 13, 2021 2:26 am

Fri Aug 20, 2021 1:24 am

Hello,

Thanks for your follow up.
We are very sorry that we can’t give you an estimated time at this moment. But I just checked the status of the issue SPIREPDF-4553 and found it has been resolved. Our Test team is now testing the hotfix. Once it passes the test, we will prepare a fixed version for you. Thanks for your patience.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Return to Spire.PDF