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
 PdfViewer.AutoSync
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

jrpcguru

USA
254 Posts

Posted - Feb 16 2022 :  17:56:22  Show Profile  Reply
With the WPCubed plug-in, I was able to instantly transfer the image of a PDF page to another copy of ImageEnView in my popup form. I discovered I could do this with PDFium (though the help file was cautious about telling me this). I could use either:

ImageEnView1.PdfViewer.AutoSync := True; OR

ImageEnView1.PdfViewer.SyncToBitmap := True; //set bitmap so Assign can work

ImageEnView1.IEBitmap.Assign (frmImagePopUp.ImageEnViewSame.IEBitmap);

OR

ImageEnView1.PdfViewer.DrawTo( frmImagePopUp.ImageEnViewSame.IEBitmap );

Regardless of which method was used, the resulting image of the PDF page was very low resolution. Is there any way of transferring a PDF page from PDFium to another copy of ImageEnView and get the same resolution that PDFium is displaying?

J.R.

foxdingding

65 Posts

Posted - Feb 16 2022 :  19:40:41  Show Profile  Reply

         IEGlobalSettings().PdfViewerDefaults.DPI:=300

         for I := 0 to PDFView.PdfViewer.PageCount-1 do
         Begin
            Self.ProgressBar1.Position:=I;

            Application.ProcessMessages;

            tmpIEBitmap.Clear;

            PDFView.PdfViewer.PageIndex:=I;

            PDFView.PdfViewer.DrawTo( tmpIEBitmap,
               MulDiv(PDFView.PdfViewer.PageWidth,IEGlobalSettings().PdfViewerDefaults.DPI,72),
               MulDiv(PDFView.PdfViewer.PageHeight,IEGlobalSettings().PdfViewerDefaults.DPI,72));

         End;


a
Go to Top of Page

xequte

38222 Posts

Posted - Feb 16 2022 :  22:50:20  Show Profile  Reply
Hi

Yes, the DrawTo method is correct.

From v10.3.5 you will just be able to use your old code because PdfViewerDefaults.DPI will affect syncing too.

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

jrpcguru

USA
254 Posts

Posted - Feb 17 2022 :  10:49:57  Show Profile  Reply
Thank you for your prompt reply. I remain baffled, however.

The help file says that PdfViewerDefaults.DPI is ignored by PDFium.
The help file says that PdfViewer.DrawTo has only one parameter and the sample code includes 3 parameters. Not surprisingly, it will not compile with "Too many actual parameters" error.

An example of problems with the help file:
The PDFViewer topic has a bullet point: "- High quality printing and exporting to bitmap" but only the printing is hyperlinked. Exporting to bitmap is not mentioned in that topic and surely needs its own page.

J.R.
Go to Top of Page

xequte

38222 Posts

Posted - Feb 17 2022 :  14:28:29  Show Profile  Reply
Hi JR

Sorry, these features are from the upcoming 10.3.5:
- PdfViewerDefaults.DPI affects the export quality and display size of PdfViewer (Pdfium)
- DrawTo() includes size paramaters

You can email me for the beta

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

jrpcguru

USA
254 Posts

Posted - Mar 11 2022 :  19:40:28  Show Profile  Reply
I have installed 10.3.5 and run some tests with PDFium.

Using IEGlobalSettings().PdfViewerDefaults.DPI := 72;
and ImageEnView1.PdfViewer.DrawTo( ImageEnViewCompare.IEBitmap );
This delivers the same low resolution copy as I experienced with IEBitmap.Assign. So I increased DPI to 144. That yielded a decent level of resolution. I tested viewing, printing and zooming and found some problems.

ImageEnViewCompare.IO.Params.Assign(ImageEnView1.io.Params);
I had been using this immediately after the ImageEnViewCompare.IEBitmap.Assign (ImageEnView1.IEBitmap); or the DrawTo. (A left over from my WPCubed implementation.) With DPI at either 72 or 144, clicking the print icon on the toolbar yielded a Floating point division by zero error. I finally realized this line of code wasn't needed and then printing worked properly.

Apparently the solution will be to use PDFium to load the 2nd image object when it is needed for comparing images. Fortunately, PDFium is quite fast to load individual pages.

The next problem arose when I tested zooming after clicking the toolbar icon for Show All Pages. Previously I could shrink the image and then scroll down to another page, and zoom back up via the scroll wheel and it would zoom in on the newly selected page.

ImageEnView1.MouseWheelParams.InvertDirection := true;
ImageEnView1.MouseWheelParams.Action:=iemwZoom;
ImageEnView1.MouseWheelParams.ZoomPosition := iemwMouse;
AutoStretch & AutoShrink are false

If DPI is 72, this works as expected. If DPI is 144 (so I can use DrawTo successfully), I can not even select the last page and clicking on a page other than one does not let me zoom in on that page. The vertical scrollbar stops before it gets to the last page. I have confirmed this basic behavior with the PDFViewerToolbar demo. Oddly, my popup form keeps the pages centered in the image object, but my main form slides the image partially off the left side of the image object with no scrollbar to slide it back.

I haven't found any properties that differ between the two image objects that might account for different zoom behavior. But they both fail to show the last page or allow zooming into a selected page. I first discovered this behavior when I tried to implement:
ImageEnView1.PdfViewer.PageSpacing := 1;
ImageEnView1.PdfViewer.PageFrameColor := clBlack;
ImageEnView1.PdfViewer.SelPageFrameColor := clRed;

But it quickly became apparent that this was not the cause and this new feature seems very useful.



J.R.
Go to Top of Page

xequte

38222 Posts

Posted - Mar 14 2022 :  00:27:52  Show Profile  Reply
Hi JR

The scrollbar issue is fixed in the current beta. But you don't need to set IEGlobalSettings().PdfViewerDefaults.DPI to improve the quality of PdfViewer.DrawTo(). Just use the new parameters:

https://www.imageen.com/help/TIEPdfViewerInteraction.DrawTo.html



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