Print Page | Close Window

Count bookmarks using DAOpenFile

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2221
Printed Date: 26 Jun 25 at 8:08PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Count bookmarks using DAOpenFile
Posted By: modderkolk
Subject: Count bookmarks using DAOpenFile
Date Posted: 11 Apr 12 at 9:50AM
Hi,

I use DAOpenFile for getting the number and format of all pages of the PDF. That works very fine, also with very big files and page formats!Clap

But sometimes I need to count the number of the bookmarks (outlines).

I know that I can use .LoadFromFile and then .PageCount() and .OutlineCount(), but then after loading several files the .LoadFromFile gives fileHandle 0. Cry
I use for each document when I am ready .RemoveDocument().

2 questions:
1. Is there or will there become a "DA-version" of the OutlineCount() ?
2. If not, what need I to do to get the OutlineCount() without problems?

Thanks,
Evert-Jan



Replies:
Posted By: Ingo
Date Posted: 11 Apr 12 at 10:15AM
Hi Jan!

Could it be that you're working on a list of files in a loop
with LoadFromFile?
Perhaps (with very large files) you throw a second filename
into LoadFromFile but the first file still isn't completely loaded?
Perhaps you should think in this direction...?
If you're suggesting a further development of QuickPDF you
should enter this Link:
http://www.quickpdflibrary.com/support/support-query.php

Cheers and welcome here,
Ingo


Posted By: modderkolk
Date Posted: 11 Apr 12 at 10:42AM
Hi Ingo,

I indeed use a loop to process a list of PDF files. For each file a call this function:

        // QuickPDF 
        private string HandlePDF(string filename)
        {
            try
            {
                int formaatNr = 0;
                // Open the file, get a file handle
                int fileHandle = 0;
                fileHandle = qp.LoadFromFile(filename, "");

                if (fileHandle == 0)
                {
                    return filename + ": cannot open file.\r\n";
                }
                int aantalPags = qp.PageCount();

                if (aantalPags == 0)
                {
                    qp.RemoveDocument(fileHandle);
                    return filename + ": filehasn't pages.\r\n";
                }
                aantalBMs += qp.OutlineCount();

                for (int p = 0; p < aantalPags; p++)
                {
                    // Get a reference to the first page and get the formats
                    int pageReference = 0;
                    double pageWidth = 0;
                    double pageHeight = 0;
                    int rotation = 0;

                    pageReference = qp.SelectPage(p + 1);
                    pageWidth = qp.PageWidth();
                    pageHeight = qp.PageHeight();
                    rotation = qp.PageRotation();

                    if (rotation == 90 || rotation == 270)
                    {
                        double d = pageWidth;
                        pageWidth = pageHeight;
                        pageHeight = d;
                    }
                    double br = pageWidth;
                    double hg = pageHeight;
                    br = br * 0.3527;  // convert from units to mm
                    hg = hg * 0.3527;
                }

                // Close the file
                qp.RemoveDocument(fileHandle);
            }
            catch (Exception ex)
            {
            }
            return "";
        }

Is this the correct way, or how can I know that a file is loaded?

Thanks,
Evert-Jan


Posted By: Ingo
Date Posted: 11 Apr 12 at 1:03PM
Hi Jan!

If LoadFromFile returns with value 0 you can use
LastErrorCode to check where's the real problem:
http://www.quickpdflibrary.com/help/quickpdf/LastErrorCode.php

Cheers, Ingo



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk