Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
0 I'm creating VB application where i want to print documents, but all of my documents have diffirent orientation, some of them are in Portret orientation and some of them are in Landscame.

I have a function where user can print bunch of files, like more then one which have different orientation.

This is the code which i use to set the settings of the printer programatically:

VB
Dim Printers As PrinterSettings.StringCollection Printers = printerSettings.InstalledPrinters Dim printerSettings As New PrinterSettings

printerSettings.DefaultPageSettings.PaperSize = pageSettings.PaperSize printerSettings.DefaultPageSettings.PrinterResolution = pageSettings.PrinterResolution printerSettings.DefaultPageSettings.Color = pageSettings.Color printerSettings.DefaultPageSettings.Landscape = pageSettings.Landscape printerSettings.DefaultPageSettings.PrinterSettings = printerSettings.DefaultPageSettings.PrinterSettings printerSettings.DefaultPageSettings.PaperSource = pageSettings.PaperSource


I can setup the orientation here: pageSettings.Landscape, but it will be only Landscape or only Portrait. I want to be automatically detected?

Is that possible?

If not, is there a way to check file orientation before print the file programatically with VB?

What I have tried:

I try to add auto to the: pageSettings.Landscape but it accepts only true/false.
Posted
Updated 21-Jul-23 6:23am
Comments
Richard MacCutchan 21-Jul-23 12:20pm    
You need some property in each file that tells which orientation it is set for. So check the settings available for the type of documents you are processing.

1 solution

You can't look at a file from the outside and say "this is portrait" or "this is landscape" - and that means you have to read the file content (which means you need to understand the file format or find software that can) and work it out.

But even then, it's probably not simple - some file formats do include page the settings you need (like Word and PDF) but many others don't (like text files, databases, source code files).

I'd say that it's probably going to be a significant amount of work to try and automate this: You would have to decide if it is worth your time investment - we cannot tell you "do this" at all!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900