Is the PDF attachment code buggy?

Discussions about PDF management.
Post Reply
mattewan
Posts: 33
Joined: Fri Apr 03, 2009 5:58 pm

Is the PDF attachment code buggy?

Post by mattewan » Mon Mar 12, 2018 5:54 pm

Hello,

I'm using the following code to generate a PDF with text & embed files:

Code: Select all

        private void WriteEmail(sEmail email, string filename) {

            GdPicture14.GdPicturePDF oPDF = new GdPicture14.GdPicturePDF();
            oPDF.CreateFromText(GdPicture14.PdfConformance.PDF1_4, 595, 842, 30, 30, 30, 30, GdPicture14.TextAlignment.TextAlignmentNear, email.emailContent, 12, "Calibri", false, false, false, false);

            string orgFilename;
            string newFilename;
            for (int i = 0; i < email.Attachments.Count; i++)
            {
                if (oPDF.EmbedFile(email.Attachments[i].newFilename, "") != GdPicture14.GdPictureStatus.OK)
                {
                    Console.WriteLine("ERROR INSERTING ATTACHMENT");
                }
            }
            oPDF.SaveToFile(filename);
        }
        
The above code works and I get a PDF, A4 in size with a dynamic amount of pages, depending on how much content there is to insert. However, I am having an issue where certain PDF's, which may have 4 attachments for example, will let me open 3 of them and one of them wont open. If I open this pdf in Acrobat Pro, I can delete the 3 attachments that are viewable, but I can't delete the file that it wont let you open or view. It's like acrobat can't locate the file in the PDF.

I have seen this happen to jpegs, gif files, html documents, etc.

What could be causing this? I can't share the files that are causing the issue because of data protection. I can confirm that if I add the same attachments using acrobat pro, it is able to view and delete them.

Am I creating the pdf incorrectly? Either that, or maybe there is a bug in the pdpicture attachment code? This is happening to about 1 in 50 PDF's I'm creating.

I have tried a few versions of GDPicture 14, including the latest as of today.

Cheers,

Matt

delbeke
Posts: 89
Joined: Wed Oct 31, 2012 5:07 pm

Re: Is the PDF attachment code buggy?

Post by delbeke » Mon Mar 12, 2018 6:10 pm

Hi mattewan.

Can you transmit the filenames of the attachments when the problem occurs.
Perhaps you can try

if (oPDF.EmbedFile(email.Attachments.newFilename + i.ToString(), "")

Hope this help
Best regards.
Jean-Luc

mattewan
Posts: 33
Joined: Fri Apr 03, 2009 5:58 pm

Re: Is the PDF attachment code buggy?

Post by mattewan » Tue Mar 13, 2018 10:49 am

Thanks for replying.

I have an email with the following two attachments:

TEXT.htm
image001.jpg

In this example, TEXT.htm won't open (nothing happens when i click the attachment in acrobat, and it wont let me delete it either). If I insert just image001.jpg or TEXT.htm on their own, both work, but don't work when stored together.

I have tried adding a counter to the end of the filename to see if that helps, same issue:

TEXT.htm 1
image001.jpg 2

The jpeg will load, TEXT.htm wont.

Kind regards,

Matt

delbeke
Posts: 89
Joined: Wed Oct 31, 2012 5:07 pm

Re: Is the PDF attachment code buggy?

Post by delbeke » Tue Mar 13, 2018 12:34 pm

Hi mattewan

Without the final PDF, it will be difficult to find what is the problem.
Can you make a test storing them according the alphabetical order, please.
image001.jpg first and then Text.htm

Best regards.
Jean-Luc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest