fill PDF

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

fill PDF

Post by AUGE_OHR »

hi,

i use Sumatra as PDF Reader where i can search and copy/paste from App
now i want to "fill" a PDF , how :?:

it is a "normal" PDF and no "editable" Fields.
i know some App can use OCR and "convert" it to Word
is there a other Way or App / LIB which can do the work :idea:
have fun
Jimmy
Pcmodula
Posts: 36
Joined: Thu Nov 22, 2012 6:00 pm

Re: fill PDF

Post by Pcmodula »

Hi Jimmy,
just one idea: C:\MiniGui\SAMPLES\Advanced\PDF-FILLER.
You can also create a compilable template pdf with Libreoffice.

Saludos
PcModula
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: fill PDF

Post by AUGE_OHR »

hi,
Pcmodula wrote: Thu Feb 03, 2022 5:09 am just one idea: C:\MiniGui\SAMPLES\Advanced\PDF-FILLER.
thx for Tip

as i know it need "Adobe Acrobat Reader DC" (which most have)
but i will look into Source Code "how" that Concept work to get a Idee ... :idea:

hm ... how to get Windows DC when have a Handle "from other App" ( like Acrobat)
when possible i can use BosTaurus Function BT_DrawDCtoDC() ...
have fun
Jimmy
Red2
Posts: 281
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: fill PDF

Post by Red2 »

Hi Jimmy,

I have one possible idea but I do not fully understand what you want to solve.
1) Do you have a specific .PDF that you want to "fill out" or do you want a much more general solution for random .PDFs?
2) Do you need your final “filled out” product to result in a .PDF format file?

Thank you,

Red2
jparada
Posts: 433
Joined: Fri Jan 23, 2009 5:18 pm

Re: fill PDF

Post by jparada »

Hi Jimmy,

As I have never been able to create a pdf neither with harbour nor with hmg and as I needed an urgent solution, so what I did was to generate an Excel file and then convert it to pdf with this tool https://github.com/cognidox/OfficeToPDF

I use it as follows:

Code: Select all

hb_processRun( "officetopdf.exe " + tmpExcelFile + " existencias.pdf /hidden",, @stdout )
Then in my case I need to send that pdf by mail and everything works perfect, maybe if you have to generate the pdf from scratch it could be useful for you.

Regards,
Javier
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: fill PDF

Post by AUGE_OHR »

hi,
thx for Answer

i do not deal with PDF every Days, so it is not urgent.
i got a PDF with i have "to fill" with my Name, City etc. and i ask myself "how" (as Programmer)

Idea : i can make a "Snapshot" of PDF to make a BMP
i can "write" into a TEXTBOX and make a "Snapshot" of TEXTBOX and "DragDrop" this Snapshot "into" 1st Snapshot
at End i do print hole BMP as new PDF.

did somebody have made something like this :?:

---

i have ""filled" that PDF "manual" ... but i don´t want to do it "same Way again"
when i have to do "same Work twice" i do "think" about a App ...
have fun
Jimmy
User avatar
mustafa
Posts: 1172
Joined: Fri Mar 20, 2009 11:38 am
DBs Used: DBF
Location: Alicante - Spain
Contact:

Re: fill PDF

Post by mustafa »

Hola jimmy
Probaste ? crear documento PDF con -> HPDFPRINT

Hi jimmy
did you try? create PDF document with ->HPDFPRINT

Saludos/Regards
Red2
Posts: 281
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: fill PDF

Post by Red2 »

Hi Jimmy,

My solution may be useful to you, at least as an idea.
I had one particular .PDF that needed to be repeatedly filled out.
In general I accomplished this as follows:

I converted the .PDF to a .PNG image.
This image went into my DEFINE REPORT's Header band as follows.

Code: Select all

DEFINE REPORT Pages_1_to_2
	PAPERSIZE	PRINTER_PAPER_LETTER	// 215.9  by  279.4
	
*** Report Layout *************
	BEGIN LAYOUT 
		ORIENTATION	PRINTER_ORIENT_PORTRAIT 
	END LAYOUT

*** Header Band ***********
	BEGIN HEADER
		BANDHEIGHT	0
	END HEADER

	BEGIN PICTURE
		VALUE	"RptPg_1"
		ROW		0
		COL		0
		WIDTH	215.9
		HEIGHT	279.4
		STRETCH	.F.
	END PICTURE
In the report's DETAIL BAND I specified the various ROW and COL text that "filled in" the .PDF's answers.

Some Details:
This .PDF form required "fill in" text on the front (page #1) only.
This .PDF form had a back side (page #2) that was printed via the SUMMARY BAND.
(Note: This back side (page #2) needed nothing "filled in").

Code: Select all

*** Summary Band *********
	BEGIN SUMMARY
		BANDHEIGHT	281	// 215.9  by  279.4
	END SUMMARY
	
	// This background picture appears on the back-side (Page #2)
	BEGIN PICTURE
		VALUE	"RptPg_2" 
		ROW		1        //    On page #2
		COL		0
		WIDTH	215.9
		HEIGHT	278
		STRETCH	.F.
	END PICTURE
Finally, I send the output to either my local printer or to a .PDF printer such as "Microsoft Print to PDF".
This works great.
Assuming your need is similar it should adapt to your paper size A4.

Hope that this is helpful.
Red2
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: fill PDF

Post by AUGE_OHR »

hi,

@mustafa
the Problem is not "to Print". i want to "fill" a PDF

@Red2
YES :!:
this is what i´m thinking on

have not work with REPORT so i have to "testdrive" how it work
thx
have fun
Jimmy
Red2
Posts: 281
Joined: Sat May 18, 2019 2:11 pm
DBs Used: Visual FoxPro, FoxPro
Location: United States of America

Re: fill PDF

Post by Red2 »

For what it is worth:
I generate my "filled in" .PDF REPORT by simply calling a function.
A simple example version of the function is below.

Code: Select all

DEFINE REPORT Pages_1_to_2
	PAPERSIZE	PRINTER_PAPER_LETTER	// 215.9  by  279.4
	
*** Report Layout *********
	BEGIN LAYOUT 
		ORIENTATION	PRINTER_ORIENT_PORTRAIT 
	END LAYOUT

*** Header Band ***********
	BEGIN HEADER
		BANDHEIGHT	0
	END HEADER

	BEGIN PICTURE
		VALUE	"RptPg_1"		// Page #1 .PNG image
		ROW		0
		COL		0
		WIDTH	215.9
		HEIGHT	279.4
		STRETCH	.F.
	END PICTURE

*** Detail Band ***********
	BEGIN DETAIL
		BANDHEIGHT	400

		BEGIN TEXT
			EXPRESSION	iif( _PAGENO == 1, ;
						alltrim( gcName ) + CRLF + ;
						alltrim(  oUserAns:OwnStreet1 ) + ;
						iif( ! empty( oUserAns:OwnStreet2 ), ", " + alltrim( oUserAns:OwnStreet2 ), "" ) + CRLF + ;
						alltrim( oUserAns:OwnCity )  + ", "  + ;
						alltrim( oUserAns:OwnState ) + " "   + alltrim( oUserAns:OwnZipCode ), "" )	
			ROW			40.3	;	COL			16
			WIDTH		100		;	HEIGHT		15.3
			FONTNAME	"Arial"	;	FONTSIZE	9
			FONTBOLD       .F.	;	FONTITALIC	 .F.
			FONTUNDERLINE  .F.	;	FONTSTRIKEOUT .F.
			FONTCOLOR	{0,0,0}
			ALIGNMENT	Left 
		END TEXT

		BEGIN TEXT
			EXPRESSION	iif( _PAGENO == 1, alltrim( oUserAns:OwnEmail ), "" )
			ROW			65   	;	COL			72
			WIDTH		100		;	HEIGHT		4.4	
			FONTNAME	"Arial"	;	FONTSIZE	9
			FONTBOLD       .F.	;	FONTITALIC	   .F.
			FONTUNDERLINE  .F.	;	FONTSTRIKEOUT  .F.
			FONTCOLOR	{0,0,0}
			ALIGNMENT	Left 
		END TEXT

		BEGIN TEXT
			EXPRESSION	iif( _PAGENO == 1, alltrim( oUserAns:FromDate ), "" )
			ROW			65	;	COL			137
			WIDTH		100		;	HEIGHT		4.4	
			FONTNAME	"Arial"	;	FONTSIZE	9
			FONTBOLD       .F.	;	FONTITALIC	   .F.
			FONTUNDERLINE  .F.	;	FONTSTRIKEOUT  .F.
			FONTCOLOR	{0,0,0}
			ALIGNMENT	Left 
		END TEXT

	END DETAIL

*** Footer Band *******
	BEGIN FOOTER
		BANDHEIGHT	0
	END FOOTER
	
*** Summary Band ******
	BEGIN SUMMARY
		BANDHEIGHT	281	// 215.9  by  279.4
	END SUMMARY
	
	// This background .PNG appears on the back-side (Page #2)
	BEGIN PICTURE	// Page #2 image
		VALUE	"RptPg_2" 
		ROW		1
		COL		0
		WIDTH	215.9
		HEIGHT	278
		STRETCH	.F.
	END PICTURE

END REPORT
Return  nil
// End function
Post Reply