Finds the page number in this document that corresponds to a page number in another source document.
public int GetTargetPageNumber(
LEADDocument sourceDocument,
int sourcePageNumber
)
public:
int GetTargetPageNumber(
LEADDocument^ sourceDocument,
int sourcePageNumber
)
public int getTargetPageNumber(Document sourceDocument, int sourcePageNumber)
def GetTargetPageNumber(self,sourceDocument,sourcePageNumber):
sourceDocument
Source document. Must not be null.
sourcePageNumber
1-based page number in the source document.
The 1-based page number in this document if found, -1 otherwise.
Use this method to find the number in this document of a page that belongs originally to another document.
This method is helpful when using virtual documents. The virtual document (the target document, or this.Document
object for this page collection) contains shared
pages that belong originally to other documents (source). These pages will have DocumentPage.Document point to the original document. For
example, the source document (sourceDocument
) is a PDF with 4 pages. Each DocumentPage has .PageNumber property that
corresponds to the actual page in the document: 1 through 4. If a virtual document is created (virtualDocument
) and pages 3 and 4 was added from sourceDocument
, then
it will be the first and second page in the virtual document. To find out this value, call virtualDocument.Pages.GetTargetPageNumber(sourceDocument, [3,4])
and it should
return the expected values of 1 and 2 respectively. If the page does not belong to the virtualDocument
(for example, if sourcePagNumber
is 2, which is the second page
that we did not add to the virtual document) then -1 is returned.
If sourceDocument
and virtualDocument
is the same object, then the same sourcePageNumber
value is returned.
This method is used by the LEADTOOLS Document Viewer to quickly final target page number of bookmarks or links without having to check if the document is virtual. For example, if page number 3 from the source document contains two DocumentLink with DocumentLinkTarget.PageNumber set to 1 and 4 (first and fourth page in the original PDF document). Then the viewer will call:
// veiwDocument is the document being viewed in the Document Viewer
// sourcePage is the page object in the document, containing the link.
// in the example above, this would be the first page in viewDocument which is also the third page in its original PDF document
// linkTarget contains information about the link. In the example above, it would have .PageNumber value set to 1 and 4
void TryGotoPage(Document viewDocument, DocumentPage sourcePage, DocumentLinkTarget linkTarget)
{
// Get the page number in our view document
int targetPageNumber = virtualDocument.Pages.GetTargetPageNumber(sourcePage.Document, linkTarget.PageNumber);
// If linkTarget was 1, then the method will return -1 since the page is not added to viewDocument
// If linkTarget was 4, then the method will return 2, since this page is added as the second page to viewDocument
if (targetPageNumber != -1)
GotoPage(targetPageNumber);
else
Alert("Target page is not added to this document")
}
And this will code will work regardless if the page is part of a virtual document or if it is the actual page from the original source document (since if
sourceDocument
equals targetDocument
, the method returns the same sourcePageNumber
value).
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document