Closed VitalyEG closed 5 years ago
Hi @VitalyEG!
PtrFactory
is targets output parameters, so data which already exists. You need a way to create PrintRawFile310
to pass it as input, I suggest you create a Builder class:
public class PrintRawFile310 extends Struct {
public static class Builder {
private final String fileName;
private Set<MediaControl> mediaControl;
private Optional<PaperSource> paperSource;
public Builder(String fileName) {
this.fileName = fileName;
mediaControl = EnumSet.noneOf(MediaControl.class);
paperSource = Optional.empty();
}
public Builder mediaControl(Set<MediaControl> mediaControl) {
this.mediaControl = mediaControl;
return this;
}
public Builder paperSource(Optional<PaperSource> paperSource) {
this.paperSource = paperSource;
return this;
}
public PrintRawFile310 build() {
PrintRawFile310 result = new PrintRawFile310();
result.allocate();
result.fileName.set(fileName);
result.mediaControl.set(mediaControl);
if (paperSource.isPresent()) {
result.paperSource.set(paperSource.get());
}
return result;
}
}
And I don't know if a XPS file works, it completely depends on your service provider/hardware.
I wrote like this. Could you change it?
**package at.o2xfs.xfs.v3_10.ptr;
import java.util.Set;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import at.o2xfs.win32.LPSTR; import at.o2xfs.win32.Pointer; import at.o2xfs.win32.Struct; import at.o2xfs.xfs.ptr.MediaControl; import at.o2xfs.xfs.ptr.PaperSource; import at.o2xfs.xfs.win32.XfsDWord; import at.o2xfs.xfs.win32.XfsDWordBitmask;
public class PrintRawFile310 extends Struct {
protected final LPSTR fileName = new LPSTR();
protected final XfsDWordBitmask
public static class Builder {
private final LPSTR fileName;
private Set<MediaControl> mediaControl;
private PaperSource paperSource;
public Builder(String fileName) {
LPSTR fileNameLPSTR = new LPSTR();
fileNameLPSTR.allocate();
fileNameLPSTR.set(fileName);
this.fileName = fileNameLPSTR;
}
public Builder mediaControl(Set<MediaControl> mediaControl) {
this.mediaControl = mediaControl;
return this;
}
public Builder paperSource(PaperSource paperSource) {
this.paperSource = paperSource;
return this;
}
public PrintRawFile310 build() {
return new PrintRawFile310(this);
}
}
public PrintRawFile310() { add(fileName); add(mediaControl); add(paperSource); }
protected PrintRawFile310(Builder builder) { this(); allocate(); fileName.set(builder.fileName); mediaControl.set(builder.mediaControl); paperSource.set(builder.paperSource); }
public PrintRawFile310(Pointer p) { this(); assignBuffer(p); }
public PrintRawFile310(PrintRawFile310 copy) { this(); allocate(); set(copy); }
public void set(PrintRawFile310 copy) { fileName.set(copy.getFileName()); mediaControl.set(copy.getMediaControl()); paperSource.set(copy.getPaperSource()); }
public String getFileName() { return fileName.get(); }
public Set
public PaperSource getPaperSource() { return paperSource.get(); }
@Override public int hashCode() { return new HashCodeBuilder() .append(getFileName()) .append(getMediaControl()) .append(getPaperSource()) .toHashCode(); }
@Override public boolean equals(Object obj) { if (obj instanceof PrintRawFile310) { PrintRawFile310 printRawFile310 = (PrintRawFile310) obj; return new EqualsBuilder() .append(getFileName(), printRawFile310.getFileName()) .append(getMediaControl(), printRawFile310.getMediaControl()) .append(getPaperSource(), printRawFile310.getPaperSource()) .isEquals(); } return false; }
@Override public String toString() { return new ToStringBuilder(this) .append("fileName", getFileName()) .append("mediaControl", getMediaControl()) .append("paperSource", getPaperSource()) .toString(); } }**
Ok. Thanks!
Hi, Andreas! Could you answer me how to print data using PrintRawFile310? There is PtrFactory factory and PrintRawFile310 structure, but I don't know how to use it? PrintRawFile310 stucture contains file that will have been created through the Windows GDI print sub-system. How can I create such file? And could I put file name of XPS format?