dynapdf question - programmatically set A6 paper size

  1. 6 months ago

    nicolás c

    May 24 Pre-Release Testers, Xojo Pro

    this is my problem

    the pdf has A6 size and the printer config has A4

    i was studyng the example project "Print PDF" but i can't PROGRAMMATICALLY configure the printer to match automatically the PDF SIZE

    but i think i have a clue.. to print a PDF i use the following code:

    if pdf.PrintPDFFileWithDialog(nil, "doc name here",0,nil,nil,nil) = true then
        msgbox "ok"
      else
        msgbox "print cancelled"
      end if

    works great. but the PDF is A6 and i don't want to obligate the user to select A6 format manually... i want to set the page size automatically.

    i think that after the above code i could use something like this

    dim p as DynaPDFPrintParamsMBS
    p.PageSize

    but i don't even have a clue of how to use it.

    i know that instead nil.. i have to use "p" in the corresponding pdf.PrintPDFFileWithDialog parameter

    how do i set pagesize using DynaPDFPrintParamsMBS??

    i have read the documentation but i don't figure out how to do it

  2. Jeff T

    May 24 Pre-Release Testers Midlands of England, Europe

    This is doomed to fail.

    i want to set the page size automatically.

    Why should you be able to do that?
    Say the customer has a printer that only has A4 paper in it.
    If you try and succeed to force A6, the printer will just stop and put up a message saying 'insert A6 tray' or similar.

    You are creating a document.
    if you want to print, ask the printer what paper size it is using, create a PDF of that size, and print that.

    Otherwise, give the customer the document and let then decide how to print it.

  3. nicolás c

    May 24 Pre-Release Testers, Xojo Pro
    Edited 6 months ago

    thanks Jeff

    Why should you be able to do that?

    i want to print A6 labels and then print A4 reports and then A6 labels.. and so on, in the same printer. i don't want to force users to manually change paper size many times

    Say the customer has a printer that only has A4 paper in it.

    that will never be the case with any of my clients.

  4. Christian S

    May 27 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    well, you can create a custom printer setup for Windows with WindowsDeviceModeMBS class:

    dim d as new WindowsDeviceModeMBS
    dim name as string = "My printer"
    
    d.Fields = d.DM_PAPERSIZE
    d.PaperSize = d.DMPAPER_A6 
    
    dim data as string = d.RawData

    Next you can pass that data to DynaPDFMBS .PrintSetDevMode(data as String) as Boolean method.

    This may tell DynaPDF to use this printer setup.

  5. nicolás c

    May 28 Pre-Release Testers, Xojo Pro
    Edited 6 months ago
    dim d as new WindowsDeviceModeMBS
    
    d.Fields = d.DM_PAPERSIZE
    d.PaperSize = d.DMPAPER_A6
    
    dim data as string = d.RawData
    
    if pdf.PrintSetDevMode(data) then
      msgbox "ok"
    else
      msgbox "not set"
    end if
    
    if pdf.PrintPDFFileWithDialog(nil, "doc name here",0,nil,nil,nil) = true then
      msgbox "ok"
    else
      msgbox "print cancelled"
    end if

    this code does't seem to work.
    I've dived through the MBS documentation, but It seems like I can't put the puzzle together

    if i use

    if pdf.PrintPDFFile(InputFile, "doc name here","HP LaserJet Professional P1606dn",0,nil,nil) = true then

    doesn't seem to work either

    FWIW, I clarify that my printer has native support for A6 paper size

  6. nicolás c

    May 28 Pre-Release Testers, Xojo Pro

    if i set number of copies... works perfect..

    d.fields = d.DM_COPIES
    d.Copies = 8

    but

    d.Fields = d.DM_PAPERSIZE
    d.PaperSize = d.DMPAPER_A6

    It doesn't seem to work at all

  7. Christian S

    May 30 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Does it work with showing print dialog?
    What settings are in device mode after dialog is used?

or Sign Up to reply!