Looking for tips/tools to make this happen (using PDF/Velocity Templates/Java):
I have an image that has large dimension (4000 x 2000) and that image is obviously not viewable in a PDF. I can modify the size of the image to fit into the PDF.
But what I want to do is to view the actual size of the image in the PDF. I want to be able to scroll the image from left to right.
How can I keep the true size of the image, without destroying the set container size of the PDF?
That's not quite a basic PDF feature, but it might be implementable using some embedded scripts inside the PDF, assuming that the user has a PDF viewer capable of running scripts.
Now, a PDF is not supposed to be used as a dynamic document where you can scroll. How would that work on paper after printing? If you want scrollable documents, then you should stick to HTML. I strongly advise you not to try to do this.
If, however, you still want to go down this route, then here are a couple of suggestions:
As I said, you could do it with embedded JavaScript, but then it depends on how you're generating the PDF: FOP, iText, another PDF writer library, or just plain println concatenation, since few libraries support embedding JavaScript.
You could just make the image fit into the page, but keep its original resolution, so that you end up with a high resolution page that the user can zoom in and scroll. This way you leave the scrolling to the PDF viewer itself, you'll just have to let the user know that the image has a higher resolution and should be magnified. And frankly 4000px isn't that large, it's not even enough to keep up with today's standard printer DPIs.
Related
Here's the current problem:
I have an XFA Form created by a 3rd party and I would like to use it as is.
I was able generate the PDF with filled fields by:
a) Extracting the XML via Acrobat Pro
b) filling the fields within the XML and calling
XfaForm xfa = form.getXfa();
xfa.fillXfaForm(new FileInputStream(XML));
What I'm trying to do is just stamp an image/watermark over the 2nd page which has a form w/multiple fields. The "DRAFT" png image I'm stamping has a transparent background so if the overlay works, the image background should make the underlay appear and look like that the image text is sitting on top of the pdf page.
What I wanted to accomplish would have been trivial if this was not an XFA form. I would just use iText's pdfStamper and stamp this transparent PNG over the 2nd page, but since I'm now confined to use Adobe LiveCycle Designer, I noticed that this once trivial task in the non XFA document isn't so trivial within XFA.
From a previous post, I learned that I couldn't mix technologies together. I had to choose between nonXFA (AcroForms) vs XFA (built by Adobe LiveCycle Designer). Basically, I couldn't do a fillXFA then use the stamper, so I had to figure out how to do this using XFA.
I've tried the following steps as a static PDF and a dynamic PDF....it didn't make a difference what type the PDF was.
1) Within Adobe LiveCycle Designer, I went to the second page of the source PDF and defined 2 image fields.
overlay1 - this will span the top portion width of the page which has text
content underneath
overlay2 - this will span the lower portion width of the page which has text
content underneath
2) As a test...I selected an image for overlay1 which has a transparent background and it's
foreground background as DRAFT
At design time...the DRAFT transparency image worked and it was laid on top of the content correctly
for the imageField: overlay1.
I saved the modified XFA-based PDF, opened it up in Acrobat Pro, and exported the XFA XML structure.
I verified that overlay1 had the DRAFT image as a base64 encoded string.
<overlay1 xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:contentType="image/png"
>iVBORw0KGgoAAAANSUhEUgAACWAAAAJYCAYAAADmY91UAAAACXBIWXMAAC4jAAAuIwF4pT92AABH
.......
.......
3) When I took the same base 64 string and only entered it's content within overlay2 and rendered it through the fillXFA method...the image was a black box instead.
I also opened the file in Acrobat Pro, then double clicked on the imageField area, selected the transparent image, and it still showed up as a black box.
I repeated the previous step with an image w/no transparency and it's rectangular white background
overlayed everything underneath it.
4) I went ahead and made another image...one that didn't have any transparency.
DRAFT with no transparency and it's background is white.
I had it encoded in base64 format.
I was able to place it within both overlay1 & overlay2 image fields without any problems.
The new problem is that the white background of the DRAFT images covered everything behind it.
Why did the initial transparent png work during the Adobe LifeCycle Design (design time) and after
a fillXFA call it shows up as a black box? But if I change the image to not use transparency at
all...everything works?
Does XFA not support transparent images for image fields during an xfa fill? Remember, it worked during
design time when I told Adobe LiveCycle designer to use this transparent png for this field.
I'm basically trying to create 2 image watermarks over a specific page within an XFA pdf.
My current backup plan is to flatten the PDF (take off the XFA) and putting back all the fields back on the form using Acrobat Pro and filling it using the standard PDF itext calls and using a stamper (this is going to be tedious since there's a bunch of fields). But I'd like to know if anyone ever had to do the same w/an XFA PDF form before I look at option B.
So I replaced the same PNG transparent image with a GIF transparent image. The GIF image encoded in base64 worked. I can create a new GIF file w/transparency, encode it in base64, and replace the previous one & it still worked. Looks like a bug with PNG rendering within the XFA form
Currently we have a requirement where we have an image depicting the blueprint of the mall (red specifies the booked up areas and white specifies the available areas) and the image is available in a raster (JPEG) format.
We would like to drag and drop some icons onto the available areas of the image (in white). There should also be zoom in and zoom out functionality to be given for the above image as well
Since the JPEG has a lossy scaling, zooming after a certain limit can result in a jagged image. One proposed solution is to convert the image to SVG (Scalable Vector graphics).
Going with the expanded form of SVG, it simply tells us that image is:
s=>scalable (i.e. you can zoom to any level without compromising the quality)
v=>vectorized (i.e co-ordinates are available)
So by simply looking at the XML format of the image, we can predict whether to allow dropping an object at fill=red or fill=white where red and white are the two colors in the image. This might not be appropriate solution, but I'm just guessing it this way
Now the problems I see with this approach is:
Converting an image with some open source tool (InkSpace) - if we trace it with ink-space, which uses portace inside it to trace the image, it can handle only black and white colors.
Note-: Most of the tools comes with some license.
Problem with inkspace is that it embeds the image into the SVG map and does not create the co-ordinates. If you trace it with inkspace, it only creates the outline of the image.
Converting it with some online utility - Not recommended in our case, but doing so results in a large size of the SVG image. For a 700 KB file, the SVG generated is about 39 MB, which when opened up on a browser crashes the browser.
Most of the time when the image is converted to an SVG, it becomes way too large a big factor to worry about. There are utilities available like Gzip to compress files, but this is a two way route - first you convert, then you compress.
Using delinate (which employs a portace and autotrace engines in it) - the quality of the image produced is not good.
Using Java code - Again the quality suffers. Java graphics are not fully developed to handle the conversion (size is again way too large)
Converting the image to PDF, then to SVG - this also embeds the image into the SVG file, which is useless as no co-ordinates are available
Does anybody got any idea on this ,how to deal with this situation?,Can we handle the drag and drop on raster(jpeg,png...etc) images itself?
Thanks
Dishant Anand
I'm currently working with JavaFX 2.2 und Batik. I have an application with a pane on which you can drag multiple SVG pictures.
This is all working out, and the svg code of each picture is stored in each object, so I can get that, too.
However now I want to take a "screenshot" of this pane and its current SVG-children and export it as an svg-file.
To me, there are two possibilities:
1) export it with the takeSnapshot() function as a .png-file and convert it to svg
2) or create a new svg-file from all the small svg-files with paying attention to the position of each svg-picture-object.
Is the latter possible? Or does anyone know, whether batik can do this png to svg conversion?
Thanks a lot for your help! :)
With approach 1) you would loose all vector information and end up effectively with a bitmap. The result would typically be larger (in terms of disk space) and loose quality when it is scaled.
So approach 2) is clearly better. Batik implements SVG DOM so that manipulation of the individual documents should not be to difficult.
I'm working on application in Java that will maintain database of song lyrics in plain text and print out some songbooks/chordbooks(that is create PDF file from selected songs). I was planing that the Java application will generate source code for pdflatex and after compiling this source user will get PDF file.
Lately I've run into a lot of problems because of latex limitation: fixed memory size (some pictures will also be drawn to PDF) - error when exceeded, no way to query end of line or and of page dynamically, it's very hard to override latex placement algorithm in a complex way,... see also some my other questions regarding latex. I come to conclusion that latex is not good option for automated PDF generation.
So I need replacement. I need to be able to typeset:
Chords over lyrics when the lyrics are in variable char width so I need to be able to measure text width
Chord diagrams that means I'll have to draw quite complex pictures
Each song on separate double page
Different fonts etc.
Thanks for all answers
Here are some PDF open source APIs
http://java-source.net/open-source/pdf-libraries
This has been asked many time, You might want to look at this post
IText is a free library which offers lots of capabilities for creating PDFs programmatically.
Rather than try to manage/calculate the complexities of the desired layout, you could try Docmosis. It will let you layout a document as a template using doc or odt formats. This means if you could make a doc or odt look like you want, you can turn it into a template and get Docmosis to render it as a PDF. Text and images can be placed inside or outside tables which makes layout fairly easy to manage.
ConTeXt is another TeX system, but it is easier to control the layout than with LaTeX. For drawing you could use PGF/TikZ or MetaPost. Support for both is available in ConTeXt. With ConTeXt's built in Lua scripting you could draw the chords automatically, assuming you have them stored in some sort of data structure.
why not just use lilypond with latex? it's meant for typesetting music.
We are currently leveraging a third party tool to convert pdf files into gifs and displaying them in the browser. We have been adjusting the DPI of these images so that when printed they will look as close as possible to what the original pdf looked like. We've found that at least a setting of 300 DPI matches roughly the clarity of what the pdf will display when printed. However if we try to load a GIF image with a setting of 300 DPI into the browser using HTML the image is very large and causes scrolling. I was able to get around it by setting the height and width of the image tag, however when/if the margins on the Print preferences changes the image will be chopped when printed. If we print the images as is through an image viewer they print fine.
So that leads me to my question, is there some other third party tool that we could call from a webpage that would load these images and give printing capabilities through some sort of a Java applet?
I recommend to embed the PDF file inside your HTML page, so if you print, you have full capatibilies, and you don't need to "duplicate" que information.
If you have to use GIF images (for any reason), you could have two views, one small, wihout scrolls, for viewing the HTML page, and other only with the GIF image. When you click "Print" in the HTML page, you see a kind of "Print preview", larger, with scrolls or whatever.
Hope it helps.