ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder
ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 ImageEn and PDF-Viewer ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Stalker4

Ukraine
3 Posts

Posted - May 07 2020 :  09:50:50  Show Profile  Reply
Hi All,

ImageEn has various methods for working with PDFs (creating, saving, etc.).
Question: Is it possible in ImageEn to view PDF files ?

xequte

5327 Posts

Posted - May 07 2020 :  17:49:13  Show Profile  Reply
At this stage, ImageEn cannot natively load PDF files. To load PDF files you need either:

- An add-on, such as WPViewPDF (59. You ship a DLL with your application:

https://www.imageen.com/wpviewpdf/

- ImageMagick + GhostScript (Free, but needs to be installed on client machines):

https://www.imageen.com/ieforum/topic.asp?TOPIC_ID=1464



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

BillM

USA
8 Posts

Posted - Jun 26 2020 :  03:30:39  Show Profile  Reply
Another possibility exists if you have the Developers Express PDFViewer component. The library has an API that converts a PDF to TIFF or PNG. Here is a working sample:


Uses
  dxGDIPlusClasses, dxPDFDocument;
  
procedure TfrmMain.DisplayPDF(const Filename: string);
var
  i: integer;                    // page counter
  ndx: integer;                  // new image location in viewer
  ADocument: TdxPDFDocument;     // the loaded PDF document
  ImgContainer: TdxSmartImage;   // Temporary storage for converted pages
  ImgStream: TMemoryStream;      // Interface between temporary storage and image viewer
begin
  if AnsiCompareText(ExtractFileExt(FileName), '.PDF') = 0 then
  begin
    Screen.Cursor := crHourGlass;
    ADocument := TdxPDFDocument.Create;
    ImgContainer := TdxSmartImage.Create;
    ImgStream := TMemoryStream.Create;

    try
      ADocument.LoadFromFile(FileName);

      // Convert the PDF placing all the pages in the SmartImage Container
      // A scale of 4.5 renders good resolution - a higher scale requires more memory and performance suffers
      if dxPDFDocumentExportToTIFF(ADocument, 4.5, ImgContainer, nil, ra0) then
      begin
        // Save the converted image to a stream as a TIFF file
        ImgContainer.SaveToStreamByCodec(ImgStream, dxImageTIFF);

        // Step through each page adding it to the image viewer
        for i := 0 to ADocument.PageCount - 1 do
        begin
          // Reposition the stream to 0 since the SetImageFromStream method locates the page based on the SourceImageIndex value
          ImgStream.Position := 0;

          // Prepare viewer for a new image
          ndx := imgMView.AppendImage;

          // Load the page into the viewer at index ndx from the streams image at index i
          imgMView.SetImageFromStream(ndx, ImgStream, i, ioTIFF);
        end;
      end;
    finally
      ImgStream.Free;
      ImgContainer.Free;
      ADocument.Free;
      Screen.Cursor := crDefault;
    end;
  end;
end;



I don't have either of the two plugins that Nigel supports so I can't compare the performance between the methods.
Go to Top of Page

Vezion

2 Posts

Posted - Jun 26 2020 :  06:47:41  Show Profile  Reply
I've been using WPViewPDF as an add-on and it works really well in my case. I will try to explore more possible options when I am going to have a weekend in my family property in Sicily, I will tell you more later
Go to Top of Page

Stalker4

Ukraine
3 Posts

Posted - Jun 26 2020 :  08:24:26  Show Profile  Reply
Thanks to everyone for the answers, but that is not what i need. The fact that there are other libraries that can watch PDF I know.
I just thought that if ImageEn can save to PDF, can create PDF, it would be logical to be able to view PDF. Hence my initial question.
Go to Top of Page

klausdoege

Germany
309 Posts

Posted - Jun 27 2020 :  13:37:24  Show Profile  Reply
I also use WPViewPDF, without a plugin images cannot display a PDF. That was also my problem, that's why the plugin. And it does what it should.

Klaus
www.klausdoege.de
Go to Top of Page

spetric

Croatia
288 Posts

Posted - Jun 27 2020 :  16:12:44  Show Profile  Reply
Hi,

Writing/creating PDF is not so difficult task. I've worked with iText in Java and it's actually adding strings to a text file.

Rendering is much more complicated. I have created few components that could render PDF pages to ImageEnMView. Under the hub was PDFium.dll (Google Chrome PDF engine) and I was able to render simple PDFs. PDFs without active forms, digital signatures, etc..., just text and pictures.

However, I've tried it yesterday and it did not work. It worked on Win7, but on my new Win10 machine it failed. I've downloaded recent PDFium.dll, but it does not work neither...so I gave up. It's not simple to write decent PDF viewer, especially for Embarcadero platform.
Go to Top of Page

xequte

5327 Posts

Posted - Jun 28 2020 :  03:17:52  Show Profile  Reply
Hi

Just confirming what Spetric has said, creating a file is relatively simple. You just need to output your data in a single supported format. Reading a file is very different, you must recognize every available version of that format and every variation of its content. This is why we can save to formats like SVG and PDF, but reading them is not supported.




Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To: