PurePDF Version 2.0

Developed or developing a new product in PureBasic? Tell the world about it.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

:cry: Still not working here:

Code: Select all

dPtcm.d = ((1/72) * 25.4)
   dW.d = 794.00 * dPtcm
   dH.d = 1123.00 * dPtcm
sPDF_PAGE_FORMAT_CUSTOM.s = StrD(dW,2) + "," + StrD(dH,2)

;Debug sPDF_PAGE_FORMAT_CUSTOM

Define   sPdfName.s = "C:\TestA4Format200dpi.pdf"
Define sImageFile.s = "TestA4Format200dpi.png"

      pdf_Create("P","pt",sPDF_PAGE_FORMAT_CUSTOM)
     pdf_AddPage()
       pdf_Image(sImageFile,0,0,dW)
        pdf_Save(sPdfName)

      ;View PDF created
      RunProgram(sPdfName)
No image and PDF Page Size is 98.8 x 139.8mm (Adobe Reader v10.1.3)
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: PurePDF Version 2.0

Post by ABBKlaus »

What are the dimensions (in pixels) of your image IdeasVacuum ?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

Hi ABBKlaus, the 200dpi image is size A4, verifies as 794 x 1123 pix in Irfan View (and the OS explorer).

The files we have been testing are available for download:

Test Files
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: PurePDF Version 2.0

Post by ABBKlaus »

If you want the PDF size equal to 210 x 297 mm you can do it this way :

Code: Select all

ptinch.d=1/72 ; each point is ~0.014" (1/72 of an inch)
ptcm.d=(1/72)*25.4 ; each point is ~0.35 mm
ptx=210 / ptcm ; calculate 210 mm into point
pty=297 / ptcm ; calculate 297 mm into point
PDF_PAGE_FORMAT_CUSTOM.s=Str(ptx)+","+Str(pty)
sPdfName.s = "TestA4Format200dpi.pdf"
sImageFile.s = "TestA4Format200dpi.png"

pdf_Create("P","pt",PDF_PAGE_FORMAT_CUSTOM)
pdf_SetMargins(0,0,0)
pdf_SetFillColor(230,230,230) ;Light Gray
pdf_AddPage()
pdf_Image(sImageFile,0,0,ptx,pty)

pdf_Save(sPdfName)

;View PDF created
RunProgram(sPdfName)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

Oh yes, that works perfectly! :mrgreen:

Thanks again ABBKlaus
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

Re: PurePDF Version 2.0

Post by Olby »

Is there any way I can change the PDF Producer tag with my own text. I know it's not meant to be changed but the files produced by my application are sent to clients and we need to put our company's credentials in there. Thanks.
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
MachineCode
Addict
Addict
Posts: 1482
Joined: Tue Feb 22, 2011 1:16 pm

Re: PurePDF Version 2.0

Post by MachineCode »

Can I request that PurePDF support passwords for opening the created PDF document in future? Thanks! (And I mean natively, and not with a JavaScript hack).
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
Puffolino
User
User
Posts: 49
Joined: Thu Jan 05, 2012 12:27 am

Re: PurePDF Version 2.0

Post by Puffolino »

I just downloaded the PurePDF lib and tested all tutorials, what a nice package -- thanks :wink:

I started "decoding" some HTML-Tags (<b>, </b> and <br>), which can be seen in the code below. But I would need a kind of a text flow and have no idea how to do this. I have an image on the top right position of a page and a loto of text which should be drawn on the page (except over the image).

It should look like that (t=text, *=image):
__________

tt ttttt . ******
ttttt tt . ******
tt ttttt . ******
ttttt tt
ttttt ttttt tttttt
tt tt ttt tttt ttt
tttttt
__________

Can this be done easily?

I have also another problem, some jpg files are not displayed in the resulting pdf file. PB is able to display these images with no problem and as there are no big differences in the jpg parameters (image size, DPI etc.) it seems to be that progressive encoding is not supported.
As I am not able to change the image sources, is it possible to do a trick do embed these jpg files into a pdf file without creating temporary files for each image?

