Extract PDF coordinates using mouse click - pdf

I want to extract the coordinates of a PDF document with the help of a mouse click. I have gone through some posts but since I'm new to this, I'm not being able to understand it properly. Also, can this be done if I render the PDF file in a web page?

You can add javascript to a pdf document. Although you only get access to a limited subset of the language.
If you only need the coordinates once (for instance when doing layout of the document), you can simply open it with adobe and activate the rulers/grid option to see where your mousepointer is currently located.

Related

How to get page coordinates inside pdf document onclick

Is there any API in js or .net or any other free tool through which page coordinates can be obtained in a pdf? Basically, I have a pdf file which contains images so I have read the coordinates on click inside the pdf document.
*coordinates here refer to .pdf page coordinates and not pixel coordinates, however I used itext library but couldn't figure out the solution.
In order to read the coordinates of an image when it's clicked on in the PDF, you're going to need to use a PDF viewer that is capable of running scripts. Unfortunately, there are only a few of those and they all implement only a portion of the Acrobat JavaScript API but the Acrobat JavaScript API can't tell you anything about images or their location so it's doubtful that any of the others would. However, you could create a plug-in to Reader and/or Acrobat and add that functionality but then all of your users would need to install both Acrobat/Reader and your plug-in.
Assuming I understood the user experience you are looking for, I don't think it's possible without a customized viewer.

Extract screenshot or picture of portion of PDF using VBA or VB and Adobe SDK

I am currently using an excel macro (although I will switch to VB.NET if necessary) to loop through all of the text in a PDF and populate an array with certain portions of the text in the PDF (via the Adobe SDK and getPageNthWord). This part is working just fine, but now what I want goes a step further.
There are certain portions of the PDF where just grabbing the text isn't giving the full picture, and I'd like to see what more I can get. This is exactly the screenshot or snippet I am trying to get:
So, I know that I could use getPageNthWordQuads to find the coordinates for the words "Compliance Warning" and I could figure out a way to find the bottom right of the screen as well, but my problem starts there. After I get those coordinates what would I do with them? Can I zoom in the PDF to only see that portion and then take a screenshot? I already have the code for a screenshot of the activewindow, but I don't know how to scroll or zoom on a PDF.
Any help would be greatly appreciated. A fresh approach would be welcome as well. Thanks!
There are probably a number of approaches that would work - I don't know enough about your environment / constraints to know for sure which would work best. I'm assuming you are talking to Acrobat through OLE here.
1) You can open a window, get its AVPageView and ask it to zoom and move to where you want it to do your thing.
2) You can open a PDF document in one of your own windows using OpenInWindowEx and then grab the contents of that window (the advantage being that this window could be off screen).
3) You can use the DrawEx method (in AcroExch.PDPage) to render a specific portion of a page into your own window and then process that.

Customize PDF view inside a browser

I've worked on a requirement that allows me to show a PDF file inside a browser by doingo a Response.ContentType = "application/pdf".
The problem is that the default view of the PDF is always showing the bookmarks menu at the left, is there a way by using HTTP headers or something to tell the PDF viewer not to show the bookmarks section?
Thanks in advance.
There's two ways that you can do it. The way that I would recommend is to actually open the PDF in Adobe Acrobat and go to File, Properties. On the Initial View tab you'll see a lot of options for how to display the PDF. The second way I haven't tested but Adobe says you can pass various querystring options to the PDF. The one you'd probably want is http://example.org/doc.pdf#pagemode=none
The way how a PDF document is displayed can be configured inside the PDF document.
There are a lot of PDF editors that can modify the "viewer preferences" as it is mostly called. One free example is BeCyPDFMetaEdit.

Is it possible to have a PDF file open at a predefined magnification in Adobe Reader?

We have a downloadable PDF file which looks great at 72% magnification in Adobe Reader and not so good at 101%. When downloaded and opened in the reader, its default magnification is 101%.
Is there a way to define the default magnification in the PDF file itself so that we ensure the best user experience?
Thank you!
If you can control the URL used to download, you can put parameters in the URL to control how the built-in reader will display the file.
For example, http://example.org/doc.pdf#zoom=50 will set the magnification to 50%.
See: https://www.evermap.com/AutoBookmark/Manual/OpenParameters.htm
The above applies to the built-in reader supplied by Adobe. Other readers may not honor the parameters. In particular, see the answer to this question regarding Chrome.
An example of how to define magnification when opening a file (regardless of the default one):
AcroRd32 /A "zoom=50=OpenActions" sh.pdf
First, this is a programming website, so you should identify a programming context. This question will probably be closed because it belongs on the soon to be launched serverfault.com
To set the default magnification, you need Adobe Acrobat Standard or Professional not Reader to have the ability to edit pdfs. Then when you open the document, click File | Properties. Click the Initial View tab and enter 72% in the magnification text box and click ok. Save your pdf and reopen it. It should default to 72% magnification when it is opened.
Note: I am unsure if other open source pdf editors provide this type of functionality.
Update: Standard doesn't work for saving magnifications.
For Adobe Standard, go to "Edit" then "Preferences."
When you click on the "Page Display" tab on the left, you'll see a panel with a field called "Zoom," where you can select a percentage from a drop-down menu.
If the above suggestions are not working it may be because the bookmarks can contain zoom instructions in their properties. To look at the bookmark properties select a bookmark in the bookmark panel and right click it to open properties. Choose actions. There should be a description of actions that will be applied when clicking on the bookmark.
The best solution I have found is that you can add a subsequent property for zoom instructions that will execute following the initial one, and set the page zoom to your specifications. To do this, select all of the bookmarks, right click to open properties, then actions, then choose the add function. After choosing add, find the zoom instruction that is the best fit for what you are looking for.
If you want to edit the initial zoom instruction through the edit function in bookmark properties on all bookmarks, you cannot select all, because, although the zoom will be set correctly, every bookmark will be set to one bookmark page. If you wish to edit the properties this way you must edit each, one by one.

Is there a way to display a PDF in an asp.net webpage without frames?

I have a PDF document that needs to be pulled up in the browser, edited, and saved. I can save via the embedded adobe toolbar, along with all the other acrobat functions. But, what I am trying to see is if there is a way to display the PDF in a webpage alongside web controls.
For example, in the top part of the webpage I have a dropdownlist. It has a list of PDFs. I select one and the bottom part of the webpage opens up with the PDF.
Thanks.
Are you looking for something like Scribd's iPaper viewer?
You can embed it on your site or host with them.
This is typically done with an iframe.
Sorry, you'll have to use either Frames, or iFrames. Perhaps you can also get it via an <object> tag, but that might get browser-specific.
I would contact the people at ceTe (makers of DynamicPDF). Their product permits you to dynamically replace your page output with a PDF file but this involves changing the entire page (the mime-type will be pdf). Is it possible to output the page to a panel instead? I don't think so, but they would be the people I would turn to.