SVG to PDF maintain unit size dimensions - pdf

I create a SVG image with one rectangle. Attributes width & height units in mm:
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
width="210mm"
height="297mm"
version="1.1">
<rect
style="opacity:1;fill:none;stroke:#000000;stroke-opacity:1;stroke-width:0.5"
width="100mm"
height="100mm"
x="40mm"
y="60mm" />
</svg>
Then i convert that SVG with Inkscape and also with Apache Batiks SVG Rasterizer to PDF documents and print it on paper.
In both cases, a few millimeters are missing on the printed paper. The rectangle must be 100mm x 100mm, but it is accurate 97mm x 97mm. The larger the rectangle, the more millimeters missing.
To test my printer, i create a PDF with a PDF editor (Master PDF Editor) and a rectangle of 100mm x 100mm. In this printed PDF the rectangle is very accurate 100mm x 100mm.
How do you get the millimeter from the SVG without loss of size (or profit) on paper?

Thanks to RMo.
With Master PDF Editor is all ok, also the rectangle from SVG PDF.
Now i set in my PDF reader Okular (at print dialog) the margins to 0. Super, all is OK, the rectangle prints out with 100mm x 100mm.
Master PDF Editor has as default no margins or scalings.
In Gnome Evince, the scaling in the print dialog is set to 0 and everything is fine here as well. There are no margins.

Related

pdf2image converts page with page information that is not visible in the pdf viewer

I convert PDF to image using pdf2image which is python package.
But in result, PDF page information(?), which is not visible on pdf viewer, is appeared.
How can i remove page information on PDF, not on image?
PDF file link is https://1drv.ms/b/s!Ar1AW_VI_HwvkMAOyDmQhFEKrZnRWg?e=fvWEwN
The PDF Page data/information for viewing has been constrained by a "crop box" or "trim box" which in most cases would be identical to the paper "media box" However when using crop marks for printing or display the crop box area will be smaller than the media box area.
pdf2image has a setting to cover the use of crop boxes use_cropbox=True, (normal default is False) so in your invocation you would need to set that argument/option
use_cropbox
Uses the PDF cropbox instead of the default mediabox. This is a rather dark feature that should be set to true when the module does not seem to work with your data.
However looking into the file the values have been altered from expected so a source page is defined as
<< /CropBox [ 0 0 676 855] /MediaBox [ 0 0 676 856]...
thus there would be no noticeable difference, the 1 unit is only 1/72"
But 48 pages have later additional (LaTeX ?) crop box values of
<</CropBox[32.4 32.4 643.6 823.6]... and this seems to effect the issue of the trimmed viewport.
pdfinfo filename.pdf reports the cropped area Page size: 611.2 x 791.2 pts (letter)
For that reason (there are two conflicting settings) :-
Then without a working pdf2image set-up for testing, I am not 100% confident that the use_cropbox=True setting may always work reliably.
There are other methods that might work better and Ghostscript and other python dependency applications have similar, or alternate, means to clip the image output directly on the file. Using poppler direct we could get the same default output
However if we specify -cropbox the secondary crop, in this case, will be taken into account.
pdftoppm -png -cropbox "process data sheet.pdf" output
If that did not work we would need to define the exact area using
-x <int> : x-coordinate of the crop area top left corner
-y <int> : y-coordinate of the crop area top left corner
-W <int> : width of crop area in pixels (default is 0)
-H <int> : height of crop area in pixels (default is 0)

Adobe Illustrator 19 SVG Viewbox?

We produce icons in Illustrator as SVGs and then produce font based icons with fontcustom. Out of no where, they were coming in too low. I found in the svg this odd viewBox with a negative 49 on it. How is this controlled in Illustrator? I don't want any viewbox, I just want a perfectly centered icon. I also see that it thinks that it is grouped. My only fix is to ungroup, and then set the X and Y to zero, and it works. It does put in a transform compensating to -49 on the layer. Something is causing this odd offset.
<svg version="1.1" id="Layer_1" xmlns:x="&ns_extend;" xmlns:i="&ns_ai;" xmlns:graph="&ns_graphs;"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="-49 141 512 512"
style="enable-background:new -49 141 512 512;" xml:space="preserve">
Viewbox in illustrator is based on the art board I believe and it's a pain to get it to match the artwork exactly. The easy way to zero it all out is to just highlight the object in illustrator select copy.. then go to your code editor, make a new document and paste it. It will copy the svg code with a the view box set correctly(starting at 0,0). Then just save the file as an svg and you're done.

GraphicsMagick crop PDF

