Sammlung aller PureBasic Extensions by RSBasic
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

135 lines
6.5 KiB

EnableExplicit
Define PBEx_PDF
#PBEx_PDF_PageOrientation_Portrait = 0
#PBEx_PDF_PageOrientation_Landscape = 1
#PBEx_PDF_PageSize_A0 = 1
#PBEx_PDF_PageSize_A1 = 2
#PBEx_PDF_PageSize_A2 = 3
#PBEx_PDF_PageSize_A3 = 4
#PBEx_PDF_PageSize_A4 = 5
#PBEx_PDF_PageSize_A5 = 6
#PBEx_PDF_PageSize_B0 = 7
#PBEx_PDF_PageSize_B1 = 8
#PBEx_PDF_PageSize_B2 = 9
#PBEx_PDF_PageSize_B3 = 10
#PBEx_PDF_PageSize_B4 = 11
#PBEx_PDF_PageSize_B5 = 12
#PBEx_PDF_PageSize_RA0 = 13
#PBEx_PDF_PageSize_RA1 = 14
#PBEx_PDF_PageSize_RA2 = 15
#PBEx_PDF_PageSize_RA3 = 16
#PBEx_PDF_PageSize_RA4 = 17
#PBEx_PDF_PageSize_RA5 = 18
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
PBEx_PDF = OpenLibrary(#PB_Any, "PB.Ex_PDF_x86.dll")
CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64
PBEx_PDF = OpenLibrary(#PB_Any, "PB.Ex_PDF_x64.dll")
CompilerEndIf
If PBEx_PDF
Prototype CreatePDF(ID, ErrorOutput)
Define CreatePDF.CreatePDF = GetFunction(PBEx_PDF, "CreatePDF")
Prototype SetPDFTitle(ID, Title.p-Unicode, ErrorOutput)
Define SetPDFTitle.SetPDFTitle = GetFunction(PBEx_PDF, "SetPDFTitle")
Prototype SetPDFAuthor(ID, Author.p-Unicode, ErrorOutput)
Define SetPDFAuthor.SetPDFAuthor = GetFunction(PBEx_PDF, "SetPDFAuthor")
Prototype SetPDFSubject(ID, Subject.p-Unicode, ErrorOutput)
Define SetPDFSubject.SetPDFSubject = GetFunction(PBEx_PDF, "SetPDFSubject")
Prototype SetPDFKeywords(ID, Keywords.p-Unicode, ErrorOutput)
Define SetPDFKeywords.SetPDFKeywords = GetFunction(PBEx_PDF, "SetPDFKeywords")
Prototype SetPDFCreator(ID, Creator.p-Unicode, ErrorOutput)
Define SetPDFCreator.SetPDFCreator = GetFunction(PBEx_PDF, "SetPDFCreator")
Prototype GetPDFTitle(ID, Output, ErrorOutput)
Define GetPDFTitle.GetPDFTitle = GetFunction(PBEx_PDF, "GetPDFTitle")
Prototype GetPDFAuthor(ID, Output, ErrorOutput)
Define GetPDFAuthor.GetPDFAuthor = GetFunction(PBEx_PDF, "GetPDFAuthor")
Prototype GetPDFSubject(ID, Output, ErrorOutput)
Define GetPDFSubject.GetPDFSubject = GetFunction(PBEx_PDF, "GetPDFSubject")
Prototype GetPDFKeywords(ID, Output, ErrorOutput)
Define GetPDFKeywords.GetPDFKeywords = GetFunction(PBEx_PDF, "GetPDFKeywords")
Prototype GetPDFCreator(ID, Output, ErrorOutput)
Define GetPDFCreator.GetPDFCreator = GetFunction(PBEx_PDF, "GetPDFCreator")
Prototype AddPDFText(ID, Text.p-Unicode, ErrorOutput)
Define AddPDFText.AddPDFText = GetFunction(PBEx_PDF, "AddPDFText")
Prototype SavePDF(ID, Path.p-Unicode, ErrorOutput)
Define SavePDF.SavePDF = GetFunction(PBEx_PDF, "SavePDF")
Prototype AddPDFPage(ID, ErrorOutput)
Define AddPDFPage.AddPDFPage = GetFunction(PBEx_PDF, "AddPDFPage")
Prototype ClosePDF(ID, ErrorOutput)
Define ClosePDF.ClosePDF = GetFunction(PBEx_PDF, "ClosePDF")
Prototype IsPDF(ID, ErrorOutput)
Define IsPDF.IsPDF = GetFunction(PBEx_PDF, "IsPDF")
Prototype SetPDFFont(ID, FontName.p-Unicode, FontSize, FontStyle, ErrorOutput)
Define SetPDFFont.SetPDFFont = GetFunction(PBEx_PDF, "SetPDFFont")
Prototype ProtectPDF(ID, UserPassword.p-Unicode, OwnerPassword.p-Unicode, PermissionForExtract, PermissionForModification, PermissionForFormFill, PermissionForAnnotation, PermissionForPrint, PermissionForPrintFullQuality, ErrorOutput)
Define ProtectPDF.ProtectPDF = GetFunction(PBEx_PDF, "ProtectPDF")
Prototype OpenPDF(ID, Path.p-Unicode, Password.p-Unicode, ErrorOutput)
Define OpenPDF.OpenPDF = GetFunction(PBEx_PDF, "OpenPDF")
Prototype GetPDFPageTotal(ID, ErrorOutput)
Define GetPDFPageTotal.GetPDFPageTotal = GetFunction(PBEx_PDF, "GetPDFPageTotal")
Prototype SetPDFPageSize(ID, Size, Orientation, ErrorOutput)
Define SetPDFPageSize.SetPDFPageSize = GetFunction(PBEx_PDF, "SetPDFPageSize")
Prototype GetPDFPageSize(ID, ErrorOutput)
Define GetPDFPageSize.GetPDFPageSize = GetFunction(PBEx_PDF, "GetPDFPageSize")
Prototype GetPDFPageOrientation(ID, ErrorOutput)
Define GetPDFPageOrientation.GetPDFPageOrientation = GetFunction(PBEx_PDF, "GetPDFPageOrientation")
Prototype SetPDFPageMargin(ID, Top, Right, Bottom, Left, ErrorOutput)
Define SetPDFPageMargin.SetPDFPageMargin = GetFunction(PBEx_PDF, "SetPDFPageMargin")
Prototype SetPDFTextColor(ID, Color, ErrorOutput)
Define SetPDFTextColor.SetPDFTextColor = GetFunction(PBEx_PDF, "SetPDFTextColor")
EndIf
Define Output$ = Space(1000000)
Define ErrorOutput$ = ""
Define MyText$ = ""
MyText$ + "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor." + Chr(13)
MyText$ + "Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus." + Chr(13)
MyText$ + "Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem." + Chr(13)
MyText$ + Chr(13)
MyText$ + "Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus." + Chr(13)
MyText$ + Chr(13)
MyText$ + "Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue."
If CreatePDF(1, @ErrorOutput$)
SetPDFTitle(1, "My title", @ErrorOutput$)
SetPDFAuthor(1, "RSBasic", @ErrorOutput$)
SetPDFSubject(1, "My title", @ErrorOutput$)
SetPDFTitle(1, "My title", @ErrorOutput$)
SetPDFKeywords(1, "pb, html, cpp, js, asm, vb", @ErrorOutput$)
SetPDFCreator(1, "RSBasic", @ErrorOutput$)
SetPDFPageSize(1, #PBEx_PDF_PageSize_A4, #PBEx_PDF_PageOrientation_Portrait, @ErrorOutput$)
SetPDFPageMargin(1, 50, 50, 50, 50, @ErrorOutput$)
SetPDFFont(1, "Arial", 16, 0, @ErrorOutput$)
SetPDFTextColor(1, RGBA(0, 0, 0, 255), @ErrorOutput$)
AddPDFText(1, MyText$, @ErrorOutput$)
AddPDFPage(1, @ErrorOutput$)
SetPDFPageSize(1, #PBEx_PDF_PageSize_A3, #PBEx_PDF_PageOrientation_Landscape, @ErrorOutput$)
SetPDFFont(1, "Courier", 20, #PB_Font_Underline | #PB_Font_Italic, @ErrorOutput$)
SetPDFTextColor(1, RGBA(255, 0, 0, 150), @ErrorOutput$)
AddPDFText(1, "Hello PureBasic Friends. How are you?", @ErrorOutput$)
SavePDF(1, GetCurrentDirectory() + "MyPDF.pdf", @ErrorOutput$)
ClosePDF(1, @ErrorOutput$)
RunProgram(GetCurrentDirectory() + "MyPDF.pdf")
EndIf
CloseLibrary(PBEx_PDF)
; IDE Options = PureBasic 5.70 LTS (Windows - x64)
; CursorPosition = 66
; FirstLine = 42
; EnableXP
; EnableUser
; CompileSourceDirectory
; EnableCompileCount = 136
; EnableBuildCount = 0

Impressum | Datenschutz