Cannot open attachments embeded using GDPicture

Discussions about PDF management.
Post Reply
Halla602
Posts: 8
Joined: Wed Jan 02, 2013 4:59 pm

Cannot open attachments embeded using GDPicture

Post by Halla602 » Thu Oct 31, 2013 1:14 pm

Hi, I recently encountered this weird problem.
When I embed random files into pdf, sometimes I cannot open the first file when displaying the .pdf using Adobe Acrobat.

What's weird, when I change the names of attachments (since acrobat shows the attachment list alphabetically ordered), the same file that couldn't be opened has no problems at all. Files I use stay the same, just names change.

So, in this example when I name the files named thusly, I get no errors:

Code: Select all

Plain text only.eml
test.rtf
zchilipepper.jpg
But when I name them this way, the image file cannot be opened:

Code: Select all

chilipepper.jpg
Plain text only.eml
test.rtf

My code for embeding files into pdf

Code: Select all

              Output_PDF.LoadFromStream(new MemoryStream(Input_PDF_Data));
              string[] Files = Directory.GetFiles(Temp_Attachements_Dir);
              for (int i = 0; i < Files.Length; i++)
              {
                Output_PDF.EmbedFile(Files[i], Path.GetFileName(Files[i]), "");
                File.Delete(Files[i]);
              }
              Stream stm = (Stream)new MemoryStream();
              Output_PDF.SaveToStream(stm);
              Output_PDF_Data = ((MemoryStream)stm).ToArray();

Thank you for your response,

Martin Halla,
Software602
Attachments
Source_Files.zip
(40.14 KiB) Downloaded 346 times
Attachment_cant_open.zip
(85.95 KiB) Downloaded 319 times

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

Re: Cannot open attachments embeded using GDPicture

Post by delbeke » Sun Nov 03, 2013 12:54 pm

Hi,

The problem has been reproduced.
Inside the PDF the names should have been sorted but were not. The problem has been fixed and will be available in the next minor release, until then, a work around consists of adding the files in Alhabetical order. something like:

Code: Select all

string[] Files = Directory.GetFiles(Temp_Attachements_Dir);
Array.Sort(Files , StringComparer.Ordinal); 
for (int i = 0; i < Files.Length; i++)
Hope this help,
Jean-Luc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest