[Module] PurePDF

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

[Module] PurePDF

Post by Thorsten1867 »

I transformed the PurePDF include into a module.

Download-Link (Box.net)

Code: Select all

; ===== Commands ==================
; PDF::AcceptPageBreak()        - Accept automatic page break or not.
; PDF::Addlink()                - Creates a new internal link and returns its identifier.
; PDF::AddPage()                - Adds a new page to the document.
; PDF::BookMark()               - Add bookmark
; PDF::Cell()                   - Prints a cell (rectangular area) with optional borders, background color and character string.
; PDF::DrawCircle()             - Draw circle
; PDF::DisplayPreferences()     - Set viewer preferences
; PDF::DrawEllipse()            - Draw ellipse
; PDF::GetErrorCode()           - Return the error code.
; PDF::GetErrorMessage()        - Return the error message. 
; PDF::GetFontSize()            - Get current fontsize.
; PDF::GetMultiCellNewLines()   - Get the last value of newlines for pdf_MultiCell()
; PDF::GetNumbering()           - Return if numbering is #True/#False. Usefull for TOC functions
; PDF::GetNumberingFooter()     - Return if numbering in footer is #True/#False. Usefull for TOC functions
; PDF::Image()                  - Puts an image in the page.
; PDF::ImageMem()               - Puts an image from memory in the page.
; PDF::IncludeFileJS()          - Include JavaScript file
; PDF::IncludeJS()              - Add JavaScript code
; PDF::InsertTOC()              - Insert table of contents.
; PDF::DrawLine()               - Draws a single line between two points.
; PDF::Link()                   - Puts a link on a rectangular area of the page.
; PDF::Ln()                     - Performs a line break.
; PDF::MultiCell()              - This method allows printing text with line breaks.
; PDF::MultiCellBlt()           - Add multicell with bullet
; PDF::NumPageNum()             - Get TOC page number
; PDF::PathArc()                - Draws a cubic Bezier curve to the current path.
; PDF::PathBegin()              - Begins a new path at the coordinates (x, y). 
; PDF::PathEnd()                - Closes the current path and draws a line from the current point to the starting point.
; PDF::PathLine()               - Draws a line from the current point to (x, y).
; PDF::PathRect()               - Draws a rectangle to the current path with upper-left corner (x, y) and dimensions (w, h). 
; PDF::Rect()                   - Outputs a rectangle.
; PDF::ResetBookMark()          - Reset bookmarks for new document
; PDF::RoundRect()              - Outputs a rounded rectangle.
; PDF::Rotate()                 - Perform a rotation around a given center.
; PDF::Save()                   - Save PDF to filename.
; PDF::ScaleX()                 - Scaling X
; PDF::ScaleY()                 - Scaling Y
; PDF::ScaleXY()                - Scaling XY
; PDF::Sector()                 - Draw the sector of a circle.
; PDF::SetAFile()               - Defines the page and position for file annotations.
; PDF::SetALaunch()             - Defines the page and position for a launch action.
; PDF::SetAPopUp()              - Defines the page and position for PopUp annotations.
; PDF::SetAText()               - Defines the page and position for text annotations.
; PDF::SetDrawColor()           - Set color for all stroking operations.
; PDF::SetFillColor()           - Set color for all filling operations.
; PDF::SetLineWidth()           - Defines the line width.
; PDF::SetLink(                 - Defines the page and position a link points to.:
; PDF::SetDash()                - Set a dash pattern And draw dashed lines Or rectangles.
; PDF::SetFont()                - Sets the font used to print character strings.
; PDF::SetFontSize()            - Defines the size of the current font.
; PDF::SetTextColor()           - Set color for text.
; PDF::SetNumberingFooter()     - Set footer numbering true/false.
; PDF::SetX()                   - Defines the abscissa of the current position.
; PDF::SetY()                   - Moves the current abscissa back to the left margin and sets the ordinate.
; PDF::SetXY()                  - Defines the abscissa and ordinate of the current position.
; PDF::StartPageNums()          - Start TOC page numbering.
; PDF::StopPageNums()           - Stop TOC page numbering.
; PDF::SubWrite()               - Write superscripted or supscripted
; PDF::Text()                   - Prints a character string.
; PDF::TOCEntry()               - Set TOC entry
; PDF::Triangle()               - Draw Triangle
; PDF::TruncateCell()           - Prints a Cell, if text is too large it will be truncated
; PDF::Write()                  - This method prints text from the current position.
; PDF::SetProcHeader()          - Set header procedure.
; PDF::SetProcFooter()          - Set footer procedure.
; PDF::SetProcAcceptPageBreak() - Set acceptpagebreak procedure.
; PDF::SetProcCompression()     - Set compression procedure.
; PDF::SetTitle()               - Defines the title of the document.
; PDF::SetAuthor()              - Defines the author of the document.
; PDF::SetKeywords()            - Associates keywords with the document, generally in the form 'keyword1 keyword2 ...'.
; PDF::SetCreator()             - Defines the creator of the document.
; PDF::AliasNbPages()           - Defines an alias for the total number of pages.
; PDF::GetPageNum()              - Returns the current page number.
; PDF::GetPosX()                - Returns the abscissa of the current position.
; PDF::GetPosY()                - Returns the ordinate of the current position.
; PDF::Create()                 - Begin document.
; PDF::SetDisplayMode()         - Set display mode in viewer.
; PDF::SetAutoPageBreak()       - Set auto page break mode and triggering margin.
; PDF::SetMargins()             - Set left, top and right margins.
; PDF::SetTopMargin()           - Set top margin.
; PDF::SetRightMargin()         - Set right margin.
; PDF::SetCellMargin()          - Set cell margin.
; PDF::SetLeftMargin()          - Set left margin.
; PDF::EmbedFile()              - Embeds a file into the pdf.
; PDF::GetStringWidth()         - Get width of a string in the current font.
; PDF::TextString(String$)      - Format a text string.
; PDF::GetCMargin()             - Get cell margin.
; PDF::GetRMargin()             - Get right margin.
; PDF::GetLMargin()             - Get left margin.
; PDF::GetWordSpacing()         - Get word spacing. 
; PDF::SetWordSpacing()         - Set word spacing.
; PDF::GetWidth()               - Get current width of page. 
; PDF::GetHeigth()              - Get current height of page.
; PDF::GetScaleFactor()         - Get scale factor.
; PDF::GetObjNum()              - Get object number
; PDF::GetFontSizePt()          - Get current fontsize in points.
; PDF::StartTransform()         - Use this before calling any transformation. (Scale, Skew, Mirror, Translate)
; PDF::StopTransform()          - Restore the normal painting and placing behaviour as it was before calling pdf_StartTransform(). 
; PDF::Translate()              - Translate -> right/bottom
; PDF::TranslateX(TX.f)         - Translate -> right
; PDF::TranslateY(TY.f)         - Translate -> bottom
; PDF::SkewX()                  - Skewing (angle x)
; PDF::SkewY()                  - Skewing (angle y)
; PDF::MirrorH()                - Alias for scaling -100% in x direction
; PDF::MirrorV()                - Alias For scaling -100% in y direction.
; PDF::SetLineCap()             - Sets the line cap style
; PDF::SetLineJoin()            - Sets the line join style.
; PDF::SetTextColorCMYK()       - Set Textcolor CMYK
; PDF::SetDrawColorCMYK()       - Set Drawcolor CMYK
; PDF::SetFillColorCMYK()       - Set Fillcolor CMYK 
; PDF::ASCII85_Decode()         - Decodes an ASCII85 encoded buffer.
; PDF::ASCII85_Encode()         - Encodes data to ASCII85-
; PDF::ASCII85_Free()           - Frees a Databuffer that was allocated with PDF::ASCII85_Encode().
; =================================
Last edited by Thorsten1867 on Tue Sep 26, 2017 8:58 pm, edited 2 times in total.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]
loulou2522
Enthusiast
Enthusiast
Posts: 359
Joined: Tue Oct 14, 2014 12:09 pm

Re: Module PurePDF

Post by loulou2522 »

THanks a lot , very usefull programm
User avatar
Kukulkan
Addict
Addict
Posts: 1259
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

Re: [Module] PurePDF

Post by Kukulkan »

GREAT :!: Thank you!
Lord
Enthusiast
Enthusiast
Posts: 702
Joined: Tue May 26, 2009 2:11 pm

Re: [Module] PurePDF

Post by Lord »

Hm, the history of this module says "Version 2.24 (13.2.2013)"
but isn't there already a version 2.25 (for PB5.2x x86)?
Image
RSBasic
Moderator
Moderator
Posts: 1114
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: [Module] PurePDF

Post by RSBasic »

Great Image
ImageImageImageImage Image
acreis
Enthusiast
Enthusiast
Posts: 140
Joined: Fri Jun 01, 2012 12:20 am

Re: [Module] PurePDF

Post by acreis »

Great! Very usefull!!!! Thanks!!!!!
User avatar
cabaptista
User
User
Posts: 86
Joined: Sun Nov 30, 2003 11:42 pm
Location: Lisboa, Portugal

Re: [Module] PurePDF

Post by cabaptista »

Many Thanks
User avatar
Kwai chang caine
Addict
Addict
Posts: 4887
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: [Module] PurePDF

