Is there any way to slice an SVG . I mean any already available lib . I need to implement this slicing component in Java.
I mean , I have single SVG file and based rulers/scales i choose graphically , I want to slice the single SVG into different SVG files.
Hope I am clear
Yes, although, you'd think this was classified information - or just simply impossible - based on how hard it is to find this basic fact....
Apparently, all you need to do is reference the viewBox from a URI "fragment".. I have confirmed, it does indeed work. Take the following example... The lesson of the story, in case you miss it, is... image.svg#svgView(viewBox(100,100,100,100))
image.svg is defined as <svg .... viewBox="0,0,400,400" width="400" height="400">
http://example.com/image.svg
http://example.com/image.svg#svgView(viewBox(100,100,100,100))
If you're working with SVG in Java, the Batik SVG Toolkit will provide a lot of functionality (I confess I don't know what you mean by slicing, however)
All you have to do is edit the <svg> tag. Edit width and height, set the viewBox attribute on the main svg element to the rectangle you want, render, repeat.
Each svg will contain all the data from the original but will only display the part of the drawing inside the viewBox. See http://dingoskidneys.com/~dholth/svg/
viewbox = "x y width height"
If your goal in slicing the svg was to create 'hot links' or an image map .. this is how to do it!
Simply slice the svg in Illustrator then when saving ('Save As') the svg, be sure to nab the code ('SVG Code' at bottom) which will include slice references such as:
<rect id="_x3C_Slice_x3E__1_" x="88" y="22.5" class="yj4" width="227" height="88"/>
which are LINKABLE by surrounding with a link tag:
<rect id="_x3C_Slice_x3E__1_" x="88" y="22.5" class="yj4" width="227" height="88"/>
Hope this helps.
Related
I have a bunch of PDF's which I have merged by this point in the code. At the beginning of the merged PDF I have a contents page which links to said PDF's respectively. These pdfAction.gotoLocalPage links sometimes don't work correctly and instead jump to between the bottom of the page and the next, however the PDF bookmark hyperlinks always work fine.
The code for the bookmark:
int pageToLinkTo=prevSectionPageCount+sectionPageCount+numberOfIndexPages+currentIndexPage+1;
document.put("Title", documentName);
document.put("Action", "GoTo");
document.put("Page",String.format("%d Fit", pageToLinkTo));
The code for the contents page link:
PdfAction action = PdfAction.gotoLocalPage(pageToLinkTo, new PdfDestination(PdfDestination.FIT,-1,-1,0), stamper.getWriter());
chunk.setAction(action);
Both of these evaluate to the same page. Could there be something wrong with the source PDF files? The only notable difference between the links which do work and the links that jump to the wrong place, is that the source PDF's have a slightly different page size (0.1 of an inch different).
Any help would be appreciated!
Thanks
I see that you create your destination like this:
new PdfDestination(PdfDestination.FIT,-1,-1,0)
This is a strange way to create a destination so that the page is displayed to fit the viewer window. Please take a look at The ABC of PDF with iText. The book isn't finished yet, but it's free and in table 3.7, you can see which destinations take how many parameters.
If you want the page to fit the viewer window, you don't need any extra parameters:
new PdfDestination(PdfDestination.FIT)
There is a destination that takes three extra parameters:
new PdfDestination(PdfDestination.XYZ, x, y, z)
In this case x and y are coordinates and z is the zoom factor. I think that you are confusing the PDF viewer by adding x, y and z parameters when all you want it to fit the page in the viewer window.
So, say I have two images, one which is a .bmp of some text and another which is a bufferedImage, how would I go about finding if the .bmp is inside the bufferedImage?
Im really lost on how to find an image within an image, a color is easier as its just one thing to search for but an image seems much harder...
One Solution to this Problem is "Template Matching".
This means sliding your Template (the image you want to find) over the Image (you want to search in) and at every Position compare the similiarity of all Pixels.
The Position of your Template in the Image is at the Maximum this procedure returned.
As suggested in the comments you can use OpenCV for this Task which support Template Matching.
I have attempted to find this answer (on Google and Stackoverflow) without success, but I'm sure it must have been asked before, so feel free to point me onwards to the answer if it exists.
Currently, I have a Java servlet that loads a PNG from disk into a BufferedImage, writes text on top of it, and then streams back the byte[] to the client.
My desire is to replace the PNG-from-disk with a rendered SVG path, from a collection of icon-paths that I've source online (e.g. "M21.871,9.814 15.684,16.001 21.871,22.188 18.335,25.725 8.612,16.001 18.335,6.276z" and "M22.727,18.242L4.792,27.208l8.966-8.966l-4.483-4.484l17.933-8.966l-8.966,8.966L22.727,18.242z").
I've come across Batik and SVG Salamander, but am struggling to understand how I would accomplish the above with either of them, most specifically, how to render the SVG path into the BufferedImage. I need to be able to specify (a) the dimensions of the image, (b) the fill-color and (c) & (d) the stroke width and color.
Here is an example that basically uses the Transcoder API.
I'm making an app for a real life game. The app needs to use a custom map that uses scalar vector graphics (SVG). The map I'm using provides very accurate detail, such as door locations inside a building; This is why i'm using SVG instead of the maps api.
Now I know there is an api for svg (http://code.google.com/p/svg-android/), so here is what I need help with:
1) The image must be zoomable. The only reason for using the SVG graphics is for clean zooming.
2) I need to place dynamic markers (images, or buttons w/ numbers) on the SVG image. An SQL table has an image, and a location. The table will be updated, added to, and removed from. I need to place said images on top of the SVG image, and possibly each other. Coordinates and math aside, how do I place the images on top of each other (can't use XML since they aren't static).
I need to use Android 2.2
The default browser in 2.2 doesn't support SVG. You can target Opera Mobile, which supports SVG and other new technology much better, but it won't be a native app.
The first step I'd try would be designing the interface in Inkscape, then you can reference the .svg file from HTML and move elements with javascript.
flying-pigs,
If i understand your question, you want to display a SVG like that on your phone ? So you can display user location on that map.
I describe a working solution here : Add SVG Tile Provider
Let me know if you have other questions about GG Map
I have searched over bunch of sites, and I was unable to find solution for my problem.
This is the problem:
I am making PDF's in Java using iText library.
Everything works fine except one thing.
Transparent PNG images have black/gray border around non-transparent area.
I didn't set any borders in code, and actually I have tried to remove them (with no luck).
Can someone help me how to solve this problem?
The closest answer what I have found is: Resizing an image in asp.net without losing the image quality
But I cannot (don't know) interpret this code in Java.
My code is pretty big to copy/paste, but these are steps:
create document
load image from given path
manipulate image (resize, rotate, positioning)
add image to current page
save pdf file
This is what I have tried also:
http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2157267
http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2330200
I have tried more than those 2, but I didn't bookmarked them (none of them worked)
Thanks in advance
UPDATE: I forgot to mention that my original pictures don't have border. Border is created somehow by iText. I initially thought that it was bug, but since iText 5.0.2 this problem remained so now I doubt that is bug (I am currently using 5.1.3).
UPDATE 2 I forgot to add this link: http://itext-general.2136553.n4.nabble.com/template/NamlServlet.jtp?macro=print_post&node=2157261
Here is presented VB script that works, but I cannot convert to Java code (it still draws black border), so can someone help me at least with this to convert good?
You could use the java BufferedImage method, getSubImage(x, y, w, h) which allows you to crop a sub image out of an existing image. That way you could cut out the edges.
See here: Class BufferedImage