Hi,
Where can I found a piece of Delphi code about the use of PXCV_ReadDocumentFromIStream?
Best regards.
Delphi example about ReadDocumentFromIStream
Moderators: PDF-XChange Support, Daniel - PDF-XChange, Chris - PDF-XChange, Sean - PDF-XChange, Vasyl - PDF-XChange, Ivan - Tracker Software, Stefan - PDF-XChange
-
- User
- Posts: 6
- Joined: Mon Apr 28, 2008 5:09 pm
-
- Site Admin
- Posts: 19913
- Joined: Mon Jan 12, 2009 8:07 am
Re: Delphi example about ReadDocumentFromIStream
Hello Stemon,
If you have installed the Viewer SDK in the default folder you should find the example in e.g.
C:\Program Files\Tracker Software\PDF-XChange Viewer SDK\Examples\DelphiExamples\OpenDocumentFromStream
Best,
Stefan
If you have installed the Viewer SDK in the default folder you should find the example in e.g.
C:\Program Files\Tracker Software\PDF-XChange Viewer SDK\Examples\DelphiExamples\OpenDocumentFromStream
Best,
Stefan
-
- User
- Posts: 6
- Joined: Mon Apr 28, 2008 5:09 pm
Re: Delphi example about ReadDocumentFromIStream
Yes, but in the example doesn't uses PXCV_ReadDocumentFromIStream function exported from pxcview.dll...Tracker Supp-Stefan wrote:If you have installed the Viewer SDK in the default folder you should find the example in e.g.
C:\Program Files\Tracker Software\PDF-XChange Viewer SDK\Examples\DelphiExamples\OpenDocumentFromStream
-
- Site Admin
- Posts: 19913
- Joined: Mon Jan 12, 2009 8:07 am
Re: Delphi example about ReadDocumentFromIStream
Hello Stemon63,
Apologies - the samples I pointed you to are for the Viewer AX, and you are asking for the Simple DLL SDK one.
I am sorry, we do not have such a sample, but it is a straight forward function, and the parameters it requires are also pretty obvious, so please ensure that you have created a PDF file to pass as the PXVDocument paramter via PCV_Init, and that you have a correct IStream to pass as the second parameter. Flags are optional.
Best,
Stefan
Apologies - the samples I pointed you to are for the Viewer AX, and you are asking for the Simple DLL SDK one.
I am sorry, we do not have such a sample, but it is a straight forward function, and the parameters it requires are also pretty obvious, so please ensure that you have created a PDF file to pass as the PXVDocument paramter via PCV_Init, and that you have a correct IStream to pass as the second parameter. Flags are optional.
Best,
Stefan
-
- User
- Posts: 6
- Joined: Mon Apr 28, 2008 5:09 pm
Re: Delphi example about ReadDocumentFromIStream
It's ok.Tracker Supp-Stefan wrote:I am sorry, we do not have such a sample, but it is a straight forward function, and the parameters it requires are also pretty obvious, so please ensure that you have created a PDF file to pass as the PXVDocument paramter via PCV_Init, and that you have a correct IStream to pass as the second parameter. Flags are optional.
I modified PDFXView.LoadFile() method in this way:
var
PDFResult: HResult;
TmpFileStream: TFileStream;
TmpIStream: IStream;
tPos: int64;
[...]
//PDFResult := PXCV_ReadDocumentW(pDocument, PWChar(WideString(PDFFilename)), 0);
// -- Start read from stream
TmpFileStream := TFileStream.Create(PDFFilename,fmOpenReadWrite or fmShareDenyNone);
TmpIStream := TStreamAdapter.Create(TmpFileStream, soOwned);
TmpIStream.Seek(0, 0, tPos);
// -- End read from stream
PDFResult := PXCV_ReadDocumentFromIStream(pDocument, TmpIStream, 0)
[...]
but it doesn't works and in PDFResult I have a negative value.

P.S.
Since the PXView_36.pas file was missing the function PXCV_ReadDocumentFromIStream, I added in its statement:
function PXCV_ReadDocumentFromIStream(pDoc :PXVDocument; Stream: IStream; Flags: DWORD):HRESULT;stdcall;external 'pxcview.dll';
-
- User
- Posts: 664
- Joined: Tue Nov 14, 2006 12:23 pm
Re: Delphi example about ReadDocumentFromIStream
Hello Stemon63,
Problem with TStreamAdapter is that TStreamAdapter doesn't provide a correct implementation of IStream.Clone method. As example you may use create IStream by using CreateStreamOnHGlobal function.
Here is example code:
HTH.
Problem with TStreamAdapter is that TStreamAdapter doesn't provide a correct implementation of IStream.Clone method. As example you may use create IStream by using CreateStreamOnHGlobal function.
Here is example code:
Code: Select all
var
fs: TFileStream;
IStr:iStream;
dwWritten : DWORD;
dw : DWORD;
dt : pointer;
Res: HResult;
....
Res := PXCV_Init(@m_pDocument,...);
....
try
fs := TFileStream.Create(PDFFilename, fmOpenRead);
dw := fs.Size;
GetMem(dt, dw);
fs.Read(dt^, fs.Size);
CreateStreamOnHGlobal(0, False, IStr);
if IStr <> nil then
begin
IStr.Write(@dw, sizeof(DWORD), @dwWritten);
IStr.Write(dt, dw, @dwWritten);
Res := PXCV_ReadDocumentFromIStream(m_pDocument, IStr, 0);
end;
finally
fs.Free();
FreeMem(dt, dw);
end;
-
- User
- Posts: 6
- Joined: Mon Apr 28, 2008 5:09 pm
Re: Delphi example about ReadDocumentFromIStream
Works!Corwin - Tracker Sup wrote:Hello Stemon63,
[...]
As example you may use create IStream by using CreateStreamOnHGlobal function.
[...]
thanks!

-
- Site Admin
- Posts: 19913
- Joined: Mon Jan 12, 2009 8:07 am
Re: Delphi example about ReadDocumentFromIStream
Glad to hear that Stemon!
(And kudos to Corwin
)
Regards,
Stefan
(And kudos to Corwin

Regards,
Stefan