Post by Kwai chang caine »

Very useful and nice module
Works perfectly here
Thanks for sharing 8)
ImageThe happiness is a road...
Not a destination
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 1875
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: [Module] PurePDF

Post by Andre »

Thank you very much! :D

I will try to include/use it in my project (for Win + Mac) during the next weeks... 8)
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
kvitaliy
Enthusiast
Enthusiast
Posts: 161
Joined: Mon May 10, 2010 4:02 pm

Re: [Module] PurePDF

Post by kvitaliy »

Thank you.
Can you show a simple example of using this module?
User avatar
falsam
Enthusiast
Enthusiast
Posts: 626
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: [Module] PurePDF

Post by falsam »

Hello kvitaliy
kvitaliy wrote:Thank you.
Can you show a simple example of using this module?
Use the PurePDF225 examples and replace PDF_ with PDF::

Example: pdf_Create becomes PDF::Create()

■ Hello World

Code: Select all

XIncludeFile "PurePdfModule.pbi"

Define file$="Tutorial01 Hello World.pdf"

UseModule PDF

PDF::Create()
PDF::AddPage()
PDF::SetFont("Arial","B",16)
PDF::Cell(40,10,"Hello World!",1)
PDF::Save(file$)

RunProgram(file$)
■ Header & Footer

Code: Select all

XIncludeFile "PurePdfModule.pbi"

UseModule PDF

Procedure Header()
  PDF::SetFont("Arial","B",15)
  PDF::Cell(80)
  PDF::Cell(30,10,"Title",1,0, PDF::#ALIGN_CENTER)
  PDF::Ln(20)
EndProcedure

Procedure Footer()
  PDF::SetY(-15)
  PDF::SetFont("Arial","I",8)
  PDF::Cell(0,10,"Page "+Str(PDF::GetPageNum())+"/{nb}",0,0,PDF::#ALIGN_CENTER)
EndProcedure

Define file$="Tutorial02 Header-Footer.pdf"
Define i

PDF::Create()
PDF::SetProcFooter(@Footer())
PDF::SetProcHeader(@Header())
PDF::AliasNbPages();

PDF::AddPage();
PDF::SetFont("Times","",12);

For i = 1 To 40
  PDF::Cell(0,10,"Printing line number "+Str(i),0,1);
Next

PDF::Save(file$)
RunProgram(file$)

➽ Windows 10 - PB 5.73(x64)

Sorry for my bad english and the Dunning–Kruger effect.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 626
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: [Module] PurePDF

Post by falsam »

Hello Thorsten

The procedure AliasNbPages() is not public. I modified the source you provided.
Declare SetCreator(Creator$)
Declare AliasNbPages(Alias$="{nb}")
Declare.l GetPageNum()
Thank you for this module.

➽ Windows 10 - PB 5.73(x64)

Sorry for my bad english and the Dunning–Kruger effect.
loulou2522
Enthusiast
Enthusiast
Posts: 359
Joined: Tue Oct 14, 2014 12:09 pm

Re: [Module] PurePDF

Post by loulou2522 »

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
kvitaliy
Enthusiast
Enthusiast
Posts: 161
Joined: Mon May 10, 2010 4:02 pm

Re: [Module] PurePDF

Post by kvitaliy »

falsam, thanks for a simple example!
User avatar
Thorsten1867
Addict
Addict
Posts: 1265
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Re: [Module] PurePDF

Post by Thorsten1867 »

kvitaliy wrote:Thank you.
Can you show a simple example of using this module?
Look at the end of the code and comple it.

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

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 10 x64] [PB V5.7x]
Post Reply