Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
this tif can't be converto pdf |
Post Reply |
Author | |
mjohn
Beginner Joined: 28 Oct 11 Location: ?? Status: Offline Points: 16 |
Post Options
Thanks(0)
Posted: 20 Mar 12 at 5:36PM |
Thanks!
Edited by mjohn - 21 Mar 12 at 8:45PM |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
Where's your sample code? I can convert it but when i want to open it with adobe i've get a message "not enough data for a picture". Don't know what this could mean ;-) Cheers, Ingo Edited by Ingo - 20 Mar 12 at 9:42PM |
|
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
|
Hi,
your file looks broken. Different programs show not the same. Picasapreview shows a white paper. MS-Photoeditor shows Text and last line on half and a black area. Irfanview shows text like MS-Photoeditor, but the last line only half. Your can't hope that wrong input gives correct output. The source of your file is the problem. Cheers, Werner |
|
mjohn
Beginner Joined: 28 Oct 11 Location: ?? Status: Offline Points: 16 |
Post Options
Thanks(0)
|
I get the message "not enough data for a picture" too.
But I use Microsoft office document Imaging Can see the most content of this tif file. And the Microsoft office Picutre Manager Can see the most content of this tif file too. When drag the tif file to Microsoft word, word Can see the most content of this tif file too. But Quick PDF Library can't see any content of this tif file. If Quick PDF Library can see the good part the tif file, then it will be perfect. Thanks! |
|
mjohn
Beginner Joined: 28 Oct 11 Location: ?? Status: Offline Points: 16 |
Post Options
Thanks(0)
|
This file is downloaded from USPTO-United States Patent and Trademark Office
And there has many broken files as this tif file. |
|
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
|
Hi,
if you know that the file is corrupted, you should try a repair. So you may save, what is to save. In case of your example, I open it with Irfanview and did a save to another location. Because the program rebuilds the structure of file, it is repaired (with loss of destroyed part of course). After this QPL made a PDF, which is fully correct. That's the proof, that QPL works with correct builded input. Cheers again, Werner |
|
mjohn
Beginner Joined: 28 Oct 11 Location: ?? Status: Offline Points: 16 |
Post Options
Thanks(0)
|
But before open the merged pdf file that quick pdf converted,
I didn't know whick tif file is
corrupted. I have many many tif files need to be merged to many pdf files. I can't view all the tif files one by one before I merge them to pdf files. Only after I open the merged pdf file, I get the message "not enough data for a picture", then I know there is a corrupted tif file in the merged pdf file. I hope QPL can give a tip when it detect a tif file is corrupted before merged to a pdf file or throw a error. And I hope QPL can give a method to rebuilds the structure of the corrupted tif file too. Thanks!
|
|
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
|
Hi,
QPL takes the image-file and embeds it only in PDF-code. As I think, there is no kind of looking for errors inside, because the main part of the image is only copied as is. So you get there no errormessage. But if you try to render this PDF - QPL does it! In this point it looks harder than adobe reader! So I see no way of automated test of integrity. QPL is no imageprocessor and hopes that the images are build correct. But in Irfanview there is an easy to use batch-facillity. There you may configure a job like take all tiffs from one place and store them to another place. So you could use the clearing files (needed or not) without taking one by one every file in your fingers. If a file is ok, this process does not disturb, but after this you should have no more corrupted files. Try it! Cheers, Werner |
|
Ingo
Moderator Group Joined: 29 Oct 05 Status: Offline Points: 3524 |
Post Options
Thanks(0)
|
Hi!
You can render the pdf-pages to a stream and convert it to bmp for example. Then you can check the pixel rows and columns (scanline!). If there are only white pixels you know that there's a corrupt page. To make this routine not too slow you should scale the bmp down ;-) This could be a starting point for you: pix := 64; // for example... QP.RenderPageToStream(72,page,0,test_stream); // render to bmp test_stream.Seek(0,0); bmp := TBitmap.Create; bmp2 := TBitmap.Create; bmp2.Width := Round(pix); bmp2.Height:= Round(pix); bmp.LoadFromStream(test_stream); bmp2.Canvas.StretchDraw(Rect(0, 0, pix, pix), bmp); for x := 0 to bmp2.Height - 1 do begin for y := 0 to bmp2.Width - 1 do begin geco := bmp2.Canvas.Pixels[x,y]; rgb := ColorToRGB(geco); c1 := GetRValue(rgb); c2 := GetGValue(rgb); c3 := GetBValue(rgb); // and so on ... Cheers, Ingo |
|
mjohn
Beginner Joined: 28 Oct 11 Location: ?? Status: Offline Points: 16 |
Post Options
Thanks(0)
|
Hi. edvoigt and Ingo.
Thank you all very much! |
|
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
|
Hi,
Ingo's idea is nice, but no save way. By the way Canvas.pixels is much too slow, if then use scanlines. Your example-tif (0000004.tif) does not end in white pixels. The picture here is comming from QPL: On a corrupted file nobody is able to say, how it will look. It looks different from program to program. Werner Edited by edvoigt - 21 Mar 12 at 8:31PM |
|
mjohn
Beginner Joined: 28 Oct 11 Location: ?? Status: Offline Points: 16 |
Post Options
Thanks(0)
|
Hi.
Now I found use itextsharp can convert this tif to pdf. But Quick PDF Library can't. So I thinks it not too good. Here is the code i changed from the web use itextsharp. /////////////////////////////////// using System; using System.Drawing; using System.IO; using System.Windows.Forms; using iTextSharp.text; using iTextSharp.text.pdf; using System.Drawing.Imaging; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Document document = new Document(PageSize.A4, 50, 50, 50, 50); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(@"D:\Image.pdf", FileMode.Create)); System.Drawing.Bitmap bm = new System.Drawing.Bitmap(@"D:\000004.tif"); int total = bm.GetFrameCount(FrameDimension.Page); document.Open(); PdfContentByte cb = writer.DirectContent; for (int k = 0; k < total; ++k) { bm.SelectActiveFrame(FrameDimension.Page, k); MemoryStream ms = new MemoryStream(); bm.Save(ms, ImageFormat.Tiff); iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(ms.ToArray()); img.ScalePercent(72f / (float)img.DpiX * 100); img.SetAbsolutePosition(0, 0); cb.AddImage(img); document.NewPage(); } document.Close(); } } } //////////////////////////////////////////////// The full project source is here: So you can see, Quick PDF Library can't do well as iTextSharp. Thanks! Edited by mjohn - 21 Mar 12 at 8:46PM |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
Your iTextSharp example is cheating and has nothing to do with iTextSharp being able to handle the image properly. You code is using GDI+ to load the image into memory and then using the repaired image into iTextSharp. If you used the same code to convert the TIFF image (
bm.Save(ms, ImageFormat.Tiff); before loading into QPL then QPL would load the file correctly also.
Or you could just add call QP.AddImageFromFile("000004.pdf", -page); which uses GDI+ to load the page. Note the negative page number. You will need to use the latest 8.14 beta 6 to process multipage tiffs with -page. http://www.quickpdflibrary.com/blog/2012/03/quick-pdf-library-8-14-beta-6-released/ Andrew.
|
|
mjohn
Beginner Joined: 28 Oct 11 Location: ?? Status: Offline Points: 16 |
Post Options
Thanks(0)
|
Hi, AndrewC! Thank you very much!
|
|
mjohn
Beginner Joined: 28 Oct 11 Location: ?? Status: Offline Points: 16 |
Post Options
Thanks(0)
|
Hi.
AndrewC!
file 000004.tif is 94k when use QP.AddImageFromFile("000004.tif", 0) The pdf file become 97K But when use QP.AddImageFromFile("000004.tif", -page) The pdf file become 297K. So when use gid+, is too large. So 1. How to reduce the pdf file size when I use gdi+ to load the tif file? 2. How to let QP to use tif format first when failed then use gdi+ to load the tif file? Thanks! |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store