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 - Rendering large pdf
  FAQ FAQ  Forum Search   Register Register  Login Login

Rendering large pdf

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


Joined: 10 Feb 12
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ADev Quote  Post ReplyReply Direct Link To This Post Topic: Rendering large pdf
    Posted: 08 Mar 12 at 3:17PM
Welcome,
I'm trying to render large pdf to bmp, 72 (or 36) dpi by RenderPageToFile, DARenderPageToFile or other render method (also stream).
Functions always return 1 (all ok), but result bmp file has only white pixels (bmp page is white). Size (pixels) of bmp is correct, filesize is also ok. Other test: CapturePage and DrawCapturedPage works ok.
I prepared sample pdf file (from tif to pdf conversion -
test2 2MB ).
Sometimes there are large area documents (scanned engineering documentation, for example 900x2000mm 300 dpi).

Any idea how to convert this large pdf to bmp file by QPL library?

I'm trying QPL Delphi dcu v8.13, Windows7x32, 4GB RAM.

Adam

Edit1:
Test with QPL 8.14b3
after DARenderPageToFile, DARenderPageToStream
Delphi5 say error: "Out of memory while expanding memory Stream"

Edit2
Delphi2006 say: in clas EOutOfMemory: "Out of memory"
Why? Other viewers and libraries can rasterize this file, slow, but rasterize.
Im know, this is only user-user forum, and library has only 3MB.
QPL is look good, composition (DrawCapturedPage) is very, very fast.
Only rendering.. Rendering for smaller area pdf (e.g, A1 format) is good, but greater has some problems.

Regards


Edited by ADev - 08 Mar 12 at 11:28PM
Back to Top
ADev View Drop Down
Beginner
Beginner


Joined: 10 Feb 12
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ADev Quote  Post ReplyReply Direct Link To This Post Posted: 09 Mar 12 at 7:13PM
Sorry for post under post,
but there is hope, my workaround idea,
After some experiments on this (and another) sample, I got one of the idea:
QPL has functions for separate bitmap from pdf file (in my example this image is only one graphical object in pdf file)
My idea is functions GetPageImageList, SaveImageListItemDataToFile use, works ok).
This function extract image (jpg) from this pdf file, but this jpg also big image for pixel analyse.
I have to deal with large format scan and print (A0+ 300dpi)

Does anyone have experience with the analyse of large jpg files in Delphi (scan jpg format and analyze pixels?)

Only what I want, its detect "inked area" (for crop white margins on pdf file).

Im sorry for my poor english,

Regards,
Adam

Edited by ADev - 09 Mar 12 at 7:34PM
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: 11 Mar 12 at 3:02PM
Hi,

I think you need for analyzing a bitmap. In Delphi it is easy to convert a JPG to BMP:

var
  jpg: TJPEGimage;
  bmp: TBitmap;
begin
  jpg := TJPEGimage.Create;
  jpg.LoadFromFile('E:\Projekt7\PDF_Investigator\test2.jpg');
  bmp := TBitmap.Create;
  bmp.Assign(jpg);
  jpg.Free;

The Assign does the job, but it takes in your case on my PC 20 sec.

For analize you have to walk over the scanlines:

type
  TRGBTriple = packed record             // short the names
    b: byte; g: byte; r: byte;
  end;
  TRGBArray = array[0..0] OF TRGBTriple; // for easier access
var
  i, j,
  Row: ^TRGBArray;
begin
  for j:=0 to BMP.Height-1
  do begin  // from top to bottom of BMP
    Row := bmp.Scanline[j];
    for i:=0 to BMP.Width-1 // every pixel in line is a TRGBTriple
    do begin
      if (Row[ i].r<255) or (Row[ i].g<255) or (Row[ i].b<255)
      then begin // Pixel[ i,j] is not white
// here you are outside of white borders
      end;
    end;
  end;


The code snippets are working but free of errorhandling!

On big images you'll get memory-problems. One idea against is to try to handle only part of the images. But I see no way to get for example only a top bar of a image, which is a little more than the assumed top border. All I tested in this background was running out of memory on other places. The jpg is as such in the PDF, so QPL makes no conversion.


Only two small steps, but in the right direction?

Werner


Edited by edvoigt - 13 Mar 12 at 6:00PM
Back to Top
ADev View Drop Down
Beginner
Beginner


Joined: 10 Feb 12
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ADev Quote  Post ReplyReply Direct Link To This Post Posted: 12 Mar 12 at 8:14AM
Thanks Werner,
yes, the right direction :)

After further experiments, I came to satisfactory results:
pseudocode:

if RenderPageToFile=False then
if (pdf_page has only one img) and (img.size=pdf_page.size [points]) then
begin
    extract img (SaveImageListItemDataToFile)
    LoadBigImg to TBitmap with resize to 72 dpi (without resizing is memory problem)
    Analyze TBitmap
end

To load jpg with resize I'm found function:

function ResizeImage(sInImage, sOutImage: string; iHeight, iWidth: integer): boolean;
var JpgImg : TJpegImage;
   BmpImg : TBitmap;
   Rectangle: TRect;
begin
   try
    JpgImg := TJpegImage.Create;
    BmpImg := TBitmap.Create;
   
    JpgImg.LoadFromFile(sInImage);
    Rectangle := Rect(0, 0, iWidth, iHeight);
    with BmpImg do
    begin
    Width := iWidth;
    Height := iHeight;
    Canvas.StretchDraw(Rectangle, JpgImg);
    >> Analyze TBitmap here or BmpImg.SaveToFile <<
    end;
    finally
    
//    JpgImg.Assign(BmpImg);
//    JpgImg.SaveToFile(sOutImage);
    JpgImg.Free;
    BmpImg.Free;
    end;
   Result := True;
   end;

Yes, I used scanline method to analyze TBitmap.
If extracted image is jpeg image, for scanline important is also TBitmap.PixelFormat:=pf24bit; (oryginally assigned jpg has 32bit and white color has (255,0,255) r,g,b values )

I think that the problem is already solved, a little round,
partially pdf page rendering/rasterizing would be better.
Thank you for your interest, Werner

Regards,
Adam

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: 12 Mar 12 at 12:43PM
10600 x 23600 pixels is a very large PDF file and QPL initially tries to render this at 24 bpp which requires 868MB.  A 32bit EXE cannot safely handle this amount of memory.

The 64bit version of Quick PDF Library would be much better suited to this type of processing.

Andrew.




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