PDFsharp & MigraDoc Forum https://forum.pdfsharp.net/ |
|
"Insufficient Data" in Adobe Reader https://forum.pdfsharp.net/viewtopic.php?f=2&t=1837 |
Page 1 of 1 |
Author: | dmoody007 [ Mon Nov 07, 2011 6:14 pm ] |
Post subject: | "Insufficient Data" in Adobe Reader |
I am using the GDI+ assemblies 1_31 and Migradoc to create PDF's from multiple TIFF files. I can view the PDF fine in other readers like PDF Complete and Nuance. If the PDF is opened in Adobe Reader X, they get an "Insuficient Data for an image" message and none of the pages below are visible. I read two different forum messages about this issue: 1) stated they used the GDI+ and it was fixed but I am already using that 2) stated they had to save each tiff as a seperate PDF page and them combine into a single PDF Hoping someone out there has a better suggestion. Please? Below is the code I am using. I uncompress a zip file. Pull an *.asc file and open it. That doc tells me what TIFF images belong in each grouping (single PDF file). Code: Imports MigraDoc.Rendering Imports MigraDoc.DocumentObjectModel Imports MigraDoc.RtfRendering Imports ICSharpCode.SharpZipLib.Zip Function ProcessIndexFile(ByVal myFileName As String, ByVal myFilePath As String) As Boolean Dim sFileReader As System.IO.StreamReader Dim sInputLine As String Dim sWholeLine As String Dim sDate As String Dim sControl As String Dim sRteNum As String Dim sDocNum As String Dim sImgFileName As String Dim hDocNum As String Dim hDate As String Dim hRteNum As String Dim fStart, fNewDoc As Boolean Dim myerr As String Dim myDoc As Document Dim myRend As PdfDocumentRenderer Dim mySec As Section Dim myImg As MigraDoc.DocumentObjectModel.Shapes.Image Dim myPS As MigraDoc.DocumentObjectModel.Orientation fStart = True fNewDoc = True myPS = Orientation.Landscape On Error GoTo errorhandler sFileReader = System.IO.File.OpenText(myFileName) '*****Open File sInputLine = sFileReader.ReadLine Do Until sInputLine Is Nothing '*****Loop Line by Line through file sWholeLine = sInputLine '*****Create variable to store line '****************************************************** '*****Pull field values from line based on position '****************************************************** sDate = Mid(sWholeLine, 1, 8) sDate = Replace(sDate, "/", "") sControl = Mid(sWholeLine, 18, 14) sRteNum = Mid(sWholeLine, 18, 6) sDocNum = Mid(sWholeLine, 29, 3) sImgFileName = Mid(sWholeLine, 63, 12) Debug.Print(sDate & Chr(9) & sControl & Chr(9) & sDocNum & Chr(9) & sImgFileName) If fStart = True Then '*****Sets comp for first line of file hRteNum = sRteNum hDocNum = sDocNum hDate = sDate fStart = False End If If sDocNum <> hDocNum Then '*****Document changed, write previous file and start new one MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(myDoc, "MigraDoc.mdddl") myRend = New PdfDocumentRenderer(True, PdfSharp.Pdf.PdfFontEmbedding.Always) myRend.Document = myDoc myRend.RenderDocument() myRend.PdfDocument.Save("c:\Me\processed\Me_" & hDate & "_" & hRteNum & "_" & hDocNum & ".pdf") hDocNum = sDocNum fNewDoc = True End If If fNewDoc = True Then myDoc = New Document myDoc.Info.Title = "Process Documents" myDoc.Info.Subject = sControl myDoc.Info.Author = "Me" fNewDoc = False End If mySec = myDoc.AddSection myImg = mySec.AddImage(myFilePath & "\" & sImgFileName) myImg.LockAspectRatio = True myImg.Width = New Unit(7, UnitType.Inch) 'mySec.AddPageBreak() sInputLine = sFileReader.ReadLine '*****Go to next line in file Loop sFileReader.Close() ProcessIndexFile = True Exit Function errorhandler: myerr = "This file did not parse correctly. Please contact Me with error code and copy of zip file." & Chr(13) & Chr(13) MsgBox(myerr & Err.Number & ": " & Err.Description) Debug.Print(Err.Number & " - " & Err.Description & ": " & Err.Source) ProcessIndexFile = False End Function |
Author: | Thomas Hoevel [ Tue Nov 08, 2011 9:21 am ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
dmoody007 wrote: 1) stated they used the GDI+ and it was fixed but I am already using that We call Windows routines to read TIFF files. Different Windows versions cause different problems with certain images.2) stated they had to save each tiff as a separate PDF page and them combine into a single PDF It could be an error in PDFsharp that occurs with special image formats. If that's the case then we need such an image to fix the problem. We don't know your Windows version and we don't have your TIFF files. If it runs under XP and fails under Vista or W7 (creating the PDF files, not viewing), then blame Windows. I don't recall what 1) refers to, but 2) was a problem with Windows accessing page 2 of a 3-page TIFF file. Page 1 was shown correctly. |
Author: | dmoody007 [ Tue Nov 08, 2011 1:52 pm ] | ||
Post subject: | Re: "Insufficient Data" in Adobe Reader | ||
Thomas, Thanks for the quick response. Sorry, I didn't think to provide OS type info. Running Windows 7, 64 bit on all computers. As far as the image goes, I can not email it due to legal restrictions (contains client personal information). But, I can provide this level of detail about the image. I hope this is what you are looking for. Authors: 1996-98 Accusoft Inc Program Name: ImageGear Version 10.00.... Dimensions: 1695 x 1610 Hor/Ver Res is 200 dpi Bit depth 1 compression is CCITT T.6 Res Unit is 2 Not all the PDF's created fail. PDF's with only 3-4 images are readable. If I go over that, some fail around the 4th image. I can see the first three images fine then no images after that. My bosses asked that I program the app to create an individual pdf per image and then combined into a single PDF to see if that solved the issue. I don't see how that will work, but I am doing it. Really want it to work the other way so any assistance would be greatly apreciated. Douglas PS - I just found one of the images sent was a scan of a back page that was blank. I am allowed to send that one so I am attaching.
|
Author: | Thomas Hoevel [ Tue Nov 08, 2011 3:58 pm ] | ||
Post subject: | Re: "Insufficient Data" in Adobe Reader | ||
Douglas, I cannot replicate the problem with the TIFF file you provided. I include my PDF files (tested with Acrobat 8 and Reader X, no problems). You can send files via e-mail. Maybe you can find pages that allow to replicate the problem without containing confidential data, so that you can send us the TIFFs and the PDF.
|
Author: | dmoody007 [ Tue Nov 08, 2011 4:28 pm ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
Thomas, I just finished the code modifications to the above that creates a seperate PDF per Tiff and stores in a temp directory as 1.pdf, 2.pdf, etc. It uses the exact same creation of the PDF as above with MigraDoc. I then used PDFSharp to build a single PDF from those PDF's. Amazingly enough, it works. All the PDF's that failed when I just use MigraDoc, now work perfectly in Adobe after using PDFSharp. I can only assume that PDFSharp is using a method that Windows 7 and Adobe likes better. Because this was not a fun process and we should save others some of the hassel, I modified tiff's to remove customer specific data on one of the strings that created a bad PDF (one Adobe would not open). Even though I modified the files, would still not like to post on a forum. Can I email to you? If yes, how? Thx, Douglas |
Author: | dmoody007 [ Tue Nov 08, 2011 4:56 pm ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
Thomas, Spoke too soon. The first zip which had one failure, no longer failed. When I processed the second zip that had five failures, it now has only three. So this process helps but is not a cure-all. I still need your help. Douglas |
Author: | Thomas Hoevel [ Wed Nov 09, 2011 9:43 am ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
Hi, Douglas, I can replicate the error using the WPF build - no problem using the GDI+ build. If I create a document with d5224700.003 and r5224700.004, the latter will not show. If I create a document with r5224700.004 only, everything works fine. Mysterious. To make it more mysterious, you report that you already use the GDI+ build. I hope this is just a simple problem, but it won't be easy to find. As a workaround, you can change the class PdfImage (in PdfImage.cs). Search for Code: if (isFaxEncoding && (imageDataFax.Length < imageDataCompressed.Length || imageDataFaxCompressed.Length < imageDataCompressed.Length)) and replace it with (added " * 999") Code: #if false if (isFaxEncoding && (imageDataFax.Length < imageDataCompressed.Length || imageDataFaxCompressed.Length < imageDataCompressed.Length)) #else if (isFaxEncoding && (imageDataFax.Length * 999 < imageDataCompressed.Length || imageDataFaxCompressed.Length * 999 < imageDataCompressed.Length)) #endif This will lead to bigger PDF files, but should avoid the insufficient data error. |
Author: | dmoody007 [ Wed Nov 09, 2011 3:02 pm ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
Thomas, You are the man! I modified the code as you suggested above. Compiled new DDL's. Ran 20 days of files creating over 270 PDF's. I opened every last one of them in Acrobat and no errors. I owe you a pint for this one. I'll be in London in about a week if you happen to be in the area and want to collect. Thx, Douglas |
Author: | mahii [ Tue Mar 13, 2012 9:58 am ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
hi Thomas , i used the same code for to merge the pdf file but still i am getting same error of "insufficient data for an image." plz help me............... Thx, mahiiii ------------------------------------ |
Author: | himanshu [ Thu Mar 28, 2013 11:30 am ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
Thomas Hoevel wrote: Hi, Douglas, I can replicate the error using the WPF build - no problem using the GDI+ build. If I create a document with d5224700.003 and r5224700.004, the latter will not show. If I create a document with r5224700.004 only, everything works fine. Mysterious. To make it more mysterious, you report that you already use the GDI+ build. I hope this is just a simple problem, but it won't be easy to find. As a workaround, you can change the class PdfImage (in PdfImage.cs). Search for Code: if (isFaxEncoding && (imageDataFax.Length < imageDataCompressed.Length || imageDataFaxCompressed.Length < imageDataCompressed.Length)) and replace it with (added " * 999") Code: #if false if (isFaxEncoding && (imageDataFax.Length < imageDataCompressed.Length || imageDataFaxCompressed.Length < imageDataCompressed.Length)) #else if (isFaxEncoding && (imageDataFax.Length * 999 < imageDataCompressed.Length || imageDataFaxCompressed.Length * 999 < imageDataCompressed.Length)) #endif This will lead to bigger PDF files, but should avoid the insufficient data error. Hi Thomas when you say "should avoid the insufficient data error" does that mean that PDFSharp will ignore that tiff file and move on, or it will still include that tiff file. In My case when I create pdf file through PDFSharp there are some instances where in i get "insufficient image data error" but when I process the same set of files again it creates the PDF file correct without any error. Can you explain why is it happening. Thanks.. |
Author: | Thomas Hoevel [ Thu Mar 28, 2013 12:47 pm ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
Hi! himanshu wrote: when you say "should avoid the insufficient data error" does that mean that PDFSharp will ignore that tiff file and move on, or it will still include that tiff file. The image will be included, but a different compression scheme will be used (thus bypassing the buggy compression scheme).Or try the bug fix shown here: viewtopic.php?p=5967#p5967 |
Author: | himanshu [ Thu Mar 28, 2013 1:21 pm ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
Thomas Hoevel wrote: Hi! himanshu wrote: when you say "should avoid the insufficient data error" does that mean that PDFSharp will ignore that tiff file and move on, or it will still include that tiff file. The image will be included, but a different compression scheme will be used (thus bypassing the buggy compression scheme).Or try the bug fix shown here: viewtopic.php?p=5967#p5967 Thanks Thomas, The last release that happened was on "Mar 7, 2012" and the thread started on around " Nov 07, 2011". Has the bug fix not released on Mar 7 release. Correct me if I am wrong. |
Author: | Thomas Hoevel [ Thu Mar 28, 2013 1:33 pm ] |
Post subject: | Re: "Insufficient Data" in Adobe Reader |
The bug fix is from July 6, 2012. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |