How to convert DOCX to PDF with nameddest to be linkable in FireFox and Chrome - pdf

From my website, I'm linking several sections within a PDF document using URL in format http://www.example.com/Document.pdf#nameddest=sectionXY
(as discussed e.g. here).
My PDF document is manually created from a DOCX document using the "PDF export" function in MS-Word 2016. The labels are marked as MS-Word bookmarks in the source document.
Unfortunately, the PDF viewer in the web browser scrolls to the proper section only in the Google Chrome. In other browsers (FireFox, IE 11 or Edge) the PDF document is always opened on the first page.
I'm sure my solution used to work several years ago both in Chrome, FireFox and IE.
Is there any way to make it work at least in Chrome and FireFox?
I'm able to use another converter (or even some PDF library) but I cannot afford to have my source document in any other format than DOCX. I'm even able to mark my "labels" another way than using MS Word bookmarks.

Word's PDF export may or may not create "named destinations" in the PDF file. It seems to vary based on platform (Mac vs Windows) and by version (2010 vs 2016).
LibreOffice can import .docx and has PDF export with specific options for creating named destinations from the document bookmarks.
Chrome uses PDFium Firefox uses PDF.js as its built-in PDF viewer, both of which support navigating to named destinations with #nameddest=sectionXY as well as some other navigation styles specified in RFC like #page=2. (See a related question on linking to sections.)
You can check your PDF file for named destinations with Popper's pdfinfo or other tools (see a related question on Unix.SE about listing named destinations).

This is probably not something you'll be able to change.
The PDF standard itself for instance does not really specify whether links like the one you posted should work. So support for them is not something you commonly find.
Of course if the browser is open source, you may always post a pull request.

Related

vb.net - Display docx & xlsx files in Webview2 control

I'm working on a project in .net that has a need for a document preview function.
I've implemented a Webview2 control and, as the majority of doucments that need to be viewed are pdf, this works a treat.
However, now and again some documents may be in either docx or xlsx format.
When I set webview2.Source = New Uri(PathtoFile) on these files, the webview2 control downloads the document to my downloads folder rather than rendering it.
I get that the files are not HTML, but then again neither are PDFs and they work out of the box.
Is there some mechanism I'm missing whereby I can have the Webview2 control display the file contents for docx and xlxs rather than download?
We are having the same problem ourselves. At the moment we are using a product called Aspose that will allow us to convert Word Documents to XPS, after which we can display the document in a Document Viewer.
While this works, and it works well, the main problem is that this relies on us downloading the document, then converting it and then loading the converted document into the Viewer. Which causes a certain perception of "sluggishness" due to all of that work, whereas images and PDFs, especially when hosted on the Web, can be hosted directly in the WebView2 and this then leaves the rest of our application nicely responsive to user interaction.
So in case anyone comes up with a better suggestion, I'm following this ...
The code using Aspose is pretty straightforward (example in Visual Basic .NET):
Dim oDoc As Aspose.Words.Document = Nothing
oDoc = New Aspose.Words.Document(sFile)
oDoc.Save(fileName:=sToFileName, saveFormat:=Aspose.Words.SaveFormat.Xps)
(left out all error handling and so on in order to focus on the actual functionality. sToFileName just contains a filename along the lines of [somefolder][yourtargetfilename].xps ...)
I guess you may try to convert DOCX to PDF directly via Aspose.Words and XLSX to PDF via Aspose.Cells. Both these APIs support rendering to PDF or even image formats. Since your viewer supports to view PDF or images, so you may try this approach, it might work for your needs.
PS. I am working as Support developer/ Evangelist at Aspose.

Can you embed a separate pdf into Indesign and open it after exporting to PDF?

I would like to ask the following if possible. We have a client that wants a separate pdf document, embedded in a main pdf document and opens when you click it. Like the function in MS Word where you can attach another Word document inside a Word document (Word-ception, lol) and you can still open it.
I've tried it in Acrobat Pro with the Attachment and Link tools. Another option was to put the link document in an ftp server for accessibility. but our client really wants this functionality. Is this possible in Indesign?
Thank you!
Using Word as your example vehicle there are several ways to link 2 documents.
One is an appendix to the other, in PDF terms is a merge or binding but its one flowing document with separate sequential sections/chapters.
Another way is to link to an external file, in PDF terms a hyperlink to a relative second file, which can be locally folder relative or a web absolute reference. You have tried that.
In Word we can add objects internally with icons, in PDF that can be an annotation comment attachment to save externally and action accordingly. You also seem to discount that approach.
Finally PDF offers an Adobe Specific Structure where multiple PDFs attachments can be imbedded in an overall PDF wrapper. These are called Portfolios and not! to be confused with their portfolio service
They are unpopular since in a browser without Adobe Reader they should only offer the cover page.
Whilst in securer offline readers the files may well be shown as attachments that you need to save or independently open to view them.
Only some non Acrobat viewers may view them as a collection. And in the past that required runing insecure SWFlash, But I understand that has changed ?
Here is how the 3 internal PDF files seen above were shown in older Acrobat 9.
Possibly the best experience is using Foxit Reader

