[Module] pbPDF-Module

Hier könnt Ihr gute, von Euch geschriebene Codes posten. Sie müssen auf jeden Fall funktionieren und sollten möglichst effizient, elegant und beispielhaft oder einfach nur cool sein.
Benutzeravatar
Thorsten1867
Beiträge: 1359
Registriert: 04.02.2005 15:40
Computerausstattung: [Windows 10 x64] [PB V5.7x]
Wohnort: Kaufbeuren
Kontaktdaten:

[Module] pbPDF-Module

Beitrag von Thorsten1867 »

Für ein Projekt benötige ich eine plattformübergreifende und etwas "handlichere" Version von PurePDF.
Somit habe ich auf der Basis von PurePDF ein neues PDF-Modul entwickelt.
Nachdem ich viele Befehle (hoffentlich) etwas intuitiver gestaltet habe, ist pbPDF leider nicht mehr mit PurePDF kompatibel.

pbPDF - Module
  • Erstellen von Formularen (AcroForms)
  • Verschlüsselung (Passwortschutz & Zugriffsberechtigungen)
  • Nutzung der PB Packer Library anstatt externer Komprimierungs-Prozeduren
  • Auslesen von Font- und Image-Headern nur mit PB-Befehlen anstatt mit Windows-API
  • Unterstützung des JPEG2000-Bildformates
  • Unterstützung von Unicode-Zeichensätzen
  • 64-Bit kompatibel
  • Entfernung von "Altlasten" (ASCII85 / WMF) und Verzicht auf Assembler

Code: Alles auswählen

  ; ----- Basic Commands -----

  ; PDF::Create()                      - Create PDF document.
  ; 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::DividingLine()                - Draws a line with the specified width.
  ; PDF::GetFontSize()                 - Get current fontsize (#Point/#Unit)
  ; PDF::GetMargin()                   - Get left, top, right or cell margin.
  ; PDF::GetMultiCellLines()           - Get the last value of newlines for pdf_MultiCell()
  ; PDF::GetPageHeight()               - Get current height of page.
  ; PDF::GetPageNumber()               - Returns the current page number.
  ; PDF::GetPageWidth()                - Get current width of page. 
  ; PDF::GetPosX()                     - Returns the abscissa of the current position.
  ; PDF::GetPosY()                     - Returns the ordinate of the current position.
  ; PDF::GetStringWidth()              - Get width of a string in the current font.
  ; PDF::Image()                       - Puts an image in the page.
  ; PDF::Ln()                          - Performs a line break.
  ; PDF::MultiCell()                   - This method allows printing text with line breaks.
  ; PDF::MultiCellList()               - Add multicell with list elements
  ; PDF::PlaceText()                   - Place text at x, y position.  
  ; PDF::Rotate()                      - Perform a rotation around a given center.
  ; PDF::Save()                        - Save PDF under file name
  ; PDF::SetAutoPageBreak()            - Set auto page break mode and triggering margin.
  ; PDF::SetColorRGB()                 - Set RGB color for text, draw and fill  (#TextColor / #DrawColor / #FillColor).
  ; PDF::SetDashedLine()               - 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::SetPageNumbering()            - Set page numbering in footer #True/#False.
  ; PDF::SetInfo()                     - Defines author, titel, subject, creator and associated keywords ('keyword1 keyword2 ...') of the document
  ; PDF::SetLineThickness()            - Defines the line thickness.
  ; PDF::SetMargin()                   - Set left, top, right or cell margin.
  ; PDF::SetPageMargins()              - Set left, top and right page margins.
  ; PDF::SetPosXY()                    - Defines the abscissa and ordinate of the current position.
  ; PDF::SetPosX()                     - Defines the abscissa of the current position. 
  ; PDF::SetPosY()                     - Moves the current abscissa back to the left margin and sets the ordinate.
  ; PDF::SubWrite()                    - Write superscripted or supscripted
  ; PDF::TruncateCell()                - Prints a Cell, if text is too large it will be truncated
  ; PDF::Write()                       - This method prints text from the current position.
  
  ; ----- Advanced Commands -----
  
  ; PDF::EmbedFile()                   - Embeds a file into the pdf.
  ; PDF::EmbedFont()                   - Embeds a font into the pdf and returns the font name.
  ; PDF::EmbedJavaScript()             - Add JavaScript
  ; PDF::EmbedJavaScriptFile()         - Include JavaScript file
  ; PDF::EnableFooter()                - Enable/disable Footer (procedure)
  ; PDF::EnableHeader()                - Enable/disable Header (procedure)
  ; PDF::EnableTOCNums()               - Enable/disable adding page numbers to table of contents
  ; PDF::AddEntryTOC()                 - Add TOC entry
  ; PDF::EscapeText()                  - Format a text string (=> masked string).
  ; PDF::GetErrorCode()                - Return the error code.
  ; PDF::GetErrorMessage()             - Return the error message.    
  ; PDF::GetNumbering()                - Return if numbering is #True/#False. Usefull for TOC functions
  ; PDF::GetObjectNum()                - Get object number
  ; PDF::GetScaleFactor()              - Get scale factor for used unit.
  ; PDF::GetWordSpacing()              - Get word spacing.  
  ; PDF::ImageMemory()                 - Puts an image (Memory) in the page.
  ; PDF::InsertTOC()                   - Insert table of contents.
  ; PDF::Link()                        - Puts a link on a rectangular area of the page.
  ; PDF::SetAliasTotalPages()          - Defines an alias for the total number of pages.
  ; PDF::SetColorCMYK()                - Set CMYK color for text, draw and fill (#TextColor / #DrawColor / #FillColor).
  ; PDF::SetEncryption()               - Enable encryption and set passworts and permission
  ; PDF::SetFooterProcedure()          - Set footer procedure.
  ; PDF::SetHeaderProcedure()          - Set header procedure.
  ; PDF::SetOpenAction()               - Set page and zoom for opening the document
  ; PDF::SetPageCompression()          - Enable/disable compression for pages
  ; PDF::SetPageLayout()               - Define display mode for pages in the viewer
  ; PDF::SetPageMode()                 - Define mode and appearance of the viewer (e.g. fullscreen mode)
  ; PDF::SetViewerPreferences()        - Set viewer preferences
  ; PDF::SetWordSpacing()              - Set word spacing. 
  
  ; ----- AcroForms [#Enable_AcroFormCommands] ------
  
  ; PDF::ButtonField()                 - Button field (PushButton / CheckBox / RadioButton)
  ; PDF::ChoiceField()                 - Choice field (Scrolling List / ComboBox / editable ComboBox)
  ; PDF::TextField()                   - Text field   (single line/ multiline)
  
  ; ----- Annotations & Actions [#Enable_Annotations] -----
  
  ; PDF::AddFileLink()                 - Defines the page and position for embedded file annotations. (#GraphIcon/#PaperClipIcon/#PushPinIcon/#TagIcon)
  ; PDF::AddGotoAction()               - Goto page and position in the document
  ; PDF::AddGotoLabel()                - Set Label to be able to jump to this position
  ; PDF::AddLaunchAction()             - Defines the page and position for a launch action. (#OpenAction/#PrintAction)
  ; PDF::AddLinkURL)                   - Defines the page and position a link points to and returns its identifier.
  ; PDF::AddTextNote()                 - Defines the page and position for text annotations. ( #CommentIcon/#KeyIcon/#NoteIcon/#HelpIcon/#NewParagraphIcon/#ParagraphIcon/#InsertIcon )
  
  ; ----- Drawing Commands [#Enable_DrawingCommands] -----
  
  ; PDF::DrawCircle()                  - Draws a circle
  ; PDF::DrawEllipse()                 - Draws a ellipse
  ; PDF::DrawGrid()                    - Draws a light blue grid on the page for testing purposes
  ; PDF::DrawLine()                    - Draws a single line between two points.
  ; PDF::DrawRectangle()               - Draws a rectangle.
  ; PDF::DrawRoundedRectangle()        - Draws a rounded rectangle.
  ; PDF::DrawSector()                  - Draws the sector of a circle.
  ; PDF::DrawTriangle()                - Draws a triangle
  
  ; PDF::SetLineCap()                  - Sets the line cap style
  ; PDF::SetLineCorner()               - Sets the line join style.
  
  ; 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). 
  
  ; ----- Transformation [#Enable_TransformCommands] -----
  
  ; 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::MirrorHorizontal()            - Alias for scaling -100% in x direction. (Transform)
  ; PDF::MirrorVertical()              - Alias For scaling -100% in y direction. (Transform)
  ; PDF::ScaleHorizontal()             - Scaling horizontal        (Transform)
  ; PDF::ScaleVertical()               - Scaling vertical          (Transform)
  ; PDF::Scale()                       - Scaling                   (Transform)
  ; PDF::SkewHorizontal()              - Skewing -> angle x        (Transform)
  ; PDF::SkewVertical()                - Skewing -> angle y        (Transform)
  ; PDF::Translate()                   - Translate -> right/bottom (Transform)
  ; PDF::TranslateHorizontal()         - Translate -> right        (Transform)
  ; PDF::TranslateVertical()           - Translate -> bottom       (Transform)
Download: pbPDFModule.pbi
Zuletzt geändert von Thorsten1867 am 23.11.2019 14:06, insgesamt 9-mal geändert.
Download of PureBasic - Module
Download of PureBasic - Programmes

[Windows 11 x64] [PB V6]

Bild
Benutzeravatar
RSBasic
Admin
Beiträge: 8022
Registriert: 05.10.2006 18:55
Wohnort: Gernsbach
Kontaktdaten:

Re: [Module] pbPDF-Module (Beta)

Beitrag von RSBasic »

Cool, danke für deinen Code. :allright:
Aus privaten Gründen habe ich leider nicht mehr so viel Zeit wie früher. Bitte habt Verständnis dafür.
Bild
Bild
Benutzeravatar
Thorsten1867
Beiträge: 1359
Registriert: 04.02.2005 15:40
Computerausstattung: [Windows 10 x64] [PB V5.7x]
Wohnort: Kaufbeuren
Kontaktdaten:

Re: [Module] pbPDF-Module (Beta)

Beitrag von Thorsten1867 »

Hinzugefügt: Kleine Dokumentation der Befehle in Deutsch hinzugefügt. ( pbPDF-Doku_DE.pdf )
Download of PureBasic - Module
Download of PureBasic - Programmes

[Windows 11 x64] [PB V6]

Bild
Andesdaf
Moderator
Beiträge: 2658
Registriert: 15.06.2008 18:22
Wohnort: Dresden

Re: [Module] pbPDF-Module (Beta)

Beitrag von Andesdaf »

Danke, schau ich mir zu gegebener Zeit mal genauer an!
Win11 x64 | PB 6.00 (x64)
Benutzeravatar
Thorsten1867
Beiträge: 1359
Registriert: 04.02.2005 15:40
Computerausstattung: [Windows 10 x64] [PB V5.7x]
Wohnort: Kaufbeuren
Kontaktdaten:

Re: [Module] pbPDF-Module (Beta)

Beitrag von Thorsten1867 »

Hinzugefügt:
  • Passwortschutz & Verschlüsselung
  • Zugriffsberechtigungen für PDF-Dokumente

Code: Alles auswählen

#NoPrintAccess
#ModifyAccess
#CopyAccess
#AddAccess 
#FormAccess
#Extract
#Assemble
#DigitalCopy
Zuletzt geändert von Thorsten1867 am 20.01.2019 12:50, insgesamt 1-mal geändert.
Download of PureBasic - Module
Download of PureBasic - Programmes

[Windows 11 x64] [PB V6]

Bild
Benutzeravatar
Andre
PureBasic Team
Beiträge: 1754
Registriert: 11.09.2004 16:35
Computerausstattung: MacBook Core2Duo mit MacOS 10.6.8
Lenovo Y50 i7 mit Windows 10
Wohnort: Saxony / Deutscheinsiedel
Kontaktdaten:

Re: [Module] pbPDF-Module

Beitrag von Andre »

Toll, danke für die Weiterentwicklung :allright:

Die Beispiele und die Doku sind vielversprechend, zur konkreten eigenen Anwendung bin ich leider noch nicht gekommen...
Bye,
...André
(PureBasicTeam::Docs - PureArea.net | Bestellen:: PureBasic | PureVisionXP)
Benutzeravatar
Morty
Beiträge: 268
Registriert: 22.10.2004 07:20
Wohnort: Erfurt
Kontaktdaten:

Re: [Module] pbPDF-Module

Beitrag von Morty »

Hey,

erstmal vielen Dank für die Arbeit und das Projekt. Ich habe aber leider das gleiche Problem, wie jetzt auch im englischen Forum berichtet wurde. Alle Beispiele erstellen zwar eine PDF, diese lässt sich aber mit dem Acrobat Reader nicht öffnen. Fehler 14.

Das ist übrigens auch der Fall bei den PDFs, die Du mit den Beispielen auslieferst (im ZIP Ordner). Diese lassen sich auch schon nicht öffnen.

Das einzige was mir auffällt, aber ich weiß nicht ob das relevant ist, ist der Fakt, dass die PDFs nach der Fehlermeldung leer angezeigt werden, aber mit einer Skalierung von mehreren tausend Prozent.

System: Win 7 - 64 Bit - aber 32 Bit PB
PB: Ausprobiert mit der 5.40 LTS

Gruß,
Morty
Benutzeravatar
Thorsten1867
Beiträge: 1359
Registriert: 04.02.2005 15:40
Computerausstattung: [Windows 10 x64] [PB V5.7x]
Wohnort: Kaufbeuren
Kontaktdaten:

Re: [Module] pbPDF-Module

Beitrag von Thorsten1867 »

Kann mir das nicht erklären, wo das herkam.

Habe eine neue ZIP-Datei zum Download erstellt.
Download of PureBasic - Module
Download of PureBasic - Programmes

[Windows 11 x64] [PB V6]

Bild
Benutzeravatar
Morty
Beiträge: 268
Registriert: 22.10.2004 07:20
Wohnort: Erfurt
Kontaktdaten:

Re: [Module] pbPDF-Module

Beitrag von Morty »

Super, jetzt funktioniert es. Auch die PDFs, die Du mitlieferst.

Top :allright: und vielen Dank,

Morty
Benutzeravatar
Thorsten1867
Beiträge: 1359
Registriert: 04.02.2005 15:40
Computerausstattung: [Windows 10 x64] [PB V5.7x]
Wohnort: Kaufbeuren
Kontaktdaten:

Re: [Module] pbPDF-Module

Beitrag von Thorsten1867 »

Version 2.0

Ich habe die interne Struktur des Moduls komplett geändert und an die Struktur von PDF-Dokumenten (einzelne Objekte) angepasst. Anstatt den Umweg über unzählige LinkedList zu nehmen, werden die (meisten) Daten nun direkt in die Objekte geschrieben.
Der Sourcecode ist dadurch nicht nur logischer, verständlicher und übersichtlicher geworden, sondern kann nun auch deutlich einfacher erweitert werden.

Neu:
  • Unterstützung von Formularfeldern (z.B. Textfeld, Checkbox, Radiobutton & Combobox)
  • AddGotoLabel() für die Navigation im PDF-Dokument. (z.B. von der Befehlsübersicht mittels Link zu der entsprechenden Seite springen)
Download of PureBasic - Module
Download of PureBasic - Programmes

[Windows 11 x64] [PB V6]

Bild
Antworten