| | |
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 |
adobe ansi api array arrays bash binarysearch centimeter char convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling hardware highest homework i/o ide inches infiniteloop initialization interest kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives match matrix meter microsoft motherboard multi mysql odf open opendocumentformat opensource openwebfoundation owf pattern pdf performance pointer pointers posix power probleminc program programming pyramidusingturboccodes read recursion recv repetition scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string strings suggestions systemcall test testautomation unix urboc user voidmain() wab win32api windows.h





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 