Putting an iframe overlaid on a pdf document in a browser extension

I created a browser extension that lets you look up words in Wikipedia or Wiktionary without needing to open a new tab ( https://addons.mozilla.org/en-US/firefox/addon/in-page-lookup/ , almost done porting to Chrome). It is very useful when you are doing research and come across a word you don't know or want to know more about. The only thing is, a lot of research content is in PDF format. A long time ago (~2013ish) I had an older version of the app based on the old Firefox add-on framework and that did let iframes show up over pdf documents but this has not been the case for many years. I don't think the extension is even recognized in pdf documents, I get "Error: Could not establish connection. Receiving end does not exist" and there is no extension content script on the pdf page. So, my question is, is it possible to put an iframe over a pdf document? Do I need to work on the background side, and if so, how? Thanks.

Edit texts in a PDF on Chrome using Chrome inspect

Is there any way to modify texts in PDF on Chrome using the Chrome inspect tool? I was stuck because in the Chrome inspect element, differently than any other websites and even PowerPoint presentations opened in Chrome, I'm able to modify texts, while with PDFs I cannot. Does anyone know how to do it?
Edit: Yes I know that the changes made through Chrome DevTools are temporary, but usually I'm able to make those changes, even if they're temporary. But with PDFs I can't.
There are differences in the way some browsers handle PDF data.
Chromium based browsers are more traditional in that the PDF plug-in is based on a Foxit/Skia collaboration, So you need to understand in that case, the downloaded PDF you are viewing is in the binary application/pdf (file already outside of the html wrapper).
Just as you cannot edit the PDF text in Acrobat Reader, the most you can do is incrementally add comments/annotation or field data to the end of the file, before save as a secondary download. The server cannot see your changes unless you submit as an upload.
With Firefox and Google docs there is often a different approach where the PDF is "Repr"oduced as an "Ex"ample (A ReprEx of the PDF) so it is built of a hybrid image and text overlay to emulate that part of the real PDF source. When you previously or later save the underlying downloaded PDF (for viewing) it would not necessarily include any browser based HTML editing, in the saving.
There are other techniques for other cases, but to answer the basic OP question most simply, the answer is NO you cannot change a PDF body, only add notes, etc via extensions. Microsoft variant of Chrome I.E. Edge has some inbuilt annotation ability thus does not need a second extension.
Found this question because I was googling a similar situation--I was wanting to manipulate type sizes and margins on a PDF in inspector via Chrome. I found that FireFox DevTools will allow you to view those styles and even alter the content in the PDF while in browser. I am late to the game but hope this provides answers for someone else in the future.

PDF downloading instead of opening in new tab

This is not a back-end programming question. I can only modify the markup or script (or the document itself). The reason I'm asking here is because all my searches for appropriate terms inevitably lead to questions and solutions about programming this functionality. I'm not trying to force it via progrmaming; I have to find out why this PDF is behaving differently.
So:
I have a bunch of links to PDFs on a page. Most of them open in new tabs, but one of them, the most recent, starts to open in a tab, but then the tab closes and the PDF gets downloaded as a file instead. All markup is consistent - there's nothing differnt about the odd-man-out except the actual URL.
You can see this here:
http://calwater.mwnewsroom.com/Investor-Relations/Financial-Reports/Annual-Reports
All annual reports up to 2012 open in a new tab, but 2013 downloads instead.
This leads me to believe that there is some meta-data property of the PDF itself that tells it how to open, and that, in this case, the 2013 PDF was created using different settings.
Apparently, the PDF was saved out to PDF from InDesign.
Does anyone have any insight?
Problem solved. There was simply an error in the string (like an extra period) that references the attachment such that it couldn't tell it was a PDF. Fixing the reference fixed the problem.