• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

pdf printing of a selected area

  • Thread starter Thread starter Lubracali
  • Start date Start date

Lubracali

Guest
Hello, everyone.

I am creating a vba userform that allows me to draw some elements in 2d.

I created a button that allows me to export in pdf using the printer "adobe pdf" created by acrobat pro.

The code is this
Code:
private sub cmdpdf_click()
dim stampa as acadplot
dim nbackgroundplot as long


nbackgroundplot = thisdrawing.getvariable("backgroundplot")

call thisdrawing.setvariable("backgroundplot", 0)

set stampa = thisdrawing.plot
stampa.plottodevice ("adobe pdf")

call thisdrawing.setvariable("backgroundplot", nbackgroundplot)


end sub
The code works, I can print, but there's a problem.

the problem is that in this way I can print, but print what decides autocad, in the format that decides him(I think it is the default printer).

I would need to be able to decide the output format (i.e. the format of the pdf) and which area to print (when selecting printing -> window and selecting the rectangular area).

If someone knew how to indicate me a property or a command other than that used by me that would allow me to do it would make me a great pleasure :)
 
Hello, everyone.

I am creating a vba userform that allows me to draw some elements in 2d.

I created a button that allows me to export in pdf using the printer "adobe pdf" created by acrobat pro.

The code is this
Code:
private sub cmdpdf_click()
dim stampa as acadplot
dim nbackgroundplot as long


nbackgroundplot = thisdrawing.getvariable("backgroundplot")

call thisdrawing.setvariable("backgroundplot", 0)

set stampa = thisdrawing.plot
stampa.plottodevice ("adobe pdf")

call thisdrawing.setvariable("backgroundplot", nbackgroundplot)


end sub
The code works, I can print, but there's a problem.

the problem is that in this way I can print, but print what decides autocad, in the format that decides him(I think it is the default printer).

I would need to be able to decide the output format (i.e. the format of the pdf) and which area to print (when selecting printing -> window and selecting the rectangular area).

If someone knew how to indicate me a property or a command other than that used by me that would allow me to do it would make me a great pleasure :)
Good morning, I would also be interested in the solution as I am in the same situation.
at the moment the code I produced from excel with the vba and reported below.

Say hi.

Code:
on error resume next
        
    set acadapp = interaction.getobject(, "autocad.application")
    'set acadapp = interaction.getobject(, "autocad.application.22")
    'both statements above behave without any discernible difference
    
    if err then
        debug.print "error " & err.number
        debug.print err.description
        debug.print "starting autocad"
                
        err.clear
                      
         set acadapp = new acadapplication
         'set acadapp = interaction.createobject("autocad.application.22")
         'both statements above behave without any discernible difference
        
        'essential statement
        acadapp.visible = true
        
        if err then
             msgbox err.description
             exit sub
        end if
    end if
    
    debug.print "now running " + acadapp.name + " version " + acadapp.version
          
    set acaddoc = acadapp.activedocument
        if acaddoc is nothing then
            set acaddoc = acadapp.documents.add
        end if
  
    if acaddoc.activespace = 0 then
       acaddoc.activespace = 1
    end if
    
end sub



private sub commandbutton8_click()
    
    call connect_acad
    redim preserve strartpoint10(0 to 1)
    dim pointfinal(0 to 1) as double
    dim pointfina2(0 to 1) as double
    dim ptconfigs as acadplotconfigurations
    dim plotconfig as acadplotconfiguration
    dim ptobj as acadplot
    dim backplot as variant
    
    
    pointfinal(0) = strartpoint10(0)
    pointfinal(1) = strartpoint10(1) - 29.7
    pointfina2(0) = strartpoint10(0) + 42
    pointfina2(1) = strartpoint10(1) - 29.7
    
    set ptobj = acaddoc.plot
    set ptconfigs = acaddoc.plotconfigurations
    ptconfigs.add "pdf", false
    set plotconfig = ptconfigs.item("pdf")
    plotconfig.standardscale = acscaletofit
    plotconfig.refreshplotdeviceinfo

    plotconfig.setwindowtoplot pointfinal, pointfina2
    plotconfig.getwindowtoplot pointfinal, pointfina2
    plotconfig.configname = "dwg to pdf.pc3"
    'plotconfig.stylesheet = "monochrome.ctb"
    'plotconfig.centerplot = true
    
    plotconfig.refreshplotdeviceinfo
    plotconfig.plottype = acwindow
    plotconfig.canonicalmedianame = "iso_a3_(420.00_x_297.00_mm)"
    plotconfig.refreshplotdeviceinfo

    if ptobj.plottofile(replace(acaddoc.fullname, "dwg", "pdf"), plotconfig.configname) then
        msgbox "pdf creato"
    else
        msgbox "pdf non creato"
    end if
    ptconfigs.item("pdf").delete
    set plotconfig = nothing
    
 end sub
 
Last edited:

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top