MapInfo Pro

 View Only
  • 1.  MapBasic: Dynamically set the paper size based on the window size

    Posted 08-02-2023 15:53
    Edited by John Hollingsworth 08-02-2023 15:57

    Use Case: I have a written MapBasic tool (v21) that allows the user to create a new layout from a map window and then it does all the window renaming and hiding, etc. The user can choose from 8.5x11, 11x17, 18x24, and 24x36 sizes. I want to automatically configure the correct paper size based on the layout contents.

    Problem: The first two sizes are listed in the PaperSize.def file and are easy to configure. However, the last two are commonly known as ARCH C and ARCH D, respectively and these are not listed in the PaperSize.def. MapInfo leverages the printer forms in Windows and those two sizes are not listed there either.

    Need: I need to find a way to dynamically configure these paper sizes. Or run a script to add these to both the Windows paper size list and have an enumeration for both that would work with the Set Window command.

    Stuff I've Tried: Because I also need to print to the plotter, I have installed the HPGL drivers for the HP DesignJet series. Installing these drivers had the effect of adding these sizes to the options. However, each user may have a different set of printer sizes and corresponding enumerations based on the different printer drivers they have installed on their machines. Thus, I have no way of telling if printer size enumeration on my machine will match those on the user's machine.

    Research: (i.e. stuff I've read, but don't know how to make work)
    Add forms to the forms database - Windows drivers

    Plotter Driver Capabilities - Windows drivers


    Other Users Have Asked Before With No Solution:
    MapInfo PDF Printer

    MapBasic and PaperSize.Def - I agree with Peter here on the fundamental conflict with custom Windows forms. However, it is now 17 years later; is there still no solution? Can we not enumerate all of the existing printer forms and add a new one that doesn't conflict with any of the existing forms?

    Unacceptable Answers:

    - "Just make the user configure the size in Page Setup." - Friend, I have been tasked with automating this; the obvious answer will not work here.
    - "Use the C Size Sheet, D Size Sheet, A1, or A2 that do appear in the list instead of ARCH C and ARCH D" - We choose these larger sizes to match the 2' and 3' rolls of plotter paper that are commonly sold here in the US. This eliminates having to trim excess paper we would have to do if we used the given sizes.

    Thank you in advance for your consideration of this question.



    ------------------------------
    John Hollingsworth
    GIS Director
    Clear Channel Outdoor
    ------------------------------



  • 2.  RE: MapBasic: Dynamically set the paper size based on the window size

    Posted 08-07-2023 04:59
    Edited by Ahmet Dabanli 08-07-2023 05:00

    Hi John Hollingsworth,

    I have found some definition and sizes as below:
    https://learn.microsoft.com/en-us/dotnet/api/system.drawing.printing.paperkind?view=windowsdesktop-7.0 

    and here there are some .Net codes to get avilable sizes

    https://learn.microsoft.com/en-us/dotnet/api/system.drawing.printing.papersize?view=windowsdesktop-7.0 

    Hope these work fine for your case.

    I have checked te paper size enumaration in Windows and MapInfo both are same.

    Print Windowinfo(frontwindow(), 15)





    ------------------------------
    Ahmet Dabanli
    Başarsoft
    Balgat, Cankaya
    ------------------------------



  • 3.  RE: MapBasic: Dynamically set the paper size based on the window size

    Posted 08-07-2023 16:52

    Thanks for your reply, Ahmet. Unfortunately, the resources you referenced only give me what is in place by default in Windows. The sizes are already enumerated in the MapBasic definitions file, PaperSize.def.

    I need to be able to dynamically (either at runtime or via pre-configuration) be able to create a new custom size Windows printer form that MapBasic can then reference in the Set Window command.



    ------------------------------
    John Hollingsworth
    GIS Director
    Clear Channel Outdoor
    ------------------------------