Generating online PDF with Parameters from URL - javascript

I have a form PDF set up with one field for their name (it is essentially a certificate of a kind). We want this to be automated so for example, www.website.com/file.pdf?Name=Bob and it'll insert 'Bob' into the relevant field. I have tried Javascript at document level but it only works in IE and we need it to work across most browsers especially Chrome and Firefox.
Ideally, we'd like just one PDF to exist, to link that with a parameter in the URL to send to someone and they can download the PDF without filling it in. We're issuing quite a few a day,linking the URL in a separate email (but we're phasing into SQL Server and a 3rd party application to make these emails automated hence the need for this to be automated)
I've tried dozens of websites that fills PDF forms or the like but none result in a single PDF with a URL that can be parsed into the PDF form field. Am I missing any websites that does so or is there an easier way to allow a PDF to do this and host it on my own?
Thanks

You can create a server-side script that parses the URL and dynamically generates the PDF form fields with parsed URL parameters.
Here is an example of a ASP.NET generic handler that creates the PDF based on what is submitted in the form. You can instead create PDFs based on values obtained from the URL.
http://www.gnostice.com/nl_article.asp?id=315&t=An_ASP_NET_handler_to_create_a_personalized_PDF_form_that_it_that_will_mail_itself_to_an_e_mail_address
You can use any PDF library for this, not necessarily the one used in the article.
DISCLAIMER: I work for Gnostice.

You can get the URL parameters using this.path in the PDF. This property will return the file path of the document, but it will include any parameters that you pass along with it. You can use the path to extract the parameters that you need. So far, this method works on Chrome and IE. Firefox doesn't support filling PDF forms in the browser.

Related

Search for text embed

I use embed tag to display 1 pdf file, how do I make when I press Ctrl + F it only searches the pdf file, not the current page. I tried searching on google but no desired result.
You will not find a single answer on google they use two methods themselves.
Generally it should not be possible unless the embedment has control of the pdf search function, You need to understand that a binary pdf viewer embedded in a html page cannot be controlled by the html page, it can pass options like .pdf#search=words during loading. That usually works with Firefox but not Chrome derivatives, but that's as far as cross application security should allow. The best you can target is combine Page and part strings, like this:-
So there are frame controls to assist user in some cases, but not accessible from HTML, nor can the embed see the surrounding HTML.
A Firefox alternative secure Plugin that will ignore both external and internal PDF JavaScript's
Chromium Edge where there is no external control but the PDF may perhaps have scripting allowed.

How to edit pdf stored in a server by a webapp client?

The use case of this problem is very simple but i struggle to find a good solution for it.
I want to allow my users (through a webapp) fill some pdf files stored in server (pdf with forms, which begin more and more popular).
Actually, app like chrome or acrobat reader are able to fill them perfectly whe its open locally.
I already allow this functionnality for docx and xlsx files, for that i use Webdav and the custom protocols ms-word ad ms-excel. It works perfectly.
For pdf, I didnt found equivalent. Its look the mains pdf reader/editor doesn't implement this protocol. Whe we open distant file with these tools, they failed for write permission when save or they try to save the file locally) .
Another option i take a look was the new file system access api (https://web.dev/file-system-access/). But again i wasn't able to make it working properly. The main problem here is how we can edit the file.? Im able with this api to dowload the file locally and keep the filehandler to retrieve the updates, but i blocked on how i can edit the file ? like an option on the fileHandler to say "Open this file with default editor on the OS". this would be perfect. But for now to edit the file i have to manually open it on the eplorer. i can't ask my end user to do that there is too many risk they edit the wrong file.
Another option on the table is the different javascript library for editing PDF, but these last one looks all very expensive, usually very heavy on the client side, with advanced features definitively i don't need. I just want to fill the forms and retrieve the pdf completed. So i would like to avoid this option.
Last option i take a look, i already use pdf.js (from mozilla) and pdf-lib.js in my app for some drawing features. I was thinking
rendering the pdf with pdf.js
retrieve all the forms fields (id, type, size, position) of the pdf with pdf-lib
generate html input write on the top of the pdf with the informations given by pdf-lib
i let the users fill the input and click on a save button whe he finished
on the save, i edit my pdf with pdf lib, i set the value of all my forms fields by taking value of the corresponding html input, and i retrieved the pdf updated.
This solution look for me the more "feasible". But im afraid of the volume of development, on how it will render, deal with zoom, rotation, etc. i would like to not have my custom solution.
I precise my webapp target chrome so it make me crazy to not be able to use the chrome pdf viewer/editor to do what i want.
PS : i struggle to post this question on stackoverflow. the previous one was deleted witout i had precise reasons. i try to be more specific on this one, but please if its such a dumb question, please answer it
I feel your pain, this is currently not possible. Adobe acrobat can open PDFs from webdav locations (simply call acrobat.exe and pass in the WebDAV UNC and it will work) but there is no way to trigger this from the browser.
If you are able to deploy software to your customers machines, you could create a custom URL scheme to do this...

Add barcode to PDF

How can I add PDF417 2-D barcode (as an image) to a Acroform PDF?
I have a process in place where I populate a PDF "templates" with data using a XFDF file that I build server side. Staying in the same workflow, I'd like to either use XFDF or FDF files to add a barcode to the PDF.
I'm using full-stack JavaScript environment, where the Nodejs environment runs server side. I'm using PDFTK Server (JavaScript on the server calling out to a PDFTK.exe).
I can use any tool/technique within my technology stack (Nodejs/Javascript). Also, this solution must work server side only.
The PDF "template" currently uses a Adobe Lifecycle "Paper Forms Barcode" control for the barcode. When we fill this PDF form out with data manually, the XFA script embedded within the PDF automatically populates the "Paper Forms Barcode" control with the PDF417 barcode.
When I run PDFTK Server's form fill command to populate the PDF with the XFDF data I build server side, I believe the XFA (and hence any intelligence behind the "Paper Forms Barcode" control) is automatically removed from the resulting output PDF.
I can optionally remove the "Paper Forms Barcode" control and use any other control available.
pdf417-js seems to get my close to building a PDF417 barcode, but it's client side. And also, I can't see a way to build an image output.
From my research it seems I might need to remove the existing "Paper Forms Barcode" control and add an image somehow to the PDF. Then possibly use PDFTK to somehow merge a PDF that I have filled with data from my existing process with another PDF that simply has the barcode.
I never seen an example of XFDF or FDF inserting an image into the PDF. I've read where one can dynamically add an image (icon) to a button control via FDF (I've found no hard example of this), but haven't been able to get anything working.
FDF does support inserting images as icons into Button fields. I am, however, not sure whether XFDF does it. You may have to convert the image into PDF format.
For an industrial-strength use, you might consider dedicated tools, such as FDFMerge by Appligent (which would also allow to selectively flatten the barcode field (and others too)).
Both FDF and XFDF support adding images to PDF pages. Some background first, Adobe Acrobat and Reader can submit form data as well as comment annotations. It can also import form data as well as comment annotations. Therefore, FDF and XFDF can represent both form data and comment annotations.
Images can be added to a PDF via FDF or XFDF by representing them as a stamp annotation. Acrobat can certainly import these but most server tools don't know about the <annots> element of the XFDF and even if they did, they generally can't create an annotation appearance based on the annotation properties. One can; the Datalogics PDF Java Toolkit is capable of importing XFDF with stamp annotations.

Safari method of getting full path to a desktop file that is dragged to a browser window [duplicate]

I am trying to allow users to upload pictures to the server.
I am trying to create a similar system to any website that has an 'attach' file or 'upload image' feature. All I need is to get the full path of the file select by the file dialog.
I tried using this for the file dialog with no success:
<input type="file">
This method does not provide the full file path, due to security reasons. My question is how can I create a similar input dialog to websites like tinypic, photobucket, etc.. that can help users input the full file path of a given image, into an input field?
I am aware that this cannot be done using the method above for security reasons, however, I have seen this done before on various websites without any problems, I was wondering what I had to do to implement a similar file dialog that helps fill in the text, which is a full file path, of an input field?
It is not possible to get the file full path on local machine using browser and javascript.
However, as you would like to upload the file to the server, the easy possibility I see is to use html form with input type file. You will receive the file on your http server when the form is submitted.
Here is a very good url http://www.cs.tut.fi/~jkorpela/forms/file.html that explains the whole process nicely.

find pdf text in IE9 browser using selenium

In our application while clicking the link it will open the new window with secure pdf file. We want to validate that using selenium ruby. but We unable to validate this in IE9 [because there is no html/dom element]
We can perform this validation using firefox and chrome browser because there html/DOM element present for that pdf page.
Is another way to validate pdf text from browser URL?
I'm not sure this is possible. Chrome and Firefox, do, indeed render more that is actually there, usually for more powerful embedding, etc.
I can offer a solution however,
Instead of navigating to the PDF, you can validate the href of the link.
here is some pseudo-code from Java on how to accomplish the task...
String href = driver.findElement(By.cssSelector("a[href$='.pdf']")).getAttribute("href");
assertTrue(href.contains("FileName.pdf"));
From these two statements, we'll know two things:
The link is indeed taking you to a PDF file.
The PDF file, is called FileName
If the test fails in any way, that means that the link doesn't exist, or points to the wrong pdf.

Categories