[Module] PurePDF

Share your advanced PureBasic knowledge/code with the community.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] PurePDF

Post by Thorsten1867 »

loulou2522 wrote:Problem with

Code: Select all

Structure MEM_DataStructure
   pData.i       ; Pointer to memory
   lMaxSize.i    ; Max. reserved memory in bytes
   lCurSize.i    ; Current last possition of data in bytes
 EndStructure

Purebasic say
Structure yet declared in a residant file
Changed:

Code: Select all

CompilerIf Defined(MEM_DataStructure,#PB_Structure)=0
    Structure MEM_DataStructure
      pData.i       ; Pointer to memory
      lMaxSize.i    ; Max. reserved memory in bytes
      lCurSize.i    ; Current last possition of data in bytes
    EndStructure
  CompilerEndIf
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] PurePDF

Post by Thorsten1867 »

Update:
- Bugfixes
- Examples (Tutorial 1-32) added
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: [Module] PurePDF

Post by Lord »

The question still stands:
Is this modul a derivate from PurePDF v2.24 or v2.25?
Image
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: [Module] PurePDF

Post by falsam »

I tested all the examples. Thank you for sharing. ^-^

Small minor errors in these three tutorials.

Tutorial02
Module item 'SetY()' Not found.
changed: pdf_SetY() => PDF::SetPosY()


Tutorial03 - Tutorial04
Module item 'SetX()' not found.
changed: pdf_SetX() => PDF::SetPosX()

Module item 'SetY()' not found.
changed: pdf_SetY() => PDF::SetPosY()

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] PurePDF

Post by Thorsten1867 »

falsam wrote:I tested all the examples. Thank you for sharing. ^-^

Small minor errors in these three tutorials.

Tutorial02
Module item 'SetY()' Not found.
changed: pdf_SetY() => PDF::SetPosY()


Tutorial03 - Tutorial04
Module item 'SetX()' not found.
changed: pdf_SetX() => PDF::SetPosX()

Module item 'SetY()' not found.
changed: pdf_SetY() => PDF::SetPosY()
==> fixed
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: [Module] PurePDF

Post by Lord »

Image
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] PurePDF

Post by Thorsten1867 »

Upgrade PurePdfModule to PurePDF V2.26.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] PurePDF

Post by Thorsten1867 »

It based now on PurePDF V2.26.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Lord
Addict
Addict
Posts: 847
Joined: Tue May 26, 2009 2:11 pm

Re: [Module] PurePDF

Post by Lord »

Thorsten1867 wrote:...
It based now on PurePDF V2.26.
Thanks for this information.

Still:
Help file says:
History wrote:History

Version 2.24 (13.2.2013)
...
So what are the changes from 2.24 to 2.25 to 2.26?
Where can I find the original PurePDF v2.26?
Image
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] PurePDF

Post by Thorsten1867 »

The help file belongs to the original PurePDF include.

Gesendet von meinem Aquaris X mit Tapatalk
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] PurePDF

Post by Thorsten1867 »

http://www.purebasic.fr/english/viewtop ... 02#p504002

Gesendet von meinem Aquaris X mit Tapatalk
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: [Module] PurePDF

Post by collectordave »

Hi

Great module

Just one problem. I am trying to add images to a pdf document and it seems to fail.

Here is my test code

Code: Select all

IncludeFile "PurePdfModule.pbi"

PDF::Create()

PDF::AddPage()

PDF::Image("165134.jpg",80,80,50,50)
;PDF::Image("PurePDFLogo.jpg",80,80,50,50)
File$ = "Test.pdf"
PDF::Save(file$)
RunProgram(file$)
When I use the PurePDFLogo.jpg it works using any other jpg image it fails.

Any Ideas?

collectordave
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: [Module] PurePDF

Post by collectordave »

Managed to get images on the page using imagemem

Code: Select all

UseJPEGImageDecoder()
UseJPEGImageEncoder()

IncludeFile "PurePdfModule.pbi"

PDF::Create("","mm",PDF::#PAGE_FORMAT_A4)

PDF::AddPage()

StampImageID = LoadImage(#PB_Any,"165134.jpg")


;????????????????/
ResizeImage(StampImageID,590,250)

*Buffer = EncodeImage(StampImageID,#PB_ImagePlugin_JPEG)

PDF::ImageMem("165134.jpg",*Buffer,MemorySize(*Buffer),0,10) 

File$ = "Test.pdf"
PDF::Save(file$)
RunProgram(file$)
Now the only thing is to get the image to fit in a standard 30mm X 30mm size. So now what size do I resize the image to get it to fit in a 30 X 30 box? Aspect ratio etc no bother.

Cheers

CD

Hm PS

Imagemem does it for you! Just need to read a little deeper.
PDF::ImageMem("165134.jpg",*Buffer,MemorySize(*Buffer),0,10,30,30)
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
Wolfgang2
User
User
Posts: 11
Joined: Wed Jan 31, 2018 4:03 pm

Re: [Module] PurePDF

Post by Wolfgang2 »

Hi Thorsten1867,

Not sure if you feel like the PurePDF maintainer now. So, if not, that's OK.

My question is around pdf_SetAFile()
According to manual and examples, this needs a FileID which, in turn, is returned by a call to pdf_EmbedFile()
(The manual does not document any return value for pdf_EmbedFile, btw.)

So, this all works as expected, BUT:
The resulting PDF has the same file embedded twice:
Once from pdf_EmbedFile() and once again caused by pdf_SetAFile().
You can see that in the PDF created by example "tutorial29" where the "20k_c1.txt" is embedded twice.

This seems a waste. Is there any way to create a pdf_SetAFile with just one copy of the embedded file ?
could you put the return value of PB's ReadFile() into pdf_SetAFile() ?

Thank you,
Wolfgang2
normeus
Enthusiast
Enthusiast
Posts: 414
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: [Module] PurePDF

Post by normeus »

the "SetA" commands are "Anotations"

Code: Select all

pdf_SetAText
pdf_SetAPopUp
pdf_SetAFile
pdf_EmbedFile() is a separate command which attaches a file at the end of your pdf.

If you are doing pdf_SetAFile then it takes the fileid created by pdf_EmbedFile and uses it
from the example:

Code: Select all

Define fileid=pdf_EmbedFile("20k_c1.txt","Attachments Pane")
link = pdf_Addlink()
pdf_SetAFile(link,fileid,-1,0,"Beschreibung","Der Titel",5,5,Date(),"Tag",0)
pdf_Cell(80,10,"This is a File annotation",1,1,#PDF_ALIGN_LEFT,#True,link)

Define file$="Tutorial29 Annotations+Actionsa.pdf"
try this code to display link 2x for the same file

Code: Select all

Define fileid=pdf_EmbedFile("20k_c1.txt","Attachments Pane")
link = pdf_Addlink()
pdf_SetAFile(link,fileid,-1,0,"Beschreibung","Der Titel",5,5,Date(),"Tag",0)
pdf_Cell(80,10,"This is a File annotation",1,1,#PDF_ALIGN_LEFT,#True,link)
pdf_SetAFile(link,fileid,-1,0,"Beschreibung","Der Titel",5,5,Date(),"Tag",0)
pdf_Cell(80,10,"This is other File annotation",1,1,#PDF_ALIGN_LEFT,#True,link)

Define file$="Tutorial29 Annotations+Actionsa.pdf"
if you look at the output pdf it will be the same size as the previous pdf

Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Post Reply