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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - this  tif can't be converto pdf
  FAQ FAQ  Forum Search   Register Register  Login Login

this tif can't be converto pdf

 Post Reply Post Reply
Author
Message
mjohn View Drop Down
Beginner
Beginner


Joined: 28 Oct 11
Location: ??
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote mjohn Quote  Post ReplyReply Direct Link To This Post Topic: this tif can't be converto pdf
    Posted: 20 Mar 12 at 5:36PM

Below tif file can't be convert to pdf.

Thanks!


Edited by mjohn - 21 Mar 12 at 8:45PM
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 20 Mar 12 at 9:38PM
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
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 10:02AM
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


Back to Top
mjohn View Drop Down
Beginner
Beginner


Joined: 28 Oct 11
Location: ??
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote mjohn Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 1:55PM
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!

Back to Top
mjohn View Drop Down
Beginner
Beginner


Joined: 28 Oct 11
Location: ??
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote mjohn Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 2:02PM
This file is downloaded from USPTO-United States Patent and Trademark Office

And there has many broken files as this tif file.


Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 3:59PM
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

Back to Top
mjohn View Drop Down
Beginner
Beginner


Joined: 28 Oct 11
Location: ??
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote mjohn Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 4:36PM
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!
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 5:16PM
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

Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3524
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 8:08PM
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
Back to Top
mjohn View Drop Down
Beginner
Beginner


Joined: 28 Oct 11
Location: ??
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote mjohn Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 8:15PM
Hi. edvoigt and Ingo.
Thank you all very much!
Back to Top
edvoigt View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 Mar 11
Location: Berlin, Germany
Status: Offline
Points: 111
Post Options Post Options   Thanks (0) Thanks(0)   Quote edvoigt Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 8:28PM
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
Back to Top
mjohn View Drop Down
Beginner
Beginner


Joined: 28 Oct 11
Location: ??
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote mjohn Quote  Post ReplyReply Direct Link To This Post Posted: 21 Mar 12 at 8:42PM
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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post Posted: 22 Mar 12 at 10:02AM
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.
Back to Top
mjohn View Drop Down
Beginner
Beginner


Joined: 28 Oct 11
Location: ??
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote mjohn Quote  Post ReplyReply Direct Link To This Post Posted: 22 Mar 12 at 2:39PM
Hi, AndrewC!
Thank you very much!
Back to Top
mjohn View Drop Down
Beginner
Beginner


Joined: 28 Oct 11
Location: ??
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote mjohn Quote  Post ReplyReply Direct Link To This Post Posted: 29 Mar 12 at 5:58AM
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!


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store