I'm looking to generate a pdf from an existing pdf "template". For example, the pdf "template" would have the, text, fields, and layout -- all that would be left to do is fill in "fields" with data.
I would like to populate these fields with the appropriate data from a mongo collection, and generate a new pdf from it.
I am looking at the pascoual/meteor-pdfkit package, but I only read about how to generate a pdf from scratch. Also, I reviewed http://pdfkit.org/ but found no examples of my approach.
Is the above possible with an existing meteor pdf package? What's the best way to go about this?
For example, the following is part of a pdf document, the "fields" need to be populated with data I get from a collection:
UPDATE: I'm looking into using pdftk server: https://www.pdflabs.com/tools/pdftk-server/ (the command line) to do form fill pdf (fdf). This seems to do what I want, and runs on all platforms.
Ended up using FDFs (actually XFDFs) to do the PDF form fills. PDFtk server was the tool I ended up using.
Related
I'm using NodeJS to do an app that finds and replaces a text in a pdf. I have found some approaches:
Using some npm package, like pdfReader, that converts pdf to json. So I get the text and replaces it with what I want. The problem it's convert the output back to pdf.
The possible solution for the first item it's to convert the PDF to HTML, edit the HTML and convert it back to pdf. But most of the tutorials using NodeJS it's about convert HTML to PDF, not PDF to HTML.
Any solutions for this problem?
Update
I ended up using PDFKit to create the pdf files that i need. In my case, this solution don't to cover all the possibles. But if you have to find a word and replace it in an unpredictable pdf file, maybe this problem has no solution in nodeJS. The PDFKit lib has an open issue for this feature.
Look at this approach how to export json data to pdf file with specify format with Nodejs?. Basically uses your idea. Convert PDF to JSON and then render the JSON in html, then convert the HTML to pdf.
I have a requirement wherein we have to display a chart and few parameters (date, name etc) inside a pdf file.
The user should be able to modify the chart depending upon the data selected by the user.
I have seen some examples https://www.youtube.com/watch?v=Z5bdBeFwNCU but not sure how these are getting generated.
Any pointer is highly appreciated.
Also I am a java script developer so if there is any solution in JS It would be easier for me to follow
You can look into the docmentation of the creators (Adobe):
Using JavaScript with PDF files - Tutorials about process.
Javascript API reference for PDF format - a PDF document listing all commands.
I did a few projects where charts/diagrams are created on the fly, based on user entries. For that, I used a combination of form fields and annotations, whose parameters are calculated using Acrobat JavaScript.
There is also an undocumented function in Acrobat JavaScript which allows to create the icon for button form fields.
As the actual approach depends a lot on the kind of information and graphs, one would have to look at what has to be accomplished. Feel free to contact me in private, if there is some interest. It might be worthwhile to look at "make or buy"…
I am attempting to have a button on a form that will launch file explorer for the user to select pdf files to insert into form.
The insertPages script will insert pages from a specific cPath, but I need the user to be able to select the pages to insert, as they will be different from case to case. Is there a way to accomplish this using javascript?
I am using Bluebeam, which is very similar to Acrobat. I have created several templates and javascript code using the Acrobat API Reference, and thus far the Bluebeam engine appears to operate nearly identically. In a perfect world, the button would launch the "Insert Pages" menu in Bluebeam.
Thanks in advance for the help!!
If this were Acrobat, I'd use app.browseForDoc(). The returned object has three properties...
cFS - A string containing the resulting file system name for the chosen file.
cPath - A string containing the resulting path for the chosen file.
cURL - A string containing the resulting URL for the chosen file.
Get the full path to the file from there then use insertPages.
In Acrobat, it can only be run in a Privileged context. I'm not sure if it will work the same way in BlueBeam though they have done a fairly good job of duplicating the form field related JavaScripts.
I am new to web dev and I have a text file that I created using C# to collect some data from a website. Now I want to use that data to make graphs or some way to show the info on a website. Is it possible to use I/O in javascript or what is my best option here? Thanks in advance.
You have several options at your disposal:
Use a server-side technology (like ASP.Net, Node.js etc) to load, parse and display the file contents as HTML
Put the file on a web server and use AJAX to load and parse it. As #Quantastical suggested in his comment, convert the file to JSON forma for easir handling in Javascript.
Have the original program save the file in HTML format instead of text, and serve that page. You could just serve the txt file as is, but the user experience would be horrible.
Probably option 1 makes the most sense, with a combination of 1 + 2 to achieve some dynamic behavior the most recommended.
If you are working in C# and ASP then one option is to render the html from the server without need for javascript.
In C# the System.IO namespace gives access to the File object.
String thetext = File.ReadAllText(fileName);
or
String[] thetextLines = File.ReadAllLines(fileName);
or
If you have JSON or Xml in the file then you can also read and deserialize into an object for easier use.
When you have the text you can create the ASP/HTML elements with the data. A crude example would be:
HtmlGenericControl label = new HtmlGenericControl("div");
label.InnerHTML = theText;
Page.Controls.Add(label);
There are also HTMLEncode and HTMLDecode methods if you need them.
Of course that is a really crude example of loading the text at server and then adding Html to the Asp Page. Your question doesn't say where you want this processing to happen. Javascript might be better or a combination or C# and javascript.
Lastly to resolve a physical file path from a virtual path you can use HttpContext.Current.Server.MapPath(virtualPath). A physical path is required to use the File methods shown above.
I'm a new french stackoverflow user, so sorry for my misspelling.
I would like to know how to automatically merge writable/alterable PDF with data file(XML, TXT or FDF).
I have seen that Adobe Acrobat Pro could import Data, but in the wizard action, I've not found "import" choice to make it automatic. The wizard offers JavaScript add but i don't find any PDF manipulation line code JS.
Does JavaScript is the solution for my issue ?
Or do you have some alternative ?
Thx for reading.
You can use the COM of Acrobat or PDFCreator to do it. There is a lot of example here (And in French):
http://www.developpez.net/forums/d431662/logiciels/microsoft-office/excel/contribuez/excel-word-pdf-adobe-acrobat-pro-pdfcreator/
With "Wizard", you are using the Actions Wizard?
If so, this is understandable. However, there is the Acrobat JavaScript function which would import an FDF (or a few other data formats); have a closer look at the importAnFDF() method in the Acrobat JavaScript documentation (which is part of the Acrobat SDK, downloadable from the Adobe website).
There are other approaches, by importing a tab-delimited file as File Attachment (aka Data Object), and then interpret this file to create your data table, and then use Acrobat JavaScript to fill out the form, save or print it, and so on.
A third method would be using Template pages in the PDF, craft your FDF so that it supports Templates, import it into the base document and then wait until it has spawned all the pages. You then have one big document containing all the filled forms.
Finally, if you have a higher volume, you will be better off using a server-side fill-in tool, such as FDFMerge by Appligent.