I've got a 8.5x11 PDF at 300dpi. It has a single UPC label in the top left corner of the PDF. Imagine that there could be 30 labels on a 1 sheet, but we just have 1 label.
I'm trying to crop the PDF to be just the size of the 1 label. So far I've got this
gm convert -density 300 single.pdf out.pdf
Which doesn't do any cropping. When I crop to say 300x100 it makes a 20MB file with 30000 pages.
I have not a clue how to use -crop to actually crop to the correct size. I need it to be 3.5inches by 1.125 inches.
Using the following input PDF (here converted to a PNG):
the following command will crop the label:
gm wiz.pdf -crop 180x50+1+1 cropped.pdf
This label is sized 180x50 pixels.
For an 8.5x11in PDF at 300 PPI you'd have a 2450x3300 pixels PDF (which I doubt you do, but that's another question) and you'd need to use -crop 1050x337+0+0 (more exactly, 1050x337.5+0+0 -- but you cannot crop half pixels!).
Note, the +0+0 part crops the top left corner. If you need offset to the right by N pixels and to the bottom by M pixels use +N+M...
Using ImageMagick instead...
You could also use ImageMagick's convert command:
convert wiz.pdf[180x50+1+1] cropped.pdf
Comment about image sizes...
One additional comment about this remark:
"I have not a clue how to use -crop to actually crop to the correct size."
There is no other real size for raster images than pixels. ABC pixels wide and XYZ pixels high...
There is no such thing as an absolute, real size for a digital image that you can measure in inches... unless you additionally can state the resolution at which a given image is rendered on a display or a print device!
An 8.50x11in sized image at 300 PPI will translate to 2550x3300 pixels.
However, if your image does not contain this amount of pixels (which is the real, absolute size of any raster image), you may still be able to render it at 300 PPI -- but its size in inches will be different from 8.5x11in!
So, whenever you want to crop, use the absolute number of pixels you want. Don't use resolution/density at all on your command line!

Apply color band to TIFF in the PDF

• Background :
We are developing AFP to PDF tool. It involves conversion of AFP (Advanced Function Processing) file to PDF.
• Detailed Problem statement :
We have AFP file with embedded TIFF Image. The image object is described in Function Set 45, represented somewhat like this -
Image Content
Begin Tile
Image Encoding Parameter – TIFF LZW
Begin Transparency Mask
Image Encoding Parameter – G4MMR
Image Data Elements
End Transparency Mask
Image Data Elements (IDE Size 32) – 4 bands: CMYK
End Tile
End Image Content
We want to write this tiled image to PDF either using Java /iText API.
As of now, we can write G4MMR image. But, we are not able to apply CMYK color band data (Blue Color) to this image.
• Solution tried :
The code to write G4MMR image goes as follows –
ByteArrayOutputStream decode = saveAsTIFF(<width>,<height>,<imageByteData>);
RandomAccessFileOrArray ra=new RandomAccessFileOrArray(saveAsTIFF.toByteArray());
int pages = TiffImage.getNumberOfPages(ra);
for(int i1 = 1; i1 <= pages; i1++){
img1 = TiffImage.getTiffImage(ra, i1);
}
img1.scaleAbsolute(256, 75);
document.add(img1);
saveAsTIFF method is given here –
http://www.jpedal.org/PDFblog/2011/08/ccitt-encoding-in-pdf-files-converting-pdf-ccitt-data-into-a-tiff/
As mentioned, we are not able to apply CMYK 4 band image color data to this G4MMR image.
• Technology stack with versions of each component :
1. JDK 1.6
2. itextpdf-5.1
-- Umesh Pathak
The AFP resource you're showing is a TIFF CMYK image compressed with LZW. This image is also using a "transparency mask" which is compressed with G4MMR ( a slightly different encoding than the traditional Fax style G4).
So the image data is already using the CMYK colorspace, each band (C,M,Y,K) is compressed alone using simple LZW encoding and should not be too difficult to extract and store as a basic TIFF CMYK file. You'll also have to convert the transparency mask to G4 or raw data to use it in a pdf file to maks the CMYK image.
If you want better PDF output control, I suggest you take a look at pdflib
You need to add a CMYK colorspace to your image before adding it to the PDF file. However I am afraid this might not be fully supported in iText. A workaround for you could be to convert your image into the default RGB colorspace before adding it to the PDF file, however this will probably imply some quality loss for your image.

Dimension Preserving JPEG to EPS Conversion

I am looking for the best way to convert my JPEG files into EPS. I have to convert my image files to EPS to insert into my LaTeX files. Note that I am using dvipdfm to compile my LaTeX file into PDF and I am not using pdflatex.
The problem is that the actual size of the image changes under the conversion to EPS. Therefore, I have to use the "scale" option of the "includegraphics" command in LaTeX to get the image scale to its actual size. I have tried Gimp, Jpeg2ps and ImageMagick Convert to convert my JPEG files into EPS files. However, each of these converters produces an EPS file whose actual size is different from the actual size of the original JPEG file.
I'd like to know if anyone knows of a way to convert JPEG files to EPS files which preserves the original dimensions of the image. Such a dimension-preserving converter would relieve us from scaling the image in the LaTeX file manually.
My LaTeX file (include-image.tex) is the following:
\documentclass{article}
\usepackage[dvipdfm]{graphicx}
\begin{document}
\begin{figure}
\includegraphics{image.eps}
\end{figure}
\end{document}
And, I use the following Makefile to produce the pdf:
include-image.pdf: include-image.dvi
dvipdfm include-image.dvi
include-image.dvi: include-image.tex
latex include-image.tex
JPEG is a raster format with a fixed resolution, EPS is a vector format with no resolution.
http://www.logodesignworks.com/blog/vector-graphics-and-raster-graphics-difference
A raster graphics don't have physical dimensions relative to print media, the application that renders them out uses a conversion ratio, Dots-Per-Inch (DPI), to scale the graphic. If you have a 2000x2000 pixel JPEG and you print it out at 400 DPI it will be 5x5 inches, if you print it at 800 DPI it will be 2.5x2.5 inches.
In the jpeg2ps program you mention there is a -r switch to specify the DPI of the input JPEG that will calculate the dimensions of the EPS file by dividing the pixel dimensions of the JPEG by the DPI value to get the inch dimensions of the EPS file.