Seite 1 von 1

[Module] PurePDF

Verfasst: 26.09.2017 19:49
von Thorsten1867
Ich habe das PurePDF-Include in ein Modul umgewandelt und etwas optimiert.
Einige Befehle musste ich ändern, um Konflikte mit PB-Befehlen zu vermeiden.
Einige der Beispiele sind am Ende integriert (-> Compilieren).

Nach meinen ersten Tests scheint es zu funktionieren.

Download-Link (Box.net)

Code: Alles auswählen

; ===== 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().
; =================================

Re: [Module] PurePDF

Verfasst: 28.09.2017 22:42
von Thorsten1867
Update:

- Bugfixes
- Anpassungen bei Befehlsnamen (z.B. DrawSector usw.)
- Beispiele (Tutorial 1-32) hinzugefügt

Re: [Module] PurePDF

Verfasst: 21.12.2017 22:38
von MenschMarkus
Gefällt mir :allright:

Re: [Module] PurePDF

Verfasst: 27.12.2017 22:28
von MenschMarkus
Edit: 27.12.2017

Es ist ein unschöner Effekt aufgetreten. Bei Positionierung von MultiCell Inhalt, welcher über den Seitenumbruch geht wird die Y Positionierung auf der folgenden Seite fortgesetzt und nicht wie vorgesehen auf der aktuellen Seite, auf der der Eintrag begonnen hat und stehen sollten.
Hier mal das Beispiel mit Muster eines Geschäftspapiers:

Code: Alles auswählen

;purepdf test
;
IncludeFile "PurePdfModule.pbi"

Global lorem.s = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt" +
                 " ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo" +
                 " dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit" +
                 " amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt" +
                 " ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo" +
                 " dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."

Procedure Header()
  PDF::SetPosY(5)
  PDF::Ln(16)
  PDF::SetFont("Helvetica","I",10)
  PDF::SetTextColor(127,127,127)
  PDF::SetPosX(10)
  PDF::Cell(190,8,"H    i     e     r           e     i     n            H     E     A     D     E     R",0,1,PDF::#ALIGN_CENTER)
  PDF::Ln(10)
EndProcedure
Procedure Footer()
  Protected lw1.i=18,lw2.i=45,lh.i=3
  PDF::SetPosY(-20)
  PDF::SetFont("Helvetica","I",5)
  PDF::SetTextColor(127,127,127)
  ;{ Fußtext Zeile 1)
  PDF::Cell(lw1,lh,"Adresse ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"Firmenname",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"Bank",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"Name der Bank",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"Kontakt",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"Telefonnummer",0,1,PDF::#ALIGN_LEFT)
  ;}
  ;{ Fußtext Zeile 2
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"Strasse Hausnummer",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"BLZ:  000 000 00",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"Faxnummer",0,1,PDF::#ALIGN_LEFT)
  ;}
  ;{ Fußtext Zeile 3
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"PLZ Ort",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"Konto: 000 000 000",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"Mail: hier_mail@adresse.de",0,1,PDF::#ALIGN_LEFT)
  ;}
  ;{ Fußtext Zeile 4
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"Zusatztext",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"IBAN: DE00000000000000000000",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"URL: www.hier-url.de",0,1,PDF::#ALIGN_LEFT)
  ;}
  ;{ Fußtext Zeile 5
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"UStID Nr/ VAT ID: ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"BIC: ABCDEFGH",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw1,lh,"   ",0,0,PDF::#ALIGN_LEFT)
  PDF::Cell(lw2,lh,"Geschäftsführer",0,1,PDF::#ALIGN_LEFT)
  ;}
  ;PDF::Cell(0,8,"Page "+Str(PDF::GetPageNum())+"/{nb}",0,0,PDF::#ALIGN_CENTER)
EndProcedure
Procedure pdfmain()
  Protected i.i,file$="Tutorial02.pdf", gypos.f
If PDF::Create("P","mm",PDF::#PAGE_FORMAT_A4)
  PDF::SetProcFooter(@Footer())
  PDF::SetProcHeader(@Header())
  PDF::AliasNbPages();
  PDF::AddPage("P",PDF::#PAGE_FORMAT_A4);
  For i = 1 To 10 Step 2
    gypos = PDF::GetPosY()
    PDF::MultiCell(90,5,lorem + Str(i),0,PDF::#ALIGN_LEFT);
    PDF::SetPosY(gypos)
    PDF::SetPosX(100)
    PDF::MultiCell(90,5,lorem + Str(i),0,PDF::#ALIGN_LEFT);
  Next
  PDF::Save(file$)
EndIf
RunProgram(file$)
EndProcedure

pdfmain()