How to print with custom page in ruby on rails? - ruby-on-rails

Can i print a lot of same barcode image (depends on total barcode) in rails?
Example total_barcode is 6, so i print 6 same barcode.
The image will fit with the layout.
If the size of paper only fit 4 image, and it will generate another page until there are 6 image
Its looks like
XX(page 1)
XX(page 1)
XX(page 2) the x is image
Thanks i hope you guys can understand what i'm trying to say 😭

This is possible.
I would suggest first creating the barcodes page as html, and then converting to pdf.
To create the barcodes on an html page, you have to use a barcode font (Google it), you will need to load the fonts into the page, and specify the barcode font for the barcode "text" in css. When you render text with a barcode font, it appears on the page as a barcode.
Next you need to convert the html to pdf. I suggest using the same url, but appending .pdf to the url instead of .html. You can look for libraries that convert from html to pdf.
Sorry I haven't provided much detail, this is a big project!

Related

Prawn PDF Image Comes With Text

I am using prawn pdf in Rails 3.
I try to embed an image into my pdf file using
image "#{Rails.root}/app/assets/images/logo.png", :height => 30
The resulting PDF consists of the logo, which is good. However there is this line:
#<Prawn::Images::PNG:0x007ff7d1438f20>
printed below the logo.
There is nothing special with my code, I am just following this Railscast to set things up:
http://railscasts.com/episodes/153-pdfs-with-prawn
and added the image code.
May I ask if anyone faces the same problem and how to resolve it?
Thank you so much!

QuickPDF converting a PDF to an Image: letters move in eachother

Quick PDF has a feature to convert a PDF into an Image:
iNumPages := PDFLibrary.PageCount();
PDFLibrary.RenderDocumentToFile(300, 0, iNumPages, 0, 'H:\temp\quickpdf_testimage_6_new.bmp');
If this feature is executed the letters move (with some PDF sources) in each other. In the following there is a PDF and the resulting JPG:
PDF: http://www.baunetz.de/aip/2001/tunnel.pdf
Now there is a problem: in the resulting Image the Letters move in eachother.
Update:
I have cause of the Problem:
"
This PDF contains a font (OfficinaSans-Book) that is not embedded in the PDF so Quick PDF substitutes Arial instead which has thicker characters.
This is a common problem with PDF's and many PDF viewers. The best solution is to create the PDF with embedded fonts for any of the non standard fonts that are used in the PDF."
http://www.quickpdf.org/forum/topic2478_post10369.html#10369
Update 2:
The only PDF Engine so far that has no Problems with 'lettes moving in each other' is the foxit DLL.
I have cause of the Problem: " This PDF contains a font (OfficinaSans-Book) that is not embedded in the PDF so Quick PDF substitutes Arial instead which has thicker characters.
This is a common problem with PDF's and many PDF viewers. The best solution is to create the PDF with embedded fonts for any of the non standard fonts that are used in the PDF." http://www.quickpdf.org/forum/topic2478_post10369.html#10369
Edit:
A possible solution would be to use MultiMaster fonts if the font wasn't found on the system. Adobe uses this technique. But i haven't found a way to implement that with quickpdf.

How to reduce the size (in MB) of pictures inserted in a PDF?

I'm writing a Master thesis when I need to include several photographs, but I've got a problem with the size of the generated PDF: 18MB, which is more or less the cumulated size of all the picture included.
How can I tell Latex not to keep the original picture and reduce it, but to shrink the picture before including it in the PDF?
I use \includegraphics[height=6cm]{img/cinema.jpg} to include my figures.
Thanks
You need to reduce the size of your pictures yourself before you include them (with software of your choice). That's the simple solution.
I think the rationale for including in full is that PDF is a vectorial page description language, and you might want to render a page at an arbitrary resolution later.
You can use primoPDF to downsize all pictures at once, after you created the pdf in Latex.
There is a package called "degrade" that does this. I have not tried it, and it is not included in TeXLive, so you will need to install it manually.
Also, PDFLaTeX should have some compression arguments.

Generate a thumbnail for the first page of a PDF within a rails App?

Is there anyway to generate a thumbnail image for the first page of an uploaded PDF file. I want to display this image along with the description (provided by the user) of the file.
The first answer from this question looks like it'll do what you want.
You can use an image processing library like ImageMagick to convert a PDF into an image.
Call out to the system with something like:
system("convert -size 150x150 /path/to/uploaded/document.pdf /path/to/thumbnail/file.png")

Inkscape + pdftex?

I have a small drawing in Inkscape and I want to embed it in a LaTeX document which I compile using pdftex. pdftex seem to have an oddity of not accepting .eps. infact if what I understood is correct the only vector graphics format it accepts is pdf. When I save my drawing in Inkscape as pdf then what I get is a pdf with a full page with my drawing in the upper corner.
Is there a way to import an Inkscape drawing to pdftex and ignoring this page size? Or do I need to start fiddling with the page settings to make the page size exactly fit the size of my drawing?
So it turns out that Inkscape has a button on the Document properties titled "Fit page to selection" which makes this easier. Oh well.
Yes, pdftex does not accept eps.
I have used inkscape to make figures that I incorporate into .tex documents that I then process with pdflatex. And yes, I set the page size in inkscape so that the figure fits.
You could also try to export to .eps from inkscape, then convert to pdf with the "epstopdf" tool.
Are you giving the optional scaling parameters to \includegraphics? PDF handles bounding boxes differently from encapsulated postscript, and auto-sizing does not seem to work as well.
As far as I know, you have to adjust the bounding box resp. paper size in your PDF. There are tools like eps2pdf to convert EPS to PDF with the same bounding box.
You can even fully automate the process of converting your svgs into pdfs, since inkscape can be called from command line. For instance, the following makefile code does the job (copping and converting) for me:
# svg -> pdf
$(GRAPHIC_DIR)/%.pdf: $(GRAPHIC_DIR)/%.svg
cp $(GRAPHIC_DIR)/$*.svg $(GRAPHIC_DIR)/$*-crop.svg
inkscape --verb=FitCanvasToSelectionOrDrawing --verb=FileSave --verb=FileClose $(GRAPHIC_DIR)/$*-crop.svg
inkscape -A $(GRAPHIC_DIR)/$*.pdf $(GRAPHIC_DIR)/$*-crop.svg
rm $(GRAPHIC_DIR)/$*-crop.svg
Moreover, cropping pdf files can be also done using pdfcrop.

Resources