Code: Select all

	Procedure WriteText(Text.s)

		Protected FlagBoldOn
		Protected FlagBoldOff
		Protected FlagBreak

		Repeat
			FlagBreak=FindString(Text,"<br>",FlagBreak)
			If FlagBreak
				WriteText(Left(Text,FlagBreak-1))
				Text=Trim(Mid(Text,FlagBreak+4))
				If Len(Text)
					WriteText(Text)
				EndIf
				Break
			EndIf

			FlagBoldOn=FindString(Text,"<b>",FlagBoldOff)

			If FlagBoldOn

				pdf_Write(5,Left(Text,FindString(Text,"<b>",1) - 1))

				FlagBoldOff=FindString(Text,"</b>",FlagBoldOn)
				If FlagBoldOff=0
					FlagBoldOff=Len(Text)
				EndIf
				pdf_SetFont(#FontFace,"B",14)
				pdf_Write(5,Mid(Text,FlagBoldOn+3,FlagBoldOff-FlagBoldOn-3))
				pdf_SetFont(#FontFace,"",12)
				FlagBoldOff+4

			Else

				pdf_Write(5,Mid(Text,FlagBoldOff))
				pdf_Ln()
				Break

			EndIf

		ForEver

	EndProcedure

yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Re: PurePDF Version 2.0

Post by yrreti »

Removed this question and transfered this post to the Coding Questions section
where ABBKlaus was able to help me.
Thanks for providing this nice library. :D

yrreti
Last edited by yrreti on Thu Aug 02, 2012 7:15 pm, edited 1 time in total.
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1282
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Re: PurePDF Version 2.0

Post by Paul »

Is this PurePDF tool able to load a PDF file, make some additions and then resave as PDF ?
If not, does anyone know of some existing code or command line tool to do this?

Thanks.
Image Image
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: PurePDF Version 2.0

Post by IdeasVacuum »

It is currently used to create PDF files. You can do more with GhostScript, but for commercial use the license could be an issue. I made an inquiry not so long ago and decided not to bother when I received a reply consisting of a long list of questions.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Oliver13
User
User
Posts: 90
Joined: Thu Sep 30, 2010 6:40 am

Re: PurePDF Version 2.0

Post by Oliver13 »

ABBKlaus wrote:Update :
- added WMF support (requested by Oliver13)
Hi Klaus,
I haven't been here for a while: thank you very much !!!

Oliver
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: PurePDF Version 2.0

Post by Rings »

i need a simple JPEG/PNG 2 PDf converter ,
i remembered this thread, donwloaded the stuff and
voila, it did not work with 5.10 .

Code: Select all

Procedure MEM_DataReplace(*aData.MEM_DataStructure, aSource.s, aDest.s)
.
.
.
  If (vFind > 0)
      vReturn = MEM_DataInit(*aData, vMaxSize + (vFind*(vDestLen - vSourceLen))) = #False
    EndIf  
throws a boolean error .
normaly, i'm able to fix such errors bymyself, but i'm totaly lost in this case.
And yes, i never would type such a construct ;)
anyone can help me (and the community) to fix that errors in the lib ?
SPAMINATOR NR.1
infratec
Always Here
Always Here
Posts: 7580
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: PurePDF Version 2.0

Post by infratec »

Hi Rings,

to be backward compatible I would do it like this:

Code: Select all

If (vFind > 0)
  If MEM_DataInit(*aData, vMaxSize + (vFind*(vDestLen - vSourceLen))) = #False
    vReturn = #True
  Else
    vReturn = #False
  EndIf
EndIf
I hope that's right.

Bernd
ABBKlaus
Addict
Addict
Posts: 1143
Joined: Sat Apr 10, 2004 1:20 pm
Location: Germany

Re: PurePDF Version 2.0

Post by ABBKlaus »

Thanks for reporting Rings and infratec.

I have uploaded fixed archives (no version change) ;-)

http://www.purebasicpower.de/?PurePDF
Post Reply