Hi
TImageEnIO.Seek cannot be used with special files, like those decoded from text. It needs to be passed an image filename or a stream, e.g.
var
fn: string;
io : TImageEnIO;
idx : Integer;
begin
fn := 'D:\Testing_Multimedia\TIFF\TIFF_4pages_mono_3352x4743.tiff';
io := TImageEnIO.Create(nil);
try
idx := 0;
io.LoadFromFile( fn );
Repeat
io.SaveToFileJpeg('D:\TiffOut_' + idx.ToString + '.jpg');
inc( idx );
until io.Seek( ieioSeekNext, fn ) <> idx;
finally
io.Free;
end;
end;
So you would need to load the text content and base64 decode it to a stream in order to use it with Seek.
If you don't have special reason to do that, you are better to just use the TImageEnView.PDFViewer to handle the loading, e.g.
var
iev : TImageEnView;
idx : Integer;
begin
// Check PDF library available
PDFiumLibAvailable( True );
iev := TImageEnView.Create(nil);
try
iev.PdfViewer.Enabled := True;
iev.IO.LoadFromText('D:\source.txt', ietfBase64);
{Save the first page}
iev.IO.Seek(ieioSeekFirst);
iev.IO.SaveToFileJpeg('D:\PageOut1.jpg');
idx := 0;
{Loop over the remaining pages and save them}
while iev.IO.Seek( ieioSeekNext ) <> idx do
begin
iev.IO.SaveToFileJpeg('D:\PageOut' + idx.ToString + '.jpg');
inc(idx);
end;
finally
iev.Free;
end;
end;
In this case Seek works, because the PDFViewer loads the entire PDF and seek just redirects to the PDFViewers "Next Page" function.
BTW, I would prefer to use Repeat/Until in this situation to make the code a little more concise:
var
iev : TImageEnView;
idx : Integer;
begin
// Check PDF library available
PDFiumLibAvailable( True );
iev := TImageEnView.Create(nil);
try
iev.PdfViewer.Enabled := True;
iev.IO.LoadFromText('D:\source.txt', ietfBase64);
idx := 0;
Repeat
iev.IO.SaveToFileJpeg('D:\PageOut_' + idx.ToString + '.jpg');
inc( idx );
until iev.IO.Seek( ieioSeekNext ) <> idx;
finally
iev.Free;
end;
end;
Nigel
Xequte Software
www.imageen.com