Use Librarianfile As Input For Labelformat
Is it possible to pull the source for a LabelFormat object from the Librarian storage?
I am creating a web site to allow users to print labels. I would like them to be able to choose a label that doesn't have to be stored on the web site, or loaded from the users desktop. I can create a LibrarianFile object and get the label file from the database, but then how do I use that as the label source for the LabelFormat object? As far as I can tell, the LabelFormat object takes a string of the file location. Using "lib://my_label.btw" doesn't work.
Do I have to save the LibrarianFile to a file and then load it? That seems like a waste of resources. Can't I use it as a Memory Stream or something?
Thanks for the help!
I am creating a web site to allow users to print labels. I would like them to be able to choose a label that doesn't have to be stored on the web site, or loaded from the users desktop. I can create a LibrarianFile object and get the label file from the database, but then how do I use that as the label source for the LabelFormat object? As far as I can tell, the LabelFormat object takes a string of the file location. Using "lib://my_label.btw" doesn't work.
Do I have to save the LibrarianFile to a file and then load it? That seems like a waste of resources. Can't I use it as a Memory Stream or something?
Thanks for the help!
0
-
Shotaro Ito
★ BarTender Hero ★
[quote name='TLBradshaw' timestamp='1333462707' post='2131']
Is it possible to pull the source for a LabelFormat object from the Librarian storage?
[/quote]
Read format directly from librarian "lib://my_label.btw" supposed to work from .net SDK, ActiveX or Commander.
Does command line below work?
From command prompt:
[code]"C:\Program Files\Seagull\BarTender Suite\bartend.exe" /F="lib://my_label.btw"[/code]0 -
[quote name='Shotaro I -Seagull Support' timestamp='1334052239' post='2165']
Read format directly from librarian "lib://my_label.btw" supposed to work from .net SDK, ActiveX or Commander.
Does command line below work?
From command prompt:
[code]"C:\Program Files\Seagull\BarTender Suite\bartend.exe" /F="lib://my_label.btw"[/code]
[/quote]
Yes,
[code]"C:\Program Files\Seagull\BarTender Suite\bartend.exe" /F="lib://my_label.btw"[/code]
Starts up Bartender with the specified Label format.
What I am trying to do is something like this.
[code] Library library = new Library();
LibrarianFile file = library.GetFile("lib://Intermec_.23x1.5.btw");[/code]
This works, and returns a LibrarianFile object with my label.
However, the next step is to do something like this:
[code]LabelFormat btFormat = new LabelFormat(file.Path);[/code]
This fails with the error: "The specified Bar Tender label format does not exist".
BTW, this fails too [code]LabelFormat btFormat = new LabelFormat("lib://Intermec_.23x1.5.btw");[/code]
Thanks for you help.0 -
Shotaro Ito
★ BarTender Hero ★
To load BarTender document from library / file, you need to use Formats.Open method.
[code]
btFormat = btApp.Formats.Open("lib://doc1.btw")
[/code]
Here is a very simple example vb.net + ActiveX app code, to print from library.
Need BarTender Enterprise Automation Edition (or valid trial), system database setup.
[code]Public Class Form1
Dim btApp As BarTender.Application
Dim btFormat As BarTender.Format
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Execute BarTender application'
btApp = New BarTender.Application()
'Show BarTender for debugging purpose'
btApp.VisibleWindows = BarTender.BtVisibleWindows.btAll
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Open a format from Librarian'
btFormat = btApp.Formats.Open("lib://doc1.btw")
'Print the format'
btFormat.PrintOut(False, False)
End Sub
Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
'Terminate BarTender'
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges)
'Release com wrapper'
System.Runtime.InteropServices.Marshal.FinalReleaseComObject(btApp)
End Sub
End Class[/code]0 -
That looks like that would work great if I was building a local application. However, I'm trying to build a website and take advantage of the BartenderPrintClient assembly. Bartender.Application is not included in that assembly, and I believe the code you provided would start a new Bartender Instance for each print job that was submitted.
What I am looking for is a way to use the task manager to queue tasks of labels bases on label formats that are stored in Librarian. I am using the demo code included in the Bartender Print Server SDK called "WebLabelPrint". Everything works fine if I open a librarian file and save is to the server, then load the label file from the server and use it to print. I just thought there should be an easier way to use Librarian and not have to save the file on the Server.
[code]
using Seagull.BarTender.PrintServer;
using Seagull.BarTender.PrintServer.Tasks;
using Seagull.BarTender.Print;
using Seagull.BarTender.Librarian;
Library library = new Library();
LibrarianFile file = library.GetFile("lib://Intermec_.23x1.5.btw");
file.SaveToFile(Request.MapPath("~/LabelFormats/" + file.Name ));
using (TaskManager btTaskManager = new TaskManager())
{
// Start a TaskEngine.
btTaskManager.Start(1);
//This doesn't work, but seems like it should!
//LabelFormat btFormat = new LabelFormat(file.Path);
LabelFormat btFormat = new LabelFormat(Request.MapPath("~/LabelFormats/" + file.Name));
PrintLabelFormatTask btTask = new PrintLabelFormatTask(btFormat.FileName, ddlPrinters.SelectedValue);
// Submit the Task to the TaskQueue.
TaskStatus btTaskStatus = btTaskManager.TaskQueue.QueueTask(btTask);
// Stop the TaskEngines.
// The wait timeout is the maximum time we wait for the
// asynchronous task above to finish before stopping.
btTaskManager.Stop(10000, true);
}
[/code]
Thanks again for all your help!0 -
Shotaro Ito
★ BarTender Hero ★
I finally figured out what was the issue.
Up to BarTender 9.4, librarian integration has not been supported in GetLabelFormatTask() and PrintLabelFormatTask() in the PrintServer() class.
That has been supported from 10.0.
You can write a custom task like below (C#), to get document from librarian and pass to GetLabelFormatTask().
(haven't tested by myself - it was one suggestion from dev team.)
[code]
class LibrarianGetFormatTask : Task
{
private LabelFormat m_format = null;
private string m_fileName = null;
public LibrarianGetFormatTask(string fileName)
{
m_fileName = fileName;
}
public LabelFormat LabelFormat
{
get
{
return m_format;
}
}
protected override bool OnRun()
{
LabelFormatDocument formatDoc = null;
try
{
formatDoc = Engine.Documents.Open(m_fileName);
m_format = formatDoc;
}
catch//Either the filename is invalid or we timed out and lost BarTender.
{
try
{
//attempt to close if the format is still open.
formatDoc.Close(SaveOptions.DoNotSaveChanges);
}
catch (Exception)
{
}
throw;
}
formatDoc.Close(SaveOptions.DoNotSaveChanges);
return base.OnRun();
}
}
[/code]
or.. yes, I think your current workaround (use temp file) would be a viable solution too.0 -
Hi,
Is there a way to display Librarian files from an HTML web from so user can select the files and save it to local disk?
0 -
Shotaro Ito
★ BarTender Hero ★
There is Librarian SDK to list files in library and get files in library. See SDK documentation > BarTender .NET Librarian SDK. If you coudn't find the documentation..
0 -
Thank you very much that documentation helped a lot...
0
Iniciar sesión para dejar un comentario.
Comentarios
8 comentarios