I want to know how to instatiate a viewer object in a Delphi console application.
I got to do it with Imaging object.
So, why do i want to use viewer in a console application? I need to make some manipulations/convertions in the source image.
This console application will do it in a batch process and return a value to my main window application written in another language.
Below a piece of code:
- Code: Select all
program GeraCertPDF;
{$APPTYPE CONSOLE}
uses
SysUtils, Dialogs, ActiveX,
GdPicturePro5_TLB in 'GdPicturePro5_TLB.pas';
var
GdVw : TGdViewer;
GdImg : CocImaging;
GdIm : cImaging;
begin
{ TODO -oUser -cConsole Main : Insert code here }
if System.ParamCount = 1 then
if ParamStr(1) <> '' then
begin
Try
CoInitialize(nil);
GdIm := GdImg.Create;
GdIm.PdfNewPdf('a.pdf', '', '', '', '');
GdVw.Create(nil);
GdVw.DisplayFromPdfFile(ParamStr(1), '');
CoUnInitialize;
except
on E: Exception do Writeln(E.Classname, ': ', E.Message);
end;
end;
end.
It throws me an error:
EAccessViolation: Access violation at address 00459455 in module 'GeraCertPDF.ex
e'. Read of address 01C92D3B
I think the error above is when I try to create the viewer object.
Thanks,
Marcio.
