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!
Rendering large pdf |
Post Reply |
Author | |
ADev
Beginner Joined: 10 Feb 12 Status: Offline Points: 8 |
Post Options
Thanks(0)
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 |
|
ADev
Beginner Joined: 10 Feb 12 Status: Offline Points: 8 |
Post Options
Thanks(0)
|
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 |
|
edvoigt
Senior Member Joined: 26 Mar 11 Location: Berlin, Germany Status: Offline Points: 111 |
Post Options
Thanks(0)
|
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 |
|
ADev
Beginner Joined: 10 Feb 12 Status: Offline Points: 8 |
Post Options
Thanks(0)
|
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 |
|
AndrewC
Moderator Group Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
|
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. |
|
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