| | |
Open PDF files at a certain page
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 42
Reputation:
Solved Threads: 0
Hi!
I'm using a C program to open PDF files with this code:
Now I need to go furthrer; I need to open the PDF file at a certain page. I've tried
...as is suggested in Adobe's docs, but this does not work.
Any hints?
I'm using a C program to open PDF files with this code:
c Syntax (Toggle Plain Text)
ShellExecute(GetDesktopWindow(), "open", "c:\\someFolder\\myFile.pdf", NULL, NULL, SW_SHOWNORMAL);
Now I need to go furthrer; I need to open the PDF file at a certain page. I've tried
c Syntax (Toggle Plain Text)
"c:\\someFolder\\myFile.pdf#page=5"...
...as is suggested in Adobe's docs, but this does not work.
Any hints?
EDIT:
On second thoughts, you are right.
Just a little change
Just add a space, cause page=4 is an argument.
----------------
I don't know if there are any real ways to do it. But how about triggering some keyboard inputs with keybd_event()
All you have to do is Ctrl+Shift+N to open the "go to page" dialog box. and then the input the number 4(say) and also "Enter" with the same function. Before all this you have to give time for the pdf to get opened and become active(You may have to use the function Sleep())
You can get the complete set of Virtual key codes in msdn
Hope it helps
On second thoughts, you are right.
Just a little change
c Syntax (Toggle Plain Text)
ShellExecute(GetDesktopWindow(), "open", "c:\\someFolder\\myFile.pdf #page=4", NULL, NULL, SW_SHOWNORMAL);
Just add a space, cause page=4 is an argument.
----------------
I don't know if there are any real ways to do it. But how about triggering some keyboard inputs with keybd_event()
All you have to do is Ctrl+Shift+N to open the "go to page" dialog box. and then the input the number 4(say) and also "Enter" with the same function. Before all this you have to give time for the pdf to get opened and become active(You may have to use the function Sleep())
You can get the complete set of Virtual key codes in msdn
Hope it helps
Last edited by Prabakar; Feb 7th, 2009 at 1:43 am.
•
•
Join Date: Mar 2008
Posts: 42
Reputation:
Solved Threads: 0
Well, so far I've not succeeded in making it work.
It is very easy to get the righ result when you open PDF files in a web browser: all you have to do is follow the PDF file name with the #page=n parameter (and without space).
However it does not work when calling the PDF from C/C++. I know it is possible, I've seen it work somewhere...
I'll post the solution here when I find it...
It is very easy to get the righ result when you open PDF files in a web browser: all you have to do is follow the PDF file name with the #page=n parameter (and without space).
However it does not work when calling the PDF from C/C++. I know it is possible, I've seen it work somewhere...
I'll post the solution here when I find it...
Sorry to have suggested an untested code.
My little Google search found me this
Have a look at it.
This time I have tested the code and it really works.
D:\Program files\Adobe Reader 9.exe is the path to the portable reader in my computer(I always try to get portable versions).
Ubuntu.pdf was in the same folder as my CPP program, hence I did not specify its path.
Details about parameter options could be found int the link above.
Good Luck
My little Google search found me this
Have a look at it.
This time I have tested the code and it really works.
cpp Syntax (Toggle Plain Text)
ShellExecute(GetDesktopWindow(), "open", "\"D:\\program files\\Adobe Reader 9.exe\"", "/A page=45 Ubuntu.Pdf", NULL, SW_SHOWNORMAL);
D:\Program files\Adobe Reader 9.exe is the path to the portable reader in my computer(I always try to get portable versions).
Ubuntu.pdf was in the same folder as my CPP program, hence I did not specify its path.
Details about parameter options could be found int the link above.
Good Luck
Last edited by Prabakar; Feb 9th, 2009 at 11:28 am. Reason: Spelling Mistake :$
![]() |
Similar Threads
- Read number of pages in PDF files (Python)
- Help with make CD with more then 400 .pdf? (Computer Science)
- how to count pages of .pdf files? (VB.NET)
- Internet Explorer v6 - Blank Page (Viruses, Spyware and other Nasties)
- Cant open certain links in a web page... (Viruses, Spyware and other Nasties)
- problem with dialogbox save/open/cancel jsp in IE (JSP)
- How to write the new line existing pdf file using php (PHP)
- Default program to open *.pdf (Mac Software)
Other Threads in the C Forum
- Previous Thread: Dynamicaly defining a structure in C
- Next Thread: What method is better?
| Thread Tools | Search this Thread |
* ansi api append array arrays bash binarysearch calculate centimeter changingto char character convert copyanyfile copypdffile createcopyoffile createprocess() directory dynamic execv fflush file floatingpointvalidation fork forloop frequency function getlasterror getlogicaldrivestrin givemetehcodez grade graphics gtkgcurlcompiling gtkwinlinux hardware highest histogram homework i/o ide inches initialization intmain() iso km license linked linkedlist linux list looping loopinsideloop. lowest matrix microsoft multi mysql oddnumber open opendocumentformat openwebfoundation pdf pointer pointers posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprogramming stack standard strchr string strings suggestions test testautomation threads unix urboc user variable whythiscodecausesegmentationfault win32api windows.h windowsapi





I don't know why it is not working in vista, these functions are ment to work on windows after all. Perhaps you'll have to wait for others to respond 