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 - Blank bitmaps from RenderDocumentToFile
  FAQ FAQ  Forum Search   Register Register  Login Login

Blank bitmaps from RenderDocumentToFile

 Post Reply Post Reply
Author
Message
Pirmin View Drop Down
Team Player
Team Player
Avatar

Joined: 28 Nov 05
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pirmin Quote  Post ReplyReply Direct Link To This Post Topic: Blank bitmaps from RenderDocumentToFile
    Posted: 04 Jan 06 at 3:12AM

Hello,

The following C# program works good for some PDF documents, but for the iSED manual it doesn't work at all.
Every resulting bitmap page I check appears to be blank. When I view such a page with a HEX-Editor, I see a header followed bei 0xff for the rest of the file. With some different PDF files I tried the program, some pages have been rendered correctly, while some pages have appeared blank also.

using System;
using System.IO;
using System.Text;
using System.Drawing;
using iSED = SEDTech.iSED;
class Test
{
    public static void Main()
    {
        iSED.QuickPDF qp = new iSED.QuickPDF();
        qp.UnlockKey( "your key" );

        string file = "iSEDQuickPDF 5.11 Reference Guide.pdf";

        Console.Write( "Loading PDF file " + file );
        int result = qp.LoadFromFile( file );
        int pages = qp.PageCount();

        if ( result == 1 )
        {
            Console.WriteLine( "Rendering " + file + " (" + pages.ToString() + " pages)" );
            qp.RenderDocumentToFile(72, 1, pages, 0, "Page_%p_of_file.bmp" );
        }

        Console.WriteLine( "Finished!" );
    }
}

Could please somebody try this program, ported to Delpi, ActiveX or something else?

Thanks in advance.

Best regards,
Pirmin



Edited by Pirmin
Back to Top
swb1 View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert
Avatar

Joined: 05 Dec 05
Location: United States
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote swb1 Quote  Post ReplyReply Direct Link To This Post Posted: 04 Jan 06 at 10:31AM

I tried the following in Delphi. I got the same results that you did , Pirmin.

procedure TForm1.Button3Click(Sender: TObject);
var qp : TiSEDQuickPDF;
begin
 if OpenDialog1.Execute then
  begin
  qp := TiSEDQuickPDF.Create;
   try
   qp.UnlockKey(MY_QDPF_KEY);
   qp.LoadFromFile(OpenDialog1.FileName );
   Screen.Cursor := crHourGlass;
   qp.RenderDocumentToFile( 72, 1, qp.PageCount, 0, 'ISedDoc.bmp' );
   finally
   Screen.Cursor := crDefault;
   qp.Free;
   end;
  end;
end;

I then changed my code to this :

 

procedure TForm1.Button3Click(Sender: TObject);

var qp : TiSEDQuickPDF;

      i : integer;

      stream : TMemoryStream;

      bmp : TBitmap;

begin

      if OpenDialog1.Execute then

            begin

            stream := TMemoryStream.Create;

            bmp := TBitmap.Create;

            qp := TiSEDQuickPDF.Create;

                  try

                  qp.UnlockKey(MY_QDPF_KEY);

                  qp.LoadFromFile(OpenDialog1.FileName );

                  Screen.Cursor := crHourGlass;

                  for i := 1 to qp.PageCount do

                        begin

                        stream.Clear;

                        qp.RenderPageToStream(72,i,0,stream );

                        stream.Position := 0 ;

                        bmp.LoadFromStream( stream );

                        bmp.SaveToFile(ExtractFilePath(OpenDialog1.FileName) + Format('ISedDoc%d.bmp',[ i ]));

                        end;

                  finally

                  Screen.Cursor := crDefault;

                  stream.Free;

                  bmp.Free;

                  qp.Free;

                  end;

            end;

end;

 

This took longer to run however the resulting bitmap files appeared to be correct.

 

I don’’t know the equivalent structures for TMemoryStream and TBitmap in C# however this is the method I have used in the past (with Delphi) and it has work reliably for me.

 

Perhaps when I find myself  with some time on my hands I will step through the RenderDocumentToFile function and see if I can tell why it is yielding null Bitmaps.

 

Steve

 



Edited by swb1
Back to Top
Pirmin View Drop Down
Team Player
Team Player
Avatar

Joined: 28 Nov 05
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Pirmin Quote  Post ReplyReply Direct Link To This Post Posted: 04 Jan 06 at 10:34PM

Hi Steve

Thank you! When I was reading the code in your post, it looked a kind of familiar to me.
The equivalent function RenderPageToString gives good results!
In my topic Convert string from RenderPageToString I have described how I used this function and what workarounds are necessary to make it work properly.
When I saw, that RenderPageToString needed about 6 times more time then RenderDocumentToFile (as you noted also), I thought it would be better, using RenderDocumentToFile. After having to solve other problems and because sometimes I have to pause my work for a long time, I forgot about the rendering problems I have found myself.
Now my conclusion is, to be slow is better than to be faulty. So I will definitely use the function RenderPageToString instead of RenderDocumentToFile.

Best regards,
Pirmin



Edited by Pirmin
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. About β€” Contact β€” Blog β€” Support β€” Online Store