Generate pdf files to print on paper specific sizes

474 views
Skip to first unread message

Clippero

unread,
Jun 13, 2014, 10:00:14 AM6/13/14
to harbou...@googlegroups.com
[Eng] Google

Hello people.
In a Datamax printer III I have to print labels of various sizes, which may or may not contain barcodes, for now they are just text.

For this I use pdf files. (One sheet for each label).

Use the class PDFClass made ​​by José Quintas MC inherited from HaruPDF.
The class is described in www.harbourdoc.com.br

It works great and is very practical file creation. PDF

The problem comes when I need to create pdf files in non-standard paper sizes (A4, Legal, Letter).

I have two sizes of labels but most interests me is the 60 mm x 30 mm

I did not know how to define the size of the paper, looked both PDFClass as in libharu.

Anyone know how I can resolve this?

thank you very much

--------------

[Esp]

Hola gente.
En una impresora Datamax III tengo que imprimir etiquetas de diversos tamaños, que pueden contener o no códigos de barra, por ahora son solo texto.

Para esto utilizo archivos .pdf (una hoja por cada etiqueta).

Uso la clase PDFClass hecha por José M. C. Quintas, heredada de HaruPDF.
La clase está descripta en www.harbourdoc.com.br

Funciona muy bien y resulta muy práctica la creación de archivos .PDF

El problema surge cuando tengo que crear archivos pdf en papel con tamaños no standard (A4, Legal, Carta).

Tengo dos tamaños de etiquetas pero la que mas me interesa es la de 60 mm x 30 mm

No supe como definir el tamaño del papel, busqué tanto en la PDFClass, como en la libharu.

Alguien sabe como puedo resolver esto ?

Muchas gracias

Fermín Barboza

Maurizio la Cecilia

unread,
Jun 13, 2014, 12:01:42 PM6/13/14
to Harbour User Group
Hi,
the class made by Jose builds only A4 pages. See the method AddPage()

You could:

A) change the dimensions of the page just after the AddPage() method call. You could add: 
     HPDF_Page_SetWidth( oPage, 60 * 0.03937 * 72 )
     HPDF_Page_SetHeight( oPage, 30 * 0.03937 * 72 )
where 60 and 30 are your wanted dimensions in mm, 0.03937 is the constant to convert mm to inches and 72 is the HaruPDF default DPI (I see no changes to this value in the library)  

B) change the method to do the job depending on the passed parameters as in AddPage( [ nWidth, nHeight ] ) and test the parameters to build A4 page (as before) if no value is passed or set the wanted dimensions if they are supplied.

BR
Maurizio


--
--
You received this message because you are subscribed to the Google
Groups "Harbour Users" group.
Unsubscribe: harbour-user...@googlegroups.com
Web: http://groups.google.com/group/harbour-users

---
You received this message because you are subscribed to the Google Groups "Harbour Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Clippero

unread,
Jun 14, 2014, 5:40:24 PM6/14/14
to harbou...@googlegroups.com
[Eng] Google

Thanks
Maurizio, I'll try your solution and then I tell if I could solve my problem.

[Esp]

Gracias Maurizio, voy a probar tu solución y luego te cuento si pude resolver mi problema.

Clippero

unread,
Jun 18, 2014, 8:29:08 AM6/18/14
to harbou...@googlegroups.com
[Eng] Google

Maurizio, everything worked perfect, I copy and paste as a new method was addPage

Comments are exclusive for my use.

----------

[Esp]

Maurizio, funcionó todo perfecto, copio y pego como quedó el nuevo metodo Addpage

Los comentarios son exclusivos para mi uso.

------------

***************************************************
* nWidth = Ancho (60 mm)
* nHeight= Alto  (30 mm)
* 0.03937 constante para convertir de mm a pulgadas
* 72 haruPDF default DPI
***************************************************
METHOD AddPage(nWidth,nHeight) CLASS PDFClass
   IF ::nType != PDF_TXT
      ::oPage := HPDF_AddPage( ::oPdf )

      HPDF_Page_SetSize( ::oPage, HPDF_PAGE_SIZE_A4, iif( ::nType == 2, HPDF_PAGE_PORTRAIT, HPDF_PAGE_LANDSCAPE ) )
      HPDF_Page_SetFontAndSize( ::oPage, HPDF_GetFont( ::oPdf, ::cFontName, ::cCodePage ), ::nFontSize )

      IF nWidth#NIL           && SE RE-DEFINE EL ANCHO DE LA HOJA
         HPDF_Page_SetWidth( ::oPage, nWidth * 0.03937 * 72 )
      ENDIF
      IF nHeight#NIL          && SE RE-DEFINE EL ALTO DE LA HOJA
         HPDF_Page_SetHeight( ::oPage, nHeight * 0.03937 * 72 )
      ENDIF

   ENDIF
   ::nRow := 0
   RETURN NIL

José Quintas

unread,
Jun 18, 2014, 4:56:23 PM6/18/14
to harbou...@googlegroups.com
I made a test with my class now.

Add to VAR:
   VAR    nPageWidth       INIT 595.28  // A4
   VAR    nPageHeight        INIT 841.89  // A4

Try this in AddPage, using HPDF_Page_SetRotate():

      // HPDF_Page_SetSize( ::oPage, HPDF_PAGE_SIZE_A4, iif( ::nPrinterType == 2, HPDF_PAGE_PORTRAIT, HPDF_PAGE_LANDSCAPE ) )
      HPDF_Page_SetWidth( ::oPage, ::nPageWidth )
      HPDF_Page_SetHeight( ::oPage, ::nPageHeight )
      HPDF_Page_SetRotate( ::oPage, iif( ::nPrinterType == 2, 0, 90 ) )

And try this changing size only:

      // HPDF_Page_SetSize( ::oPage, HPDF_PAGE_SIZE_A4, iif( ::nPrinterType == 2, HPDF_PAGE_PORTRAIT, HPDF_PAGE_LANDSCAPE ) )
      IF ::nPrinterType == 2
         HPDF_Page_SetWidth( ::oPage, ::nPageHeight )
         HPDF_Page_SetHeight( ::oPage, ::nPageWidth )
      ELSE
         HPDF_Page_SetWidth( ::oPage, ::nPageWidth )
         HPDF_Page_SetHeight( ::oPage, ::nPageHeight )
      ENDIF

- Using pre-defined sizes and portrait/landscape, preview is ok
- Using HPDF_Page_SetRotate(), preview is rotated too
- Setting size only, for foxit reader ok, because default print is (x)auto-rotate

Then, for preview to user, last option seems to be the best.
I do not found how change portrait/landscape without use pre-defined layout, except using HPDF_Page_SetRotate()

Option to use:
oPDF := PDFClass():New()
oPDF:nPageWidth := oPDF:mmToPDF( 210 ) // A4
oPDF:nPageHeight := oPDF:mmToPdf( 297 ) // A4

METHOD ::mmToPDF( nMilimiters )
   RETURN nMilimeters * 0.03937 * 72


José M. C. Quintas

Clippero

unread,
Jun 19, 2014, 7:39:24 AM6/19/14
to harbou...@googlegroups.com
[Esp]

Ok. José, interesante tus cambios.
Ya lo tengo resuelto pero de todos modos son muy buenas tus ideas.
Las tendré en cuenta.
Muy buena la clase PDFClass, me permitió usar de mejor manera la HaruPDF

---------------

[Eng] Google

Ok. Joseph, interesting your changes.
I got it resolved but still are very good your ideas.
The'll remember.
PDFClass very good class, let me use better the HaruPDF


Fermín
Reply all
Reply to author
Forward
0 new messages