I am trying to create an interface to allow easy editing of PDFs like VuePDF in an application I am building. This is not core to the application and will only be used by the admin.
I was wondering if there was a per-built stack for editing PDFs in the browser window?
Basically the admin user needs to black-out private data, like names and addresses.
If there is not currently a solution I was thinking of some like:
Using ImageMagik to create JPEG version of each page
Using the canvas element to add black marks to the image
Recording the location of top-left and bottom right of each black mark
Sending back the coordinates and adding black rectangles to the original PDF
Is that correct?
If you draw over the PDF, the data will still be there in the PDF and easy to extract. I wrote a blog article explaining the issue at http://www.jpedal.org/PDFblog/?p=553
You need to replace the text in the PDF command stream as well.
Related
I would like to know if it is possible to load a PDF and edit it.
The PDF is a brochure with few pages, i would like to put in few images from my database and save it.
Thank you
You can import pages of an existing PDF document with FPDI. After that you can place the images on top of them with the standard Image() method of FPDF.
Editing a PDF is very difficult programmatically, especially if it wasn't programmatically generated.
A better option would be to make your source file an HTML file, then make your edits to the HTML and convert it to PDF.
If this is a one-time task, it would be easiest to open the document in Acrobat (Pro), and exchange the images using the Edit text and Images tool.
Another way with Acrobat would be creating a Button form field over the image to be replaced (transparent border, transparent background, no action). Then you import the new image as icon, and flatten the page afterwards.
I'm using regular imagefields on various content types in a Drupal 7 social website (and also on the user profile pictures via http://drupal.org/project/imagecache_profiles). For cropping I'm using http://drupal.org/project/imagecrop as an image style effect.
I would like to replace the original image with the one generated from the imagecrop style. How do you replace the original image from a user (the one that gets used for subsequent image styles when you say call it in views) with one that is created from an image style effect?
I'm not sure the best way to approach this problem, which is why I posted question.
To make sure I'm being clear -
A User uploads a large image (say 2,000 pixels by 1300 pixels) via a regular imagefield.
Using image styles, I perform some effects (specifically javascript crop, but this could be generic) and then replace the original image with the one generated from the image style.
All additional image styles (different sizes etc) use the new original images and are derived from it.
I think this can be done easily using a custom module and they must have used something like the image editor project - See drupal.org/project/imageeditor, just not sure what hooks to use or how to jump in on this. Any advice, tips or direction would be great.
Check module - Original image with style
I believe you can address your problem by making changes under the display settings for your field:
/admin/structure/types/manage/[your content type machine name here]/display
Image this scenario:
There is a picture locally in my server, where a sketch is displayed, and there is a "blank hole" area on it.
Then, a user can upload another picture to my server.
What i'm trying to achieve is this:
After image upload is finished, the first image (the one with the "hole") is displayed, and behind it is displayed the user's photo, so that you can see it through the "blank hole" area of the first photo.
Then the user can move his picture (drag & drop style) so he can choose which area of it is visible through the "blank hole".
Then i would like to save the result - by merging the 2 photos or keeping the position of the user's picture in a db so i can display it again later.
(Something like this more or less)
What kind of technollogy should i look for? I'd guess javascript(for the drag & drop) or html5 or php(for merging the photo)?
Are there any libraries that i can use?
I hope my explanation isn't too messy, i didn't even know how to google for it.
I don't know if there are better solutions (and I suspect there are), but I suspect all of this can be done with not too much trouble. Here's a rundown of one way to approach the problem:
Use a JavaScript-powered "upload widget" such as uploadify to enable your user to upload "his" image to the server. The server will do some processing on the image (e.g. resize and crop to suitable dimensions) and save it using e.g. PHP's gd library. It will return a URL to the "prepared" image back to the browser -- all of this through AJAX.
The browser then has a URL to the user's image, so using more Javascript you can dynamically add an element that displays it inside the page and allow the user to move it around with e.g. jQuery draggable. Compositing the draggable image behind your static content (the image with the "hole") is a detail you will have to take care of using a combination of HTML, CSS and again Javascript.
When the user is done, use an AJAX call (e.g. again jQuery) to inform the server of the image's positioning (this will be available through the facilities of the Javascipt framework you have selected). The server can then "compose" the two images together (gd or something equivalent once more) and return to the browser a URL through which the final product can be accessed.
Of course there are lots of details to take care of here, but knowing exactly what the plan is should help you get started.
Have a look at the PHP GD extension. If it's installed, it's pretty easy to have an image (with a transparent center) to be merged on top of a second image that a user would upload.
Have a look at http://php.net/manual/en/function.imagecopymerge.php
Ok to get you started, yes use a JavaScript drag and drop module for the placing of the image. You can record the x /y cordinates relative to the container. Do the image merging with a PHP image library / Class. Something like this : http://www.phpclasses.org/package/3930-PHP-Generate-an-image-from-the-combination-of-2-images.html
Normally, pdf files can be edited by applications like Adobe Acrobat Writer. And when we open the pdf files in applications like adobe acrobat reader, we can select the contents. I need the codes that can create the pdf file and make it's content uneditable and users can't select the contents.
Please help me out with this.
You can render text and overlay an image. I am not sure whether this will work - viewer applications may allow the text to be selected.
If you render the text as watermark annotations, then that content will not be selectable.
You could encrypt the document and set an empty string as the user password but a full string as the owner password document. This will allow anyone to open the document without entering a password. To prevent content selection, you need to specify deny "content selection" user permission.
Our company Gnostice has PDF components for Java, .NET, and Delphi/C++Builder platforms. All of them can render text and images, create watermark annotations, encrypt PDF document, and also specify usage permissions.
you can use pdf password secure http://luxsci.com/blog/how-secure-are-password-protected-files.html.
On development enviroment using php, i have no idea how to implement it, but it helps... i guess if you convert all your text to image, they never could copy that.
Use this link to know about creating a PDF file using PHP dynamically. http://www.devarticles.com/c/a/PHP/Use-PHP-to-Create-Dynamic-pdf-Files/ In the properties, you can make it read-only.
Save the PDF file as an image. Then create a PDF of that image. If the PDF is multiple pages, you may want to consider saving it in a multi-page image format such as a tiff. Otherwise you will end up with 1 image per page if using say, the jpeg format and then have to combine them into one PDF Document. I do this with Services Agreements all the time.
This question is a bit open at the moment as I'm not sure the idea is even possible.
So far I've loaded an image from a url, and then used jQuery UI draggable feature to allow the user to drag html text (which has been replaced using cufon font replacement) over the top of the image.
The major step (which is what my question relates to) is being able to take the image and text layered over the top of the image, and save the result, either to the server, or potentially offer the option to save the altered image to the user's HD, or what would also be useful is to upload to facebook using the facebook API, but this is something I know is possible.
It all hangs on whether it's even possible to achieve the first step, which is to save the image and layered text as a combined image?
I wonder if there is a PHP/jQuery solution that would allow me to do this?
My suggestion would be to have an internal URL that outputs the final image using jQuery and PHP, then take a screenshot using webkit2png of that page. You should know the dimensions etc., so you'll be able to crop down the resulting screenshot to just the region you're looking for.