Re: [Lazarus] Get the number of pages in a pdf file

2019-06-16 Thread Joe C. Hecht via lazarus
Searching for strings of /Pages and /Count would be highly unreliable.

At worst, you would need to search the whole file, adding the entries.

To do it right, you need to get the page tree of the document catalog, then
recursively look up the kids of each page tree node, increment the count, then 
visit the all child nodes.

There are many libraries that can do this, both free, and commercial.

Joe C. Hecht
UberPDF.org
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] I found an AnchorDockingDsgn package bug?

2019-06-16 Thread Michael W. Vogel via lazarus

Am 14.06.2019 um 23:51 schrieb leyba bronstain via lazarus:

After installing the AnchorDockingDsgn package for Win7 x64, I noticed
a strange IDE behavior. If you dock any other window to the Source
Code Editor in the manner shown in the figure, then it becomes
impossible to close any tab of the Source Code Editor using the mouse
(using the shortcuts, the tab is closed correctly). It's a bug?

See more here:
https://forum.lazarus.freepascal.org/index.php/topic,45728.0.html


Yes, I can confirm that problem.

The SourceEditor doesn't have a default PopupMenu, it is created on
MouseUp. So the AnchorDockingPageControl is opening its PopupMenu. I
could recreate the problem in a simple app.

Imho a simple workaround could be to create a dummy PopupMenu for
SourceEditor, something like the added patch.

Can you please open a bug report on Mantis?!

Michl
Index: ide/sourceeditor.pp
===
--- ide/sourceeditor.pp (revision 61401)
+++ ide/sourceeditor.pp (working copy)
@@ -657,6 +657,7 @@
   private
 FNotebook: TExtendedNotebook;
 FBaseCaption: String;
+FDummyPopupMenu: TPopupMenu;
 FIsClosing: Boolean;
 FSrcEditsSortedForFilenames: TAvlTree; // TSourceEditorInterface sorted 
for Filename
 TabPopUpMenu, SrcPopUpMenu, DbgPopUpMenu: TPopupMenu;
@@ -6557,6 +6558,8 @@
 OnTabEndDrag := @NotebookEndDrag;
 ShowHint:=true;
 OnShowHint:=@NotebookShowTabHint;
+FDummyPopupMenu := TPopupMenu.Create(Self);
+PopupMenu := FDummyPopupMenu;
 {$IFDEF IDE_DEBUG}
 debugln('[TSourceNotebook.CreateNotebook] D');
 {$ENDIF}
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Get the number of pages in a pdf file

2019-06-16 Thread Santiago A. via lazarus

El 15/06/2019 a las 13:56, Graeme Geldenhuys via lazarus escribió:

On 14/06/2019 6:19 pm, Rogério Martins via lazarus wrote:

Is there a function for read info about a pdf file ?  I need to know the
number of pages in a given pdf file.

I don't know of a Object Pascal library you can you, but there is an
alternative. The PDF fromat is a mixture of text and binary. You can
search for text as follows:

/Type /Pages
/Count 45

After the "/Type /Pages" there should be a "/Count " line which
contains the page count. Hope that helps.

It is not completely reliably.
I used to search "/Type /Pages", but a day I couldn't find it, after 
digging a little in the PDF, I discovered that the number of pages was 
stored in a compressed stream.  PDF can sore any data in a compressed 
stream and they decided to compress page information. And since then I 
have begun to find it more frequently.  I suppose that once you have the 
frame work to compress stream, why not compress everything. I can't see 
what are the advantages of compressing a few bytes, but it's there.


Now I try to search "/Type /Pages" and if I can't find it I call a 
external utility "pdftk"


--
Saludos

Santiago A.

--
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus