Interactive PDF (for Mobile) - Is there a way to navigate to a page within a PDF and ensure that the user starts at the top of the page? - pdf

I'm creating an interactive PDF to be viewed on a mobile device (it's not an ideal option, but this is the direction we need to pursue).
Currently, I have tested buttons and hyperlinks, and I can easily navigate through the PDF. However, my view following the jump is centred on the page (content is cut off on the page above and below).
I have tried a variety of hyperlink anchoring types, but I'm not having any luck.
I thought the solution could be to use navto:// within a GO to URL hyperlink, but I have been unsuccessful with that as well.
Is there a way to navigate to a page within a PDF and ensure that the user is brought to the top of the page?

If you are willing to post-process the file, cpdf -open-at-page <n> in.pdf -o out.pdf should set this up, for a given value of <n>. See Chapter 11 of the manual for details.

Related

How to make bookmark targets fitwidth?

I want to make the targets of bookmarks fitwidth. I don't see there is such option in pdftk and cpdf. Is this possible with these tools? Or some other tools provide this feature?
Yes but not always applied the same in all viewers. However it should be possible to set a preferred page wide strip near top of page. Here we see effect in Acrobat on clicking single bookmark.
I dont think PDFtk is that refined however in cpdf format output is
0 "FitWidth" 1 "[1/FitBH 792]"
Note:- read the manual however the first 0 may need to be 1 or more but the rest should be similar
Here is an example using the manual to alter 6 to 6.0 and zoom fit width to top of page (page height in this case is 666) and fit width works in Acrobat or some other readers, but only top of page in others like Edge.
Note that ALL existing bookmarks need export first.
cpdf -list-bookmarks -utf8 "cpdfmanual - Copy.pdf" >bookmarks.txt
make edits
Reapply ALL bookmarks
cpdf -add-bookmarks bookmarks.txt "cpdfmanual - Copy.pdf" -o "cpdfmanual - Modified.pdf"
Note not working in current Edge or many other browsers and that with Chrome/ium represents the web majority.
However for browsers you can send URL.pdf#fragment(task=value)
bookmark_targets_fitwidth.pdf#view=FitH

Pdf Editing: change page size WITHOUT resizing content or rotate page WITHOUT rotating content

I receive postage labels from a supplier as single page pdf documents. The labels would fit on an A5 sheet but they are presented as a portrait within an A4 page, also in portrait orientation. I would like to be able to print two of these labels per A4 page to cut down on waste.
This can be achieved by rotating the page content without rotating the page itself. Or by resizing the page by swapping the height and width about the content. I am aware that both of these things can result in content being lost, which isn't a problem for my use case. Ideally I'd like a command line application that works on both Linux or Windows machines. Unfortunately, web searches for "rotate" or "resize" pdf will point to the many applications that just rotate or resize pdf pages along with the content which isn't what I want.
Similar questions:
With PdfBox: identical use case, see my comments on PdfBox below.
With iText: almost identical use case, I explicitly don't want any resizing of the content. See my comments on iText below as well.
Things I have investigated tried:
pdftk - too basic
ImageMagick - the original image contains transparency and the extent argument results in a visible loss of quality
pdfjam - also requires install of Latex and PdfPages. Ideally I'd like something that works on both Windows and Linux.
iText7 - the documentation isn't great. Looks like it was completely re-written in the last few years and the Nuget feed makes it clear that previous version, iTextSharp, is EOL. Consequently most of the examples one finds online (including on this site) are out of date. iText7 doesn't let you resize a page. I got as far as saving a document with a new page that was the right size but struggling to copy the content over. I think I could get what I wanted from this but it would take a long time and I'm trying to do something simple.
PdfBox - I've already tried one .NET library without success. Looking at the comments to the question I've linked above, this one seems to also have a version issue. I'm trying to do something really simple here, I will try this one if I exhaust all other avenues
Gimp - does what I want but I have to fire up the application, point and click quite a few times to rescale the image canvas, set the background and export
Screenshot the label from a pdf reader at 100% size and paste into a Word/LibreOffice doc. Sadly this is the most reliable method I have at the moment
I have example labels but they contain the name and address of people I've sent things to, I'd rather not upload them.
Try the command line tool cpdf from here: https://community.coherentpdf.com
cpdf -rotate-contents <angle> in.pdf -o out.pdf
to rotate contents without rotating the page. or...
cpdf -mediabox "100 100 600 500" in.pdf -o out.pdf
(and -cropbox and so on) to change page dimensions without altering content. Chapter 3 of the manual is of relevance.
You can also prepare the file by removing any page rotation whilst counter-rotating the content to leave the visual appearance unchanged:
cpdf -upright in.pdf -o out.pdf

Fetch a certain page of a pdf as an image from google drive

I have some 10,000 pages of hand-written scanned documents in google drive in somewhere around 70 pdf documents.
I am making a spreadsheet index of these, with one row for each page where I make notes of what is on each page, by actually viewing those pages, reading it, and every fully typing it if required.
I need a link, which I can put in the spreadsheet, which when clicked opens up a certain page of the pdf as an image only, and not the entire pdf, the pdf is in google drive. Is there something like this possible in Google Drive? Or should I manually download all pdf, split it into images, and then re-upload and use that?
(example - java -jar pdfbox-app.jar PDFToImage -format jpg -quality 0.75 pdffile.pdf ; and then upload all this)
I have a feeling it must be possible because when we open the pdf in browser, it loads pdf pages one by one, it takes time but it opens it in some custom image+text format, so it must be exported. Also I know there is one image version for each google slide and link is stable, so there might be something for pdf also I was thinking.
There isn’t a parameter or feature to link a pdf page in Google Drive file viewer.
Indeed as mentioned, you can link to a specific slide in Google Slides, however Google file types do have additional features.
That’s not the case for PDFs for example. A workaround I can think of would be to create a comment for each page and each comment will have its own id.
After creating the comment, you can click on the three vertical dots icon and click on Link to this comment.
Alternatively, you can send feedback to Google (On file viewer page, click on three vertical dots icon and then Send feedback to Google) making sure to describe the proposed feature.

Add margin to pdf page

I have a pdf book that is not showing up completely. I have attached a screenshot of acrobat's print preview showing what the issue is. As you can see there is more conentent on the left of the page that is not showing up.
I have tried:
Changing the paper size
Changing the dimensions to "fit"
Opening in Google docs
Opening in mac's preview
Opening in Google Books.
Any ideas of what I can try
As a late answer and when using Linux, one can use the command line tool "pdfjam".
Add margins to pages
Desired result: remove 0.5 cm from top and bottom of page, add 2 cm to right margin. Keep page size (important)
pdfjam --fitpaper true --trim "0cm 0.5cm -2cm 0.5cm" input.pdf -o output.pdf
Negative numbers in the trim-argument means "add", while a positive means "remove".
The four numbers within the trim-arguments relates to the left, bottom, right and top margin
If fitpaper is set to false the trim will move the content around the page and not resize the page.
You can add "--frame true" to see what's going on.
Move content to the left
Desired result: make right margin 1 cm larger and left margin 1 cm smaller
pdfjam --offset "-1cm 0cm" input.pdf -o output.pdf
The command below will move the content of the page 1 cm from right to left.
pdfjam and documentation
Documentation about pdfjam can be found here: http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic-research/firth/software/pdfjam
The combination of pdfinfo, pdftk and pdfjam can be used to modify PDFs quickly on a more advanced level.
If I was you, I would check if PDF page boxes are correct. Especially if document looks fine in viewer but offset in print preview.
The issue might be caused by any of the boxes defined so they are outside of MediaBox.
Another approach to try is to impose this document onto other document with some offset. Others recommend Multivalent and Ghostscript for the task.
Without seeing the PDF it is hard to determine the exact reason for what you're seeing, but often the reason is that the CropBox is smaller than the MediaBox. The MediaBox is the size of the physical page and the CropBox is the area of the page that is viewed or printed. If no CropBox is specified then its value is inherited from the MediaBox.
You can programmatically get the page box dimensions and also set them using my companies free PDF SDK. It's an ActiveX for Windows and it is called Debenu Quick PDF Library Lite.
Upload the PDF and share a link if the page box dimensions do not solve the mystery.
Fixed it!
I had to change the page size of the file (Printing to pdf on a larger paper didnt work)
Steps to get it down:
Open Adobe Acrobat Plus
Click on "tools"
Click on "Crop" (which is under the "Page" section)
Double click anywhere on the pdf
Under "Change page size" make it larger then what it is
apply to all!
That's it!

Undo Pdfnup Operation

I have a Pdf file which contains several slides per page, including text (not only images).
This pdf was probably created using pdfnup.
Can I revert the pdfnup operation so that each slide is shown on one page?
As far as I know, there is no simple to be used 'undo' operation.
However, the following answers show you the approach principle, how you can achieve the undo-equivalent operation using Ghostscript:
Convert PDF 2 sides per page to 1 side per page (Superuser)
How can I split a PDF's pages down the middle? (Superuser)
Cropping a PDF using Ghostscript 9.01 (Stackoverflow)
PDF - Remove White Margins (Stackoverflow)
(Should these not help you to find the final solution, ask again. But then to come up with a fully working commandline, I'd need the complete output of the following command first: pdfinfo -f 1 -l 100 -box your.pdf.)