Announcement

Collapse
No announcement yet.

load a PDF and print it out over XPRINT

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • load a PDF and print it out over XPRINT

    Hello PBCC-programmer,

    I need help for a problem.

    My Idea ist to load difrent PDF's an print it, but not over any extern programs.

    How can I Load the PDF - whitch parameter or function I need and how can I print it out over PBCC

    Why:

    I wrote a program with text for a letter, this letter got a lot of dates "dd.mm.yyyy" as changing parts.

    At next i need a text to explain the first text.

    I thought I can take a picture of that Make information text, but you can no longer change a static image.

    The text content of a PDF file does.

    Does anyone of you have any idea how that could work.

    sincerely

    Detlev




  • #2
    Howdy, Detley!

    Glad to see you posting!

    So, you want to load a PDF and change it's text? Does the PDF have images in it, or just plain text?

    If only plain text, then there is a freeware utility "pdftotext.exe" that you can use to extract the text for use in your app. You'd then have to format and print the text.

    I know of no way in PBCC to modify the text of a PDF directly.

    In PBCC I know of no way to load a PDF in an edit or viewing mode.

    In PBWin, one way of loading a PDF is to do so using an embedded browser, code by Jose.

    Comment


    • #3
      You can load PDFs using a program designed for that.. Adobe Acrobat is an example; it has a complete API which is used by many to create, modify, display and print PDF files. There is a license fee involved; you should be able to get info at Adobe's web site. .

      Portable Document Format *IS* a public standard so I suppose you could alternately obtain the specs and write your own program to do this. However, I know of no available source code you could use or modify for use with PB/CC.

      MCM
      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Howdy Gary,

        please cal me Delv it's wel shorter.

        I took now the first solution and make a picture of my explaner text.

        But wow, I was very perplexed when I saw the rendered image on the monitor and how small it was when it was printed out. A little fiddling was necessary.

        You don't get what you expected to have loaded. - WISIWIG ad adsurdum


        ' BK_BMP_2020 - Betriebskostenabrechnung drucken - GRAPHIC Version 24.12.2010
        '
        ' #RESOURCE "BK_MO2.PBR"

        #COMPILE EXE
        #DIM ALL
        #CONSOLE OFF

        #INCLUDE "GR_C_ED.INC"
        '
        GLOBAL ff, w, h AS LONG, hBmp AS DWORD, lks AS INTEGER, FileName AS STRING ' Bild
        '
        GLOBAL PixW,PixH,x1,y1,x2,y2,hwin,bkgr,CarW,CarH,MaxCol,MaxRow AS LONG
        GLOBAL NV,GV,LV,RV,BV,HH AS LONG ' farbe
        GLOBAL pt,zeile,spalte,le,sc,dummy,lge,kurz,la,RES,nle,tenu,vl,pkt,art AS INTEGER
        GLOBAL fn,cp,fnt,z,taste,tx,TXT,ch AS STRING
        '
        GLOBAL A,daten AS STRING
        GLOBAL x AS INTEGER
        GLOBAL Moni_w,Moni_h AS INTEGER
        GLOBAL Prtn_w,Prtn_h AS INTEGER



        GLOBAL dn AS CURRENCY

        GLOBAL nudat,dat,mutad AS STRING
        GLOBAL D1,N,links,l,o,p,x,dummy,I,WAHL AS INTEGER
        '
        '
        FUNCTION PBMAIN () AS LONG

        DIM Listing(1000) AS GLOBAL STRING

        ' OPEN "COLOR.DAT" FOR INPUT AS #3
        ' INPUT #3,NV
        ' INPUT #3,GV
        ' INPUT #3,LV
        ' INPUT #3,RV
        ' INPUT #3,BV
        ' INPUT #3,HH
        ' INPUT #3,fnt ' Schrifttype / Font
        ' INPUT #3,pkt ' Punkt / Point
        ' INPUT #3,art ' Verifizierung /
        ' CLOSE #3

        NV = &HF0D631 ' Bernstein / Amber
        GV = &H00CC00 ' Grün / Green
        LV = &HC480FC ' Lila / Purple
        RV = &HFF0000 ' Rot / Red
        BV = &H0000FF ' Blau / Blue
        HH = &H000000 ' Schwarz / Black
        fnt = "Courier New"
        pkt = 20
        art = 0


        ' Monitor 1920 x 1050 pix
        DESKTOP GET CLIENT TO PixW,PixH: x1=0: y1=0: x2=PixW-10: y2=PixH-34

        cp="BK_MO2_2020 --- Betriebskostenabrechnung drucken"
        GRAPHIC WINDOW cp,x1,y1,x2,y2 TO hwin
        GRAPHIC ATTACH hwin,0
        GRAPHIC CLEAR RGB(HH),RGB(NV)
        GRAPHIC COLOR RGB(NV),RGB(HH) ' Schwarzer Hintergrund mit nahem Bernstein Text wie in alten Zeiten
        GRAPHIC GET PIXEL (2,2) TO bkgr ' Find Background color if other colors used instead of black
        GRAPHIC FONT fnt,pkt,art ' Selektiere FONT Type,Punkt,Darstellung
        GRAPHIC CHR SIZE TO CarW,CarH ' Find pixel width and height of chosen graphic font
        MaxCol=PixW/CarW
        MaxRow=PixH/CarH ' Maximums will depend on number of pixels on desktop
        '
        ' Umsteuerung der Datumsvariablen
        '
        ' GER=MID$(DATE$,4,2)+"."+MID$(DATE$,1,2)+"."+MID$(DATE$,7,4)

        '
        '
        GRAPHIC CLEAR

        GRAPHIC SET POS (1*CarW,0*CarH)
        o = 0
        p = 0
        x = 0
        A = DIR$("????????.BMP")
        WHILE LEN(A) AND x < 1000 ' max = 1000
        INCR x
        Listing(x) = A
        A = DIR$
        IF (o MOD 80)=0 THEN o = 0 : p = p + 1
        GRAPHIC COLOR RGB(GV),RGB(HH)
        GRAPHIC SET POS (o*CarW,p*CarH) : GRAPHIC PRINT USING$("###",x)
        GRAPHIC COLOR RGB(NV),RGB(HH)
        GRAPHIC SET POS ((o+4)*CarW,p*CarH) : GRAPHIC PRINT USING$("\ ",Listing(x))
        GRAPHIC REDRAW
        o = o + 20
        WEND
        GRAPHIC SET POS (1*CarW,24*CarH) : GRAPHIC PRINT"Dateinummer:" : GRAPHIC REDRAW
        mutad=""
        CALL ceditor(NV,HH,GV,HH,CarW,CarH,24,14,4,2,mutad,dn)
        IF mutad="" AND dn=0 THEN exi
        daten=Listing(dn)

        FileName=daten

        ff = FREEFILE
        OPEN FileName FOR BINARY AS #ff
        IF ERR THEN
        PRINT ERROR$(ERR)
        EXIT FUNCTION
        END IF
        GET #ff, 19, w ' 19
        GET #ff, 23, h ' 23
        CLOSE #ff



        lks=0
        Moni_w = w * 1.5
        Moni_h = h * 1.5
        GRAPHIC CLEAR
        GRAPHIC PRINT daten,w,h
        GRAPHIC RENDER FileName, (lks, 0)-(lks+(Moni_w), Moni_h)


        Prtn_w = w * 8
        Prtn_h = h * 8

        ERRCLEAR
        XPRINT ATTACH DEFAULT
        IF ERR = 0 AND LEN(XPRINT$) > 0 THEN
        XPRINT SET ORIENTATION 2
        '
        ' XPRINT RENDER FileName, (lks, 0)-(lks+(w*3.2), h*3.2)
        XPRINT RENDER FileName, (lks, 0)-(lks+(Prtn_w),Prtn_h)
        '
        '
        XPRINT FORMFEED ' Issue a formfeed
        XPRINT CLOSE ' detach the printer
        END IF





        exi:
        LOCAL PID AS DWORD
        PID=SHELL("BK_2020")
        GRAPHIC WINDOW END

        finito:
        END
        END FUNCTION



        my INC file to it --->


        GR_C_ED.INC
        '
        ' cv1 = Color Vordergrund )
        ' ch1 = Color Hintergrund ) - einschalten
        ' cv2 = Color Vordergrund )
        ' ch2 = Color Hintergrund ) - ausschalten
        ' CarW = Spalte pixeltechnisch
        ' CarH = Zeile pixeltechnisch
        ' y = Zeile
        ' x = Spalte
        ' vl = Feldlängenbeschränkung der Eingabe
        ' tenu = : Text = 1 Währung = 2
        ' txt = alphanum Ruckgabe
        ' num = numerische Rückgabe (Währung)
        '

        SUB ceditor(cv1 AS LONG,ch1 AS LONG,cv2 AS LONG ,ch2 AS LONG,CarW AS LONG ,CarH AS LONG,y AS INTEGER ,x AS INTEGER,vl AS INTEGER,tenu AS INTEGER,TXT AS STRING,num AS CURRENCY)
        started:

        GRAPHIC COLOR RGB(cv2),RGB(ch2)

        LOCAL le,sc,n,tl,kurz,lg,result,nle AS INTEGER
        LOCAL taste,tx AS STRING

        le=LEN(TXT)+1
        GRAPHIC SET POS (x*CarW,y*CarH) : GRAPHIC PRINT STRING$(le,32)
        GRAPHIC SET POS (x*CarW,y*CarH) : GRAPHIC PRINT STRING$(vl,149)
        GRAPHIC SET POS (x*CarW,y*CarH) : GRAPHIC PRINT TXT : GRAPHIC REDRAW
        '
        fraed:
        GRAPHIC INKEY$ TO taste
        IF taste="" THEN fraed
        '
        IF taste="," THEN taste="."
        ' IF taste =CHR$(148) THEN taste=CHR$(246):' ö
        ' IF taste =CHR$(132) THEN taste=CHR$(252):' ä
        ' IF taste =CHR$(129) THEN taste=CHR$(228):' ü
        ' IF taste =CHR$(225) THEN taste=CHR$(223):' ß
        ' IF taste =CHR$(153) THEN taste=CHR$(214):' Ö
        ' IF taste =CHR$(142) THEN taste=CHR$(220):' Ä
        ' IF taste =CHR$(154) THEN taste=CHR$(196):' Ü
        '
        SELECT CASE tenu
        CASE 1
        GOTO weitered
        CASE 2
        sc=ASC(RIGHT$(taste,1))
        IF (sc>31 AND sc<45) OR (sc>57 AND sc<256) THEN GOSUB jumped:GOTO backed
        END SELECT

        weitered:
        ' [Entf]
        IF taste=CHR$(0)+CHR$(83) THEN
        TXT=CHR$(238)
        '
        GRAPHIC COLOR RGB(cv2),RGB(ch2)
        GRAPHIC SET POS (x*CarW,y*CarH) : GRAPHIC PRINT TXT
        GRAPHIC REDRAW
        GOTO exed
        END IF
        ' [Einf]
        IF taste=CHR$(0)+CHR$(82) THEN
        TXT=CHR$(237)
        '
        GRAPHIC COLOR RGB(cv1),RGB(ch1)
        GRAPHIC SET POS (x*CarW,y*CarH) : GRAPHIC PRINT TXT
        GRAPHIC REDRAW
        GOTO exed
        END IF
        IF ASC(RIGHT$(taste,1))=8 THEN n=5:GOSUB jumped:GOTO backed:' backspace
        IF ASC(RIGHT$(taste,1))=13 THEN taste="":GOTO exed:' taste return
        '
        backed:
        TXT=TXT+taste
        tl=LEN(TXT)
        IF tl>vl THEN BEEP:GOSUB jumped
        GOTO started
        '
        jumped:
        ' L”scht die letzte gedrckte Taste
        taste=""'
        ' Soll den mit LEN() gemessenen
        ' Text um 'ein' Zeichen reduzieren
        kurz=1
        lg=LEN(TXT)
        result=lg-kurz
        IF result<=0 THEN result=1:TXT="":tx=""
        tx=LEFT$(TXT,result)
        ' šbergabe des Stringergebnisses
        TXT=tx
        RETURN
        '
        exed:
        ' Berechnet den Zahlenwert des Textes mittels
        ' des internen Befehls VAL()


        ' If tenu=1 Then num=0 Else If tenu=2 Then num=Val(txt)
        SELECT CASE tenu
        CASE 1
        num=0
        num = VAL(TXT)
        nle = vl - LEN(TXT)
        GRAPHIC COLOR RGB(cv1),RGB(ch1)
        GRAPHIC SET POS (x*CarW,y*CarH) : GRAPHIC PRINT STRING$(nle,32) + TXT
        GRAPHIC REDRAW
        GOTO ex
        CASE 2
        num=VAL(TXT)
        nle=vl-LEN(TXT)
        ' COLOR cv1,ch1
        GRAPHIC COLOR RGB(cv1),RGB(ch1)
        GRAPHIC SET POS (x*CarW,y*CarH) : GRAPHIC PRINT STRING$(nle,32) + TXT
        GRAPHIC REDRAW

        GOTO ex
        ex:
        END SELECT




        ' Modifiziert: Hilfstext löschen - kill the Helptext
        ' locate 15,10 : Print" "
        ' locate 16,10 : Print" "
        ' locate 17,10 : Print" "
        ' locate 18,10 : Print" "
        '

        END SUB

        Comment


        • #5
          help standarttext

          Comment


          • #6
            the JPG must convert to BMP

            Comment


            • #7
              Is MS Word available Detlev?

              Word can have "variables" in a document.

              Word can be "driven" by COM in either PBWin or PBCC to set variable(s) and have Word Save As PDF.

              The version of Adobe Acrobat I have can Convert to Word doc. So, both directions covered.

              I hope this triggers an idea, because I have no demo code.

              Cheers,
              Dale

              Comment


              • #8
                Wow, lots of posts after post 2
                Dale

                Comment


                • #9
                  Dear Dale,

                  not that what I want.

                  I want start my text with parameters print

                  after behind print the pdf - without change to extern program

                  perhaps a *.BAT (batch event)



                  Comment


                  • #10
                    after behind print the pdf - without change to extern program

                    perhaps a *.BAT (batch event)
                    ?????

                    Invoking a command (*.CMD) (replaces *.BAT) file calls a separate external program ( the command interpreter.)

                    Besides, what's so bad about using an external program to accomplish a goal?

                    MCM
                    Michael Mattias
                    Tal Systems Inc. (retired)
                    Racine WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Dear Michael,

                      it is a problem of time --> John Ford: Time is money and money is time.

                      I have wrote in this forum, that a picture nearly a same way is.

                      It could have been that someone had already programmed something similar.

                      Unfortunately a lot of knowledge has been lost with the abandonment of the old forum.

                      There is no really good manual for Powerbasic either.

                      Bye

                      Detlev

                      Comment


                      • #12
                        Originally posted by Detlev Wuulff View Post

                        There is no really good manual for Powerbasic either.
                        There is this but it has a lot of duplicate pages.

                        Comment


                        • #13
                          Originally posted by Detlev Wuulff View Post
                          Unfortunately a lot of knowledge has been lost with the abandonment of the old forum.
                          Most of the old forum knowledge is still here, it's just that you need to modify the links in old posts.

                          Just change

                          http://www.powerbasic.com/support/pbforums/showthread.php?t=xxxxx
                          to
                          http://forum.powerbasc.com/showthread.php?t=xxxxx

                          (same with "showpost" )

                          Comment


                          • #14
                            It [using an external program] is a problem of time --> John Ford: Time is money and money is time.
                            I you mean programming time, presumably the external program is already programmed... no additional programmer time required.

                            If you mean execution time, you need to try it and time it; it is really no load at all. And in this case, actual printing time is going to be such that no one will ever notice a delay loading the external program.

                            IMNSHO the only good reason I can think of to NOT use an external program is, when you don't control that program and are left at the mercy of the publisher for support.

                            Michael Mattias
                            Tal Systems Inc. (retired)
                            Racine WI USA
                            [email protected]
                            http://www.talsystems.com

                            Comment


                            • #15
                              Originally posted by Frank Rogers View Post

                              There is this but it has a lot of duplicate pages.
                              Sorry Frank,

                              I mean not English rather German.

                              And the version 10.0 is not the last one rather 10.04 the last changings.

                              Sometimes I could help me with Googleto tranlate: https://www.google.com/search?client...b-d&q=engl+deu !

                              Bye Detlev

                              Comment


                              • #16
                                Dear Michael,

                                you missanderstand my idea:

                                1. Termination of an apartment

                                2. Work at Text for Confirmation of termination

                                3. Print out Confirmation of termination

                                3. Surch the extern Program for Print out PDF-Data

                                4. Surch the PDF-Data

                                5. Print out the PDF

                                ====>

                                2. + 3. are ready ---> (A)

                                3.. + 4. ---> Put the Text not in a PDF rather in a BMP-Picture ---> (B)

                                Result:

                                Put (A) an (B) in one prozess.

                                If you have a lot of cancellation confirmations to write about, you're going to be pretty insane in no time.

                                Bye Detlev









                                Comment

                                Working...